2018-05-09 12:01:36 +05:30
|
|
|
<script>
|
|
|
|
import { mapState, mapActions, mapGetters } from 'vuex';
|
|
|
|
import tooltip from '~/vue_shared/directives/tooltip';
|
2018-10-15 14:42:47 +05:30
|
|
|
import CommitFilesList from './commit_sidebar/list.vue';
|
|
|
|
import EmptyState from './commit_sidebar/empty_state.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
import { stageKeys } from '../constants';
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2018-10-15 14:42:47 +05:30
|
|
|
CommitFilesList,
|
|
|
|
EmptyState,
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
computed: {
|
2020-06-23 00:09:42 +05:30
|
|
|
...mapState(['changedFiles', 'stagedFiles', 'lastCommitMsg']),
|
2018-05-09 12:01:36 +05:30
|
|
|
...mapState('commit', ['commitMessage', 'submitCommitLoading']),
|
2020-06-23 00:09:42 +05:30
|
|
|
...mapGetters(['lastOpenedFile', 'someUncommittedChanges', 'activeFile']),
|
2018-11-08 19:23:39 +05:30
|
|
|
...mapGetters('commit', ['discardDraftButtonDisabled']),
|
2018-10-15 14:42:47 +05:30
|
|
|
showStageUnstageArea() {
|
2020-06-23 00:09:42 +05:30
|
|
|
return Boolean(this.someUncommittedChanges || this.lastCommitMsg);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
activeFileKey() {
|
|
|
|
return this.activeFile ? this.activeFile.key : null;
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
mounted() {
|
2020-06-23 00:09:42 +05:30
|
|
|
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,
|
|
|
|
})
|
|
|
|
.then(changeViewer => {
|
|
|
|
if (changeViewer) {
|
|
|
|
this.updateViewer('diff');
|
|
|
|
}
|
2018-10-15 14:42:47 +05:30
|
|
|
})
|
2020-06-23 00:09:42 +05:30
|
|
|
.catch(e => {
|
|
|
|
throw e;
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['openPendingTab', 'updateViewer', 'updateActivityBarView']),
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
stageKeys,
|
2018-05-09 12:01:36 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-02-15 15:39:39 +05:30
|
|
|
<div class="multi-file-commit-panel-section">
|
|
|
|
<template v-if="showStageUnstageArea">
|
2018-10-15 14:42:47 +05:30
|
|
|
<commit-files-list
|
2018-11-08 19:23:39 +05:30
|
|
|
:key-prefix="$options.stageKeys.staged"
|
2018-10-15 14:42:47 +05:30
|
|
|
:file-list="stagedFiles"
|
2018-11-08 19:23:39 +05:30
|
|
|
:active-file-key="activeFileKey"
|
2020-04-08 14:13:33 +05:30
|
|
|
:empty-state-text="__('There are no changes')"
|
|
|
|
class="is-first"
|
|
|
|
icon-name="unstaged"
|
2018-10-15 14:42:47 +05:30
|
|
|
/>
|
2018-05-09 12:01:36 +05:30
|
|
|
</template>
|
2020-06-23 00:09:42 +05:30
|
|
|
<empty-state v-else />
|
2018-05-09 12:01:36 +05:30
|
|
|
</div>
|
|
|
|
</template>
|