debian-mirror-gitlab/app/assets/javascripts/ide/components/repo_commit_section.vue

100 lines
2.9 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
import { mapState, mapActions, mapGetters } from 'vuex';
import tooltip from '~/vue_shared/directives/tooltip';
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
2018-10-15 14:42:47 +05:30
import CommitFilesList from './commit_sidebar/list.vue';
import EmptyState from './commit_sidebar/empty_state.vue';
2019-07-07 11:18:12 +05:30
import consts from '../stores/modules/commit/constants';
2020-03-13 15:44:24 +05:30
import { leftSidebarViews, stageKeys } from '../constants';
2018-05-09 12:01:36 +05:30
export default {
components: {
DeprecatedModal,
2018-10-15 14:42:47 +05:30
CommitFilesList,
EmptyState,
2018-05-09 12:01:36 +05:30
},
directives: {
tooltip,
},
computed: {
...mapState([
2018-10-15 14:42:47 +05:30
'changedFiles',
'stagedFiles',
2018-05-09 12:01:36 +05:30
'rightPanelCollapsed',
'lastCommitMsg',
2018-10-15 14:42:47 +05:30
'unusedSeal',
2018-05-09 12:01:36 +05:30
]),
...mapState('commit', ['commitMessage', 'submitCommitLoading']),
2018-12-13 13:39:08 +05:30
...mapGetters(['lastOpenedFile', 'hasChanges', 'someUncommittedChanges', 'activeFile']),
2018-11-08 19:23:39 +05:30
...mapGetters('commit', ['discardDraftButtonDisabled']),
2018-10-15 14:42:47 +05:30
showStageUnstageArea() {
2019-09-04 21:01:54 +05:30
return Boolean(this.someUncommittedChanges || this.lastCommitMsg || !this.unusedSeal);
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
watch: {
hasChanges() {
if (!this.hasChanges) {
2020-03-13 15:44:24 +05:30
this.updateActivityBarView(leftSidebarViews.edit.name);
2018-10-15 14:42:47 +05:30
}
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
},
mounted() {
2018-11-18 11:00:15 +05:30
if (this.lastOpenedFile && this.lastOpenedFile.type !== 'tree') {
2018-10-15 14:42:47 +05:30
this.openPendingTab({
file: this.lastOpenedFile,
2020-04-22 19:07:51 +05:30
keyPrefix: this.lastOpenedFile.staged ? stageKeys.staged : stageKeys.unstaged,
2018-10-15 14:42:47 +05:30
})
.then(changeViewer => {
if (changeViewer) {
this.updateViewer('diff');
}
})
.catch(e => {
throw e;
});
}
},
methods: {
...mapActions(['openPendingTab', 'updateViewer', 'updateActivityBarView']),
...mapActions('commit', ['commitChanges', 'updateCommitAction']),
2018-05-09 12:01:36 +05:30
forceCreateNewBranch() {
2018-10-15 14:42:47 +05:30
return this.updateCommitAction(consts.COMMIT_TO_NEW_BRANCH).then(() => this.commitChanges());
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">
2018-05-09 12:01:36 +05:30
<deprecated-modal
id="ide-create-branch-modal"
:primary-button-label="__('Create new branch')"
:title="__('Branch has changed')"
2018-11-08 19:23:39 +05:30
kind="success"
2018-05-09 12:01:36 +05:30
@submit="forceCreateNewBranch"
>
<template slot="body">
2019-02-15 15:39:39 +05:30
{{
__(`This branch has changed since you started editing.
Would you like to create a new branch?`)
}}
2018-05-09 12:01:36 +05:30
</template>
</deprecated-modal>
2019-02-15 15:39:39 +05:30
<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>
2019-02-15 15:39:39 +05:30
<empty-state v-if="unusedSeal" />
2018-05-09 12:01:36 +05:30
</div>
</template>