Hide merge request option in IDE when merge requests are disabled
Closes #45698
This commit is contained in:
parent
1802954b47
commit
5c8f31eb7e
4 changed files with 29 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapActions, mapState } from 'vuex';
|
import { mapActions, mapState, mapGetters } from 'vuex';
|
||||||
import { sprintf, __ } from '~/locale';
|
import { sprintf, __ } from '~/locale';
|
||||||
import * as consts from '../../stores/modules/commit/constants';
|
import * as consts from '../../stores/modules/commit/constants';
|
||||||
import RadioGroup from './radio_group.vue';
|
import RadioGroup from './radio_group.vue';
|
||||||
|
@ -10,6 +10,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']),
|
...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']),
|
||||||
|
...mapGetters(['currentProject']),
|
||||||
commitToCurrentBranchText() {
|
commitToCurrentBranchText() {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
__('Commit to %{branchName} branch'),
|
__('Commit to %{branchName} branch'),
|
||||||
|
@ -52,6 +53,7 @@ export default {
|
||||||
:show-input="true"
|
:show-input="true"
|
||||||
/>
|
/>
|
||||||
<radio-group
|
<radio-group
|
||||||
|
v-if="currentProject.merge_requests_enabled"
|
||||||
:value="$options.commitToNewBranchMR"
|
:value="$options.commitToNewBranchMR"
|
||||||
:label="__('Create a new branch and merge request')"
|
:label="__('Create a new branch and merge request')"
|
||||||
:show-input="true"
|
:show-input="true"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Hide merge request option in IDE when disabled
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: changed
|
|
@ -3,6 +3,7 @@ import store from '~/ide/stores';
|
||||||
import commitActions from '~/ide/components/commit_sidebar/actions.vue';
|
import commitActions from '~/ide/components/commit_sidebar/actions.vue';
|
||||||
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
||||||
import { resetStore } from 'spec/ide/helpers';
|
import { resetStore } from 'spec/ide/helpers';
|
||||||
|
import { projectData } from 'spec/ide/mock_data';
|
||||||
|
|
||||||
describe('IDE commit sidebar actions', () => {
|
describe('IDE commit sidebar actions', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -13,6 +14,10 @@ describe('IDE commit sidebar actions', () => {
|
||||||
vm = createComponentWithStore(Component, store);
|
vm = createComponentWithStore(Component, store);
|
||||||
|
|
||||||
vm.$store.state.currentBranchId = 'master';
|
vm.$store.state.currentBranchId = 'master';
|
||||||
|
vm.$store.state.currentProjectId = 'abcproject';
|
||||||
|
vm.$store.state.projects.abcproject = {
|
||||||
|
...projectData,
|
||||||
|
};
|
||||||
|
|
||||||
vm.$mount();
|
vm.$mount();
|
||||||
|
|
||||||
|
@ -32,4 +37,19 @@ describe('IDE commit sidebar actions', () => {
|
||||||
it('renders current branch text', () => {
|
it('renders current branch text', () => {
|
||||||
expect(vm.$el.textContent).toContain('Commit to master branch');
|
expect(vm.$el.textContent).toContain('Commit to master branch');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('hides merge request option when project merge requests are disabled', done => {
|
||||||
|
vm.$destroy();
|
||||||
|
|
||||||
|
vm.$store.state.projects.abcproject.merge_requests_enabled = false;
|
||||||
|
|
||||||
|
vm.$mount();
|
||||||
|
|
||||||
|
vm.$nextTick(() => {
|
||||||
|
expect(vm.$el.querySelectorAll('input[type="radio"]').length).toBe(2);
|
||||||
|
expect(vm.$el.textContent).not.toContain('Create a new branch and merge request');
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,4 +12,5 @@ export const projectData = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mergeRequests: {},
|
mergeRequests: {},
|
||||||
|
merge_requests_enabled: true,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue