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

111 lines
3 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';
2018-10-15 14:42:47 +05:30
import Icon from '~/vue_shared/components/icon.vue';
2018-05-09 12:01:36 +05:30
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';
2018-05-09 12:01:36 +05:30
import * as consts from '../stores/modules/commit/constants';
2018-10-15 14:42:47 +05:30
import { activityBarViews } from '../constants';
2018-05-09 12:01:36 +05:30
export default {
components: {
DeprecatedModal,
2018-10-15 14:42:47 +05:30
Icon,
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-10-15 14:42:47 +05:30
...mapGetters(['lastOpenedFile', 'hasChanges', 'someUncommitedChanges']),
...mapGetters('commit', ['commitButtonDisabled', 'discardDraftButtonDisabled']),
showStageUnstageArea() {
return !!(this.someUncommitedChanges || this.lastCommitMsg || !this.unusedSeal);
2018-05-09 12:01:36 +05:30
},
},
2018-10-15 14:42:47 +05:30
watch: {
hasChanges() {
if (!this.hasChanges) {
this.updateActivityBarView(activityBarViews.edit);
}
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
},
mounted() {
if (this.lastOpenedFile) {
this.openPendingTab({
file: this.lastOpenedFile,
})
.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
},
},
};
</script>
<template>
<div
class="multi-file-commit-panel-section"
>
<deprecated-modal
id="ide-create-branch-modal"
:primary-button-label="__('Create new branch')"
kind="success"
:title="__('Branch has changed')"
@submit="forceCreateNewBranch"
>
<template slot="body">
{{ __(`This branch has changed since you started editing.
Would you like to create a new branch?`) }}
</template>
</deprecated-modal>
<template
2018-10-15 14:42:47 +05:30
v-if="showStageUnstageArea"
2018-05-09 12:01:36 +05:30
>
2018-10-15 14:42:47 +05:30
<commit-files-list
class="is-first"
icon-name="unstaged"
:title="__('Unstaged')"
:file-list="changedFiles"
action="stageAllChanges"
:action-btn-text="__('Stage all')"
item-action-component="stage-button"
/>
<commit-files-list
icon-name="staged"
:title="__('Staged')"
:file-list="stagedFiles"
action="unstageAllChanges"
:action-btn-text="__('Unstage all')"
item-action-component="unstage-button"
:staged-list="true"
/>
2018-05-09 12:01:36 +05:30
</template>
2018-10-15 14:42:47 +05:30
<empty-state
v-if="unusedSeal"
/>
2018-05-09 12:01:36 +05:30
</div>
</template>