Commit 78f70545 authored by Sam Bigelow's avatar Sam Bigelow

Set cached MRWidget SHA after rebase

Update changelog to include Merge Request ID and Author

Update changelog to include Merge Request ID and Author
parent 07e079e8
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
Flash('Something went wrong. Please try again.'); Flash('Something went wrong. Please try again.');
} }
eventHub.$emit('MRWidgetUpdateRequested'); eventHub.$emit('MRWidgetRebaseSuccess');
stopPolling(); stopPolling();
} }
}) })
......
...@@ -155,13 +155,13 @@ export default { ...@@ -155,13 +155,13 @@ export default {
}; };
return new MRWidgetService(endpoints); return new MRWidgetService(endpoints);
}, },
checkStatus(cb) { checkStatus(cb, isRebased) {
return this.service return this.service
.checkStatus() .checkStatus()
.then(res => res.data) .then(res => res.data)
.then(data => { .then(data => {
this.handleNotification(data); this.handleNotification(data);
this.mr.setData(data); this.mr.setData(data, isRebased);
this.setFaviconHelper(); this.setFaviconHelper();
if (cb) { if (cb) {
...@@ -263,6 +263,10 @@ export default { ...@@ -263,6 +263,10 @@ export default {
this.checkStatus(cb); this.checkStatus(cb);
}); });
eventHub.$on('MRWidgetRebaseSuccess', cb => {
this.checkStatus(cb, true);
});
// `params` should be an Array contains a Boolean, like `[true]` // `params` should be an Array contains a Boolean, like `[true]`
// Passing parameter as Boolean didn't work. // Passing parameter as Boolean didn't work.
eventHub.$on('SetBranchRemoveFlag', params => { eventHub.$on('SetBranchRemoveFlag', params => {
......
...@@ -19,7 +19,7 @@ export default function deviseState(data) { ...@@ -19,7 +19,7 @@ export default function deviseState(data) {
return stateKey.unresolvedDiscussions; return stateKey.unresolvedDiscussions;
} else if (this.isPipelineBlocked) { } else if (this.isPipelineBlocked) {
return stateKey.pipelineBlocked; return stateKey.pipelineBlocked;
} else if (this.hasSHAChanged) { } else if (this.isSHAMismatch) {
return stateKey.shaMismatch; return stateKey.shaMismatch;
} else if (this.mergeWhenPipelineSucceeds) { } else if (this.mergeWhenPipelineSucceeds) {
return this.mergeError ? stateKey.autoMergeFailed : stateKey.mergeWhenPipelineSucceeds; return this.mergeError ? stateKey.autoMergeFailed : stateKey.mergeWhenPipelineSucceeds;
......
...@@ -11,7 +11,11 @@ export default class MergeRequestStore { ...@@ -11,7 +11,11 @@ export default class MergeRequestStore {
this.setData(data); this.setData(data);
} }
setData(data) { setData(data, isRebased) {
if (isRebased) {
this.sha = data.diff_head_sha;
}
const currentUser = data.current_user; const currentUser = data.current_user;
const pipelineStatus = data.pipeline ? data.pipeline.details.status : null; const pipelineStatus = data.pipeline ? data.pipeline.details.status : null;
...@@ -84,7 +88,7 @@ export default class MergeRequestStore { ...@@ -84,7 +88,7 @@ export default class MergeRequestStore {
this.canMerge = !!data.merge_path; this.canMerge = !!data.merge_path;
this.canCreateIssue = currentUser.can_create_issue || false; this.canCreateIssue = currentUser.can_create_issue || false;
this.canCancelAutomaticMerge = !!data.cancel_merge_when_pipeline_succeeds_path; this.canCancelAutomaticMerge = !!data.cancel_merge_when_pipeline_succeeds_path;
this.hasSHAChanged = this.sha !== data.diff_head_sha; this.isSHAMismatch = this.sha !== data.diff_head_sha;
this.canBeMerged = data.can_be_merged || false; this.canBeMerged = data.can_be_merged || false;
this.isMergeAllowed = data.mergeable || false; this.isMergeAllowed = data.mergeable || false;
this.mergeOngoing = data.merge_ongoing; this.mergeOngoing = data.merge_ongoing;
......
---
title: Allow merge after rebase without page refresh on FF repositories
merge_request: 23572
author:
type: fixed
...@@ -114,7 +114,7 @@ describe('Merge request widget rebase component', () => { ...@@ -114,7 +114,7 @@ describe('Merge request widget rebase component', () => {
// Wait for the eventHub to be called // Wait for the eventHub to be called
.then(vm.$nextTick()) .then(vm.$nextTick())
.then(() => { .then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('MRWidgetUpdateRequested'); expect(eventHub.$emit).toHaveBeenCalledWith('MRWidgetRebaseSuccess');
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
...@@ -35,7 +35,7 @@ describe('getStateKey', () => { ...@@ -35,7 +35,7 @@ describe('getStateKey', () => {
expect(bound()).toEqual('mergeWhenPipelineSucceeds'); expect(bound()).toEqual('mergeWhenPipelineSucceeds');
context.hasSHAChanged = true; context.isSHAMismatch = true;
expect(bound()).toEqual('shaMismatch'); expect(bound()).toEqual('shaMismatch');
......
...@@ -3,23 +3,30 @@ import { stateKey } from '~/vue_merge_request_widget/stores/state_maps'; ...@@ -3,23 +3,30 @@ import { stateKey } from '~/vue_merge_request_widget/stores/state_maps';
import mockData from '../mock_data'; import mockData from '../mock_data';
describe('MergeRequestStore', () => { describe('MergeRequestStore', () => {
describe('setData', () => { let store;
let store;
beforeEach(() => { beforeEach(() => {
store = new MergeRequestStore(mockData); store = new MergeRequestStore(mockData);
}); });
it('should set hasSHAChanged when the diff SHA changes', () => { describe('setData', () => {
it('should set isSHAMismatch when the diff SHA changes', () => {
store.setData({ ...mockData, diff_head_sha: 'a-different-string' }); store.setData({ ...mockData, diff_head_sha: 'a-different-string' });
expect(store.hasSHAChanged).toBe(true); expect(store.isSHAMismatch).toBe(true);
}); });
it('should not set hasSHAChanged when other data changes', () => { it('should not set isSHAMismatch when other data changes', () => {
store.setData({ ...mockData, work_in_progress: !mockData.work_in_progress }); store.setData({ ...mockData, work_in_progress: !mockData.work_in_progress });
expect(store.hasSHAChanged).toBe(false); expect(store.isSHAMismatch).toBe(false);
});
it('should update cached sha after rebasing', () => {
store.setData({ ...mockData, diff_head_sha: 'abc123' }, true);
expect(store.isSHAMismatch).toBe(false);
expect(store.sha).toBe('abc123');
}); });
describe('isPipelinePassing', () => { describe('isPipelinePassing', () => {
......
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