Commit e5bbb6dc authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'nfriend-fix-the-merge-button' into 'master'

Fix the merge button dropdown

Closes gitlab-ce#64970

See merge request gitlab-org/gitlab-ee!14894
parents 6922316f d13a9ae1
......@@ -94,9 +94,6 @@ export default {
return __('Merge');
},
shouldShowMergeOptionsDropdown() {
return this.isAutoMergeAvailable && !this.mr.onlyAllowMergeIfPipelineSucceeds;
},
isRemoveSourceBranchButtonDisabled() {
return this.isMergeButtonDisabled;
},
......@@ -246,7 +243,7 @@ export default {
{{ mergeButtonText }}
</button>
<button
v-if="isAutoMergeAvailable"
v-if="shouldShowMergeImmediatelyDropdown"
:disabled="isMergeButtonDisabled"
type="button"
class="btn btn-sm btn-info dropdown-toggle js-merge-moment"
......@@ -256,7 +253,7 @@ export default {
<i class="fa fa-chevron-down qa-merge-moment-dropdown" aria-hidden="true"></i>
</button>
<ul
v-if="shouldShowMergeOptionsDropdown"
v-if="shouldShowMergeImmediatelyDropdown"
class="dropdown-menu dropdown-menu-right"
role="menu"
>
......
......@@ -15,5 +15,8 @@ export default {
// MWPS is currently the only auto merge strategy available in CE
return __('Merge when pipeline succeeds');
},
shouldShowMergeImmediatelyDropdown() {
return this.mr.isPipelineActive && !this.mr.onlyAllowMergeIfPipelineSucceeds;
},
},
};
......@@ -30,5 +30,12 @@ export default {
}
return __('Merge when pipeline succeeds');
},
shouldShowMergeImmediatelyDropdown() {
if (this.mr.preferredAutoMergeStrategy === MT_MERGE_STRATEGY) {
return true;
}
return this.mr.isPipelineActive && !this.mr.onlyAllowMergeIfPipelineSucceeds;
},
},
};
---
title: Fix issue that caused the "Merge Immediately" option not to be available when
merge trains were enabled
merge_request: 14894
author:
type: fixed
......@@ -141,4 +141,43 @@ describe('ReadyToMerge', () => {
});
});
});
describe('shouldShowMergeImmediatelyDropdown', () => {
it('should return false if no pipeline is active', () => {
factory({
isPipelineActive: false,
onlyAllowMergeIfPipelineSucceeds: false,
});
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(false);
});
it('should return false if "Pipelines must succeed" is enabled for the current project', () => {
factory({
isPipelineActive: true,
onlyAllowMergeIfPipelineSucceeds: true,
});
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(false);
});
it('should return true if the MR\'s pipeline is active and "Pipelines must succeed" is not enabled for the current project', () => {
factory({
isPipelineActive: true,
onlyAllowMergeIfPipelineSucceeds: false,
});
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(true);
});
it('should return true when the merge train auto merge stategy is available ', () => {
factory({
preferredAutoMergeStrategy: MT_MERGE_STRATEGY,
isPipelineActive: false,
onlyAllowMergeIfPipelineSucceeds: true,
});
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(true);
});
});
});
......@@ -236,24 +236,26 @@ describe('ReadyToMerge', () => {
});
});
describe('shouldShowMergeOptionsDropdown', () => {
it('should return false when no auto merge strategies are available', () => {
Vue.set(vm.mr, 'availableAutoMergeStrategies', []);
describe('shouldShowMergeImmediatelyDropdown', () => {
it('should return false if no pipeline is active', () => {
Vue.set(vm.mr, 'isPipelineActive', false);
Vue.set(vm.mr, 'onlyAllowMergeIfPipelineSucceeds', false);
expect(vm.shouldShowMergeOptionsDropdown).toBe(false);
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(false);
});
it('should return true when at least one auto merge strategy is available', () => {
Vue.set(vm.mr, 'availableAutoMergeStrategies', [ATMTWPS_MERGE_STRATEGY]);
it('should return false if "Pipelines must succeed" is enabled for the current project', () => {
Vue.set(vm.mr, 'isPipelineActive', true);
Vue.set(vm.mr, 'onlyAllowMergeIfPipelineSucceeds', true);
expect(vm.shouldShowMergeOptionsDropdown).toBe(true);
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(false);
});
it('should return false when pipeline active but only merge when pipeline succeeds set in project options', () => {
Vue.set(vm.mr, 'availableAutoMergeStrategies', [ATMTWPS_MERGE_STRATEGY]);
Vue.set(vm.mr, 'onlyAllowMergeIfPipelineSucceeds', true);
it('should return true if the MR\'s pipeline is active and "Pipelines must succeed" is not enabled for the current project', () => {
Vue.set(vm.mr, 'isPipelineActive', true);
Vue.set(vm.mr, 'onlyAllowMergeIfPipelineSucceeds', false);
expect(vm.shouldShowMergeOptionsDropdown).toBe(false);
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(true);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment