Hide merge request option in IDE when merge requests are disabled

Closes #45698
This commit is contained in:
Phil Hughes 2018-05-09 17:07:02 +01:00
parent 1802954b47
commit 5c8f31eb7e
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
4 changed files with 29 additions and 1 deletions

View File

@ -1,5 +1,5 @@
<script>
import { mapActions, mapState } from 'vuex';
import { mapActions, mapState, mapGetters } from 'vuex';
import { sprintf, __ } from '~/locale';
import * as consts from '../../stores/modules/commit/constants';
import RadioGroup from './radio_group.vue';
@ -10,6 +10,7 @@ export default {
},
computed: {
...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']),
...mapGetters(['currentProject']),
commitToCurrentBranchText() {
return sprintf(
__('Commit to %{branchName} branch'),
@ -52,6 +53,7 @@ export default {
:show-input="true"
/>
<radio-group
v-if="currentProject.merge_requests_enabled"
:value="$options.commitToNewBranchMR"
:label="__('Create a new branch and merge request')"
:show-input="true"

View File

@ -0,0 +1,5 @@
---
title: Hide merge request option in IDE when disabled
merge_request:
author:
type: changed

View File

@ -3,6 +3,7 @@ import store from '~/ide/stores';
import commitActions from '~/ide/components/commit_sidebar/actions.vue';
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import { resetStore } from 'spec/ide/helpers';
import { projectData } from 'spec/ide/mock_data';
describe('IDE commit sidebar actions', () => {
let vm;
@ -13,6 +14,10 @@ describe('IDE commit sidebar actions', () => {
vm = createComponentWithStore(Component, store);
vm.$store.state.currentBranchId = 'master';
vm.$store.state.currentProjectId = 'abcproject';
vm.$store.state.projects.abcproject = {
...projectData,
};
vm.$mount();
@ -32,4 +37,19 @@ describe('IDE commit sidebar actions', () => {
it('renders current branch text', () => {
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();
});
});
});

View File

@ -12,4 +12,5 @@ export const projectData = {
},
},
mergeRequests: {},
merge_requests_enabled: true,
};