Commit 688ed72c authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/341916/mrBlockingMergeRequestsMergeButton' into 'master'

Disable merge button if dependencies are still open

See merge request gitlab-org/gitlab!81795
parents 89d8dd1a 236c554d
......@@ -295,13 +295,6 @@ export default {
return enableSquashBeforeMerge;
},
shouldShowMergeControls() {
if (this.glFeatures.restructuredMrWidget) {
return this.restructuredWidgetShowMergeButtons;
}
return this.isMergeAllowed || this.isAutoMergeAvailable;
},
shouldShowSquashEdit() {
return this.squashBeforeMerge && this.shouldShowSquashBeforeMerge;
},
......
......@@ -22,6 +22,13 @@ export default {
this.mr.preventMerge,
);
},
shouldShowMergeControls() {
if (this.glFeatures.restructuredMrWidget) {
return this.restructuredWidgetShowMergeButtons;
}
return this.isMergeAllowed || this.isAutoMergeAvailable;
},
mergeDisabledText() {
if (this.pipeline?.status === PIPELINE_SKIPPED_STATUS) {
return MERGE_DISABLED_SKIPPED_PIPELINE_TEXT;
......
......@@ -31,6 +31,17 @@ export default {
this.mr.preventMerge,
);
},
shouldShowMergeControls() {
if (this.glFeatures.restructuredMrWidget) {
return this.restructuredWidgetShowMergeButtons;
}
if (this.mr.blockingMergeRequests?.total_count > 0) {
return false;
}
return this.isMergeAllowed || this.isAutoMergeAvailable;
},
mergeDisabledText() {
if (this.isApprovalNeeded) {
return MERGE_DISABLED_TEXT_UNAPPROVED;
......
......@@ -373,6 +373,28 @@ describe('ReadyToMerge', () => {
expect(button.exists()).toBe(true);
expect(button.attributes('disabled')).toBe('true');
});
it.each`
disabled | disabledText | totalCount
${'true'} | ${'disable'} | ${1}
${undefined} | ${'enable'} | ${0}
`(
'should $disabledText merge button blockingMergeRequests.total_count is $totalCount',
({ disabled, totalCount }) => {
factory({
isMergeAllowed: true,
availableAutoMergeStrategies: [],
blockingMergeRequests: {
total_count: totalCount,
},
});
const button = findMergeButton();
expect(button.exists()).toBe(true);
expect(button.attributes('disabled')).toBe(disabled);
},
);
});
});
......
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