Commit c6691259 authored by Stan Hu's avatar Stan Hu

Refresh widget after canceling "Merge When Pipeline Succeeds"

Previously when a user clicked on "Cancel automatic merge", the merge
request widget store would fail with `currentUser is undefined` because
the `cancel_auto_merge` endpoint did not return user information.

Even after handling that problem, the merge request widget did not
refresh until waiting for a while. We fix this by forcing a refresh
after the cancellation is processed.

Closes https://gitlab.com/gitlab-org/gitlab/issues/197487
parent 69991f26
......@@ -53,6 +53,7 @@ export default {
.then(res => res.data)
.then(data => {
eventHub.$emit('UpdateWidgetData', data);
eventHub.$emit('MRWidgetUpdateRequested');
})
.catch(() => {
this.isCancellingAutoMerge = false;
......
......@@ -123,13 +123,15 @@ export default class MergeRequestStore {
const currentUser = data.current_user;
this.cherryPickInForkPath = currentUser.cherry_pick_in_fork_path;
this.revertInForkPath = currentUser.revert_in_fork_path;
this.canRemoveSourceBranch = currentUser.can_remove_source_branch || false;
this.canCreateIssue = currentUser.can_create_issue || false;
this.canCherryPickInCurrentMR = currentUser.can_cherry_pick_on_current_merge_request || false;
this.canRevertInCurrentMR = currentUser.can_revert_on_current_merge_request || false;
if (currentUser) {
this.cherryPickInForkPath = currentUser.cherry_pick_in_fork_path;
this.revertInForkPath = currentUser.revert_in_fork_path;
this.canRemoveSourceBranch = currentUser.can_remove_source_branch || false;
this.canCreateIssue = currentUser.can_create_issue || false;
this.canCherryPickInCurrentMR = currentUser.can_cherry_pick_on_current_merge_request || false;
this.canRevertInCurrentMR = currentUser.can_revert_on_current_merge_request || false;
}
this.setState(data);
}
......
---
title: Refresh widget after canceling "Merge When Pipeline Succeeds"
merge_request: 26232
author:
type: fixed
......@@ -64,6 +64,10 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
before do
click_button "Merge when pipeline succeeds"
click_link "Cancel automatic merge"
wait_for_requests
expect(page).to have_content 'Merge when pipeline succeeds', wait: 0
end
it_behaves_like 'Merge when pipeline succeeds activator'
......
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