2018-03-20 10:12:48 -04:00
|
|
|
<script>
|
2018-05-02 06:47:36 -04:00
|
|
|
import { mapState, mapActions, mapGetters } from 'vuex';
|
2021-02-01 10:08:56 -05:00
|
|
|
import { stageKeys } from '../constants';
|
2018-03-21 06:05:08 -04:00
|
|
|
import EmptyState from './commit_sidebar/empty_state.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import CommitFilesList from './commit_sidebar/list.vue';
|
2018-03-20 10:12:48 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2018-04-18 09:14:45 -04:00
|
|
|
CommitFilesList,
|
2018-03-21 06:05:08 -04:00
|
|
|
EmptyState,
|
2018-03-20 10:12:48 -04:00
|
|
|
},
|
|
|
|
computed: {
|
2020-05-27 14:08:14 -04:00
|
|
|
...mapState(['changedFiles', 'stagedFiles', 'lastCommitMsg']),
|
2018-02-28 16:47:44 -05:00
|
|
|
...mapState('commit', ['commitMessage', 'submitCommitLoading']),
|
2020-05-29 11:08:14 -04:00
|
|
|
...mapGetters(['lastOpenedFile', 'someUncommittedChanges', 'activeFile']),
|
2018-06-15 04:57:54 -04:00
|
|
|
...mapGetters('commit', ['discardDraftButtonDisabled']),
|
2018-05-03 07:39:22 -04:00
|
|
|
showStageUnstageArea() {
|
2020-05-27 14:08:14 -04:00
|
|
|
return Boolean(this.someUncommittedChanges || this.lastCommitMsg);
|
2018-05-03 07:39:22 -04:00
|
|
|
},
|
2018-06-12 05:02:15 -04:00
|
|
|
activeFileKey() {
|
|
|
|
return this.activeFile ? this.activeFile.key : null;
|
|
|
|
},
|
2018-05-02 06:47:36 -04:00
|
|
|
},
|
2018-05-01 06:51:23 -04:00
|
|
|
mounted() {
|
2020-09-25 11:09:36 -04:00
|
|
|
this.initialize();
|
|
|
|
},
|
|
|
|
activated() {
|
|
|
|
this.initialize();
|
2018-05-01 06:51:23 -04:00
|
|
|
},
|
2018-03-20 10:12:48 -04:00
|
|
|
methods: {
|
2018-05-02 06:47:36 -04:00
|
|
|
...mapActions(['openPendingTab', 'updateViewer', 'updateActivityBarView']),
|
2020-09-25 11:09:36 -04:00
|
|
|
initialize() {
|
|
|
|
const file =
|
|
|
|
this.lastOpenedFile && this.lastOpenedFile.type !== 'tree'
|
|
|
|
? this.lastOpenedFile
|
|
|
|
: this.activeFile;
|
|
|
|
|
|
|
|
if (!file) return;
|
|
|
|
|
|
|
|
this.openPendingTab({
|
|
|
|
file,
|
|
|
|
keyPrefix: file.staged ? stageKeys.staged : stageKeys.unstaged,
|
|
|
|
})
|
2020-12-23 19:10:25 -05:00
|
|
|
.then((changeViewer) => {
|
2020-09-25 11:09:36 -04:00
|
|
|
if (changeViewer) {
|
|
|
|
this.updateViewer('diff');
|
|
|
|
}
|
|
|
|
})
|
2020-12-23 19:10:25 -05:00
|
|
|
.catch((e) => {
|
2020-09-25 11:09:36 -04:00
|
|
|
throw e;
|
|
|
|
});
|
|
|
|
},
|
2018-03-20 10:12:48 -04:00
|
|
|
},
|
2018-06-13 05:10:24 -04:00
|
|
|
stageKeys,
|
2018-03-20 10:12:48 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-11-16 15:07:38 -05:00
|
|
|
<div class="multi-file-commit-panel-section">
|
|
|
|
<template v-if="showStageUnstageArea">
|
2018-03-21 06:05:08 -04:00
|
|
|
<commit-files-list
|
2018-06-13 05:10:24 -04:00
|
|
|
:key-prefix="$options.stageKeys.staged"
|
2018-03-21 06:05:08 -04:00
|
|
|
:file-list="stagedFiles"
|
2018-06-13 06:58:51 -04:00
|
|
|
:active-file-key="activeFileKey"
|
2020-03-13 08:09:22 -04:00
|
|
|
:empty-state-text="__('There are no changes')"
|
|
|
|
class="is-first"
|
2018-03-21 06:05:08 -04:00
|
|
|
/>
|
2018-03-20 10:12:48 -04:00
|
|
|
</template>
|
2020-05-27 14:08:14 -04:00
|
|
|
<empty-state v-else />
|
2018-03-20 10:12:48 -04:00
|
|
|
</div>
|
|
|
|
</template>
|