1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<script>
import { mapGetters, createNamespacedHelpers } from 'vuex';
const {
mapState: mapCommitState,
mapGetters: mapCommitGetters,
mapActions: mapCommitActions,
} = createNamespacedHelpers('commit');
export default {
computed: {
...mapCommitState(['shouldCreateMR']),
...mapCommitGetters(['isCommittingToCurrentBranch', 'isCommittingToDefaultBranch']),
...mapGetters(['hasMergeRequest', 'isOnDefaultBranch']),
currentBranchHasMr() {
return this.hasMergeRequest && this.isCommittingToCurrentBranch;
},
showNewMrOption() {
return (
this.isCommittingToDefaultBranch || !this.currentBranchHasMr || this.isCommittingToNewBranch
);
},
},
mounted() {
this.setShouldCreateMR();
},
methods: {
...mapCommitActions(['toggleShouldCreateMR', 'setShouldCreateMR']),
},
};
</script>
<template>
<div v-if="showNewMrOption">
<hr class="my-2" />
<label class="mb-0">
<input :checked="shouldCreateMR" type="checkbox" @change="toggleShouldCreateMR" />
<span class="prepend-left-10">
{{ __('Start a new merge request') }}
</span>
</label>
</div>
</template>
|