Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
d53aea6b
Commit
d53aea6b
authored
Jan 15, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed merge request status badge not updating after merging
parent
5c51cbca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
11 deletions
+59
-11
app/assets/javascripts/merge_request.js
app/assets/javascripts/merge_request.js
+4
-4
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_ready_to_merge.js
...uest_widget/components/states/mr_widget_ready_to_merge.js
+4
-5
changelogs/unreleased/mr-status-box-update.yml
changelogs/unreleased/mr-status-box-update.yml
+5
-0
spec/javascripts/merge_request_spec.js
spec/javascripts/merge_request_spec.js
+1
-2
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
...widget/components/states/mr_widget_ready_to_merge_spec.js
+45
-0
No files found.
app/assets/javascripts/merge_request.js
View file @
d53aea6b
...
...
@@ -110,7 +110,7 @@ MergeRequest.prototype.initCommitMessageListeners = function() {
});
};
MergeRequest
.
prototype
.
updateStatusText
=
function
(
classToRemove
,
classToAdd
,
newStatusText
)
{
MergeRequest
.
updateStatusText
=
function
(
classToRemove
,
classToAdd
,
newStatusText
)
{
$
(
'
.detail-page-header .status-box
'
)
.
removeClass
(
classToRemove
)
.
addClass
(
classToAdd
)
...
...
@@ -118,14 +118,14 @@ MergeRequest.prototype.updateStatusText = function(classToRemove, classToAdd, ne
.
text
(
newStatusText
);
};
MergeRequest
.
prototype
.
decreaseCounter
=
function
(
by
=
1
)
{
const
$el
=
$
(
'
.
nav-links .
js-merge-counter
'
);
MergeRequest
.
decreaseCounter
=
function
(
by
=
1
)
{
const
$el
=
$
(
'
.js-merge-counter
'
);
const
count
=
Math
.
max
((
parseInt
(
$el
.
text
().
replace
(
/
[^\d]
/
,
''
),
10
)
-
by
),
0
);
$el
.
text
(
addDelimiter
(
count
));
};
MergeRequest
.
prototype
.
hideCloseButton
=
function
()
{
MergeRequest
.
hideCloseButton
=
function
()
{
const
el
=
document
.
querySelector
(
'
.merge-request .js-issuable-actions
'
);
const
closeDropdownItem
=
el
.
querySelector
(
'
li.close-item
'
);
if
(
closeDropdownItem
)
{
...
...
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_ready_to_merge.js
View file @
d53aea6b
import
successSvg
from
'
icons/_icon_status_success.svg
'
;
import
warningSvg
from
'
icons/_icon_status_warning.svg
'
;
import
simplePoll
from
'
~/lib/utils/simple_poll
'
;
import
MergeRequest
from
'
../../../merge_request
'
;
import
Flash
from
'
../../../flash
'
;
import
statusIcon
from
'
../mr_widget_status_icon
'
;
import
eventHub
from
'
../../event_hub
'
;
...
...
@@ -165,11 +166,9 @@ export default {
// If state is merged we should update the widget and stop the polling
eventHub
.
$emit
(
'
MRWidgetUpdateRequested
'
);
eventHub
.
$emit
(
'
FetchActionsContent
'
);
if
(
window
.
mergeRequest
)
{
window
.
mergeRequest
.
updateStatusText
(
'
status-box-open
'
,
'
status-box-merged
'
,
'
Merged
'
);
window
.
mergeRequest
.
hideCloseButton
();
window
.
mergeRequest
.
decreaseCounter
();
}
MergeRequest
.
updateStatusText
(
'
status-box-open
'
,
'
status-box-merged
'
,
'
Merged
'
);
MergeRequest
.
hideCloseButton
();
MergeRequest
.
decreaseCounter
();
stopPolling
();
// If user checked remove source branch and we didn't remove the branch yet
...
...
changelogs/unreleased/mr-status-box-update.yml
0 → 100644
View file @
d53aea6b
---
title
:
Fixed merge request status badge not updating after merging
merge_request
:
author
:
type
:
fixed
spec/javascripts/merge_request_spec.js
View file @
d53aea6b
...
...
@@ -70,8 +70,7 @@ import IssuablesHelper from '~/helpers/issuables_helper';
beforeEach
(()
=>
{
loadFixtures
(
'
merge_requests/merge_request_with_task_list.html.raw
'
);
this
.
el
=
document
.
querySelector
(
'
.js-issuable-actions
'
);
const
merge
=
new
MergeRequest
();
merge
.
hideCloseButton
();
MergeRequest
.
hideCloseButton
();
});
it
(
'
hides the dropdown close item and selects the next item
'
,
()
=>
{
...
...
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
View file @
d53aea6b
...
...
@@ -371,6 +371,10 @@ describe('MRWidgetReadyToMerge', () => {
});
});
beforeEach
(()
=>
{
loadFixtures
(
'
merge_requests/merge_request_of_current_user.html.raw
'
);
});
it
(
'
should call start and stop polling when MR merged
'
,
(
done
)
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
vm
.
service
,
'
poll
'
).
and
.
returnValue
(
returnPromise
(
'
merged
'
));
...
...
@@ -392,6 +396,47 @@ describe('MRWidgetReadyToMerge', () => {
},
333
);
});
it
(
'
updates status box
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
poll
'
).
and
.
returnValue
(
returnPromise
(
'
merged
'
));
spyOn
(
vm
,
'
initiateRemoveSourceBranchPolling
'
);
vm
.
handleMergePolling
(()
=>
{},
()
=>
{});
setTimeout
(()
=>
{
const
statusBox
=
document
.
querySelector
(
'
.status-box
'
);
expect
(
statusBox
.
classList
.
contains
(
'
status-box-merged
'
)).
toBeTruthy
();
expect
(
statusBox
.
textContent
).
toContain
(
'
Merged
'
);
done
();
});
});
it
(
'
hides close button
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
poll
'
).
and
.
returnValue
(
returnPromise
(
'
merged
'
));
spyOn
(
vm
,
'
initiateRemoveSourceBranchPolling
'
);
vm
.
handleMergePolling
(()
=>
{},
()
=>
{});
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.btn-close
'
).
classList
.
contains
(
'
hidden
'
)).
toBeTruthy
();
done
();
});
});
it
(
'
updates merge request count badge
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
poll
'
).
and
.
returnValue
(
returnPromise
(
'
merged
'
));
spyOn
(
vm
,
'
initiateRemoveSourceBranchPolling
'
);
vm
.
handleMergePolling
(()
=>
{},
()
=>
{});
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.js-merge-counter
'
).
textContent
).
toBe
(
'
0
'
);
done
();
});
});
it
(
'
should continue polling until MR is merged
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
poll
'
).
and
.
returnValue
(
returnPromise
(
'
some_other_state
'
));
spyOn
(
vm
,
'
initiateRemoveSourceBranchPolling
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment