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

63 lines
1.7 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2018-10-15 14:42:47 +05:30
import _ from 'underscore';
import { mapActions, mapState } from 'vuex';
import { sprintf, __ } from '~/locale';
import * as consts from '../../stores/modules/commit/constants';
import RadioGroup from './radio_group.vue';
2018-05-09 12:01:36 +05:30
2018-10-15 14:42:47 +05:30
export default {
components: {
RadioGroup,
},
computed: {
...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']),
commitToCurrentBranchText() {
return sprintf(
__('Commit to %{branchName} branch'),
{ branchName: `<strong class="monospace">${_.escape(this.currentBranchId)}</strong>` },
false,
);
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
disableMergeRequestRadio() {
return this.changedFiles.length > 0 && this.stagedFiles.length > 0;
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
},
mounted() {
if (this.disableMergeRequestRadio) {
this.updateCommitAction(consts.COMMIT_TO_CURRENT_BRANCH);
}
},
methods: {
...mapActions('commit', ['updateCommitAction']),
},
commitToCurrentBranch: consts.COMMIT_TO_CURRENT_BRANCH,
commitToNewBranch: consts.COMMIT_TO_NEW_BRANCH,
commitToNewBranchMR: consts.COMMIT_TO_NEW_BRANCH_MR,
};
2018-05-09 12:01:36 +05:30
</script>
<template>
<div class="append-bottom-15 ide-commit-radios">
<radio-group
:value="$options.commitToCurrentBranch"
:checked="true"
>
<span
v-html="commitToCurrentBranchText"
>
</span>
</radio-group>
<radio-group
:value="$options.commitToNewBranch"
:label="__('Create a new branch')"
:show-input="true"
/>
<radio-group
:value="$options.commitToNewBranchMR"
:label="__('Create a new branch and merge request')"
:show-input="true"
2018-10-15 14:42:47 +05:30
:disabled="disableMergeRequestRadio"
2018-05-09 12:01:36 +05:30
/>
</div>
</template>