Commit d1ba0986 authored by Stan Hu's avatar Stan Hu Committed by Yorick Peterse

Merge branch 'fix-build-notification-on-merge-page-change' into 'master'

Fix build notification on merge request page change even if the build status didn't change

## What does this MR do?
This MR contains a bugfix for #17357 which was introduced by !3998. The notification are now only shown on status changes, and not when switching between different merge requests.

## Are there points in the code the reviewer needs to double check?
Check implementation

## Why was this MR needed?
Because auf a bug introduced in !3998.

## What are the relevant issue numbers?
#17357

Closes #17357

See merge request !4086
parent afcc33b7
...@@ -42,6 +42,9 @@ v 8.7.4 ...@@ -42,6 +42,9 @@ v 8.7.4
- Fix links on wiki pages for relative url setups. !4026 (Artem Sidorenko) - Fix links on wiki pages for relative url setups. !4026 (Artem Sidorenko)
- Links for Redmine issue references are generated correctly again (Benedikt Huss) - Links for Redmine issue references are generated correctly again (Benedikt Huss)
v 8.7.4
- Fix always showing build notification message when switching between merge requests
v 8.7.3 v 8.7.3
- Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented - Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented
- Merge request widget displays TeamCity build state and code coverage correctly again. - Merge request widget displays TeamCity build state and code coverage correctly again.
......
...@@ -9,11 +9,12 @@ class @MergeRequestWidget ...@@ -9,11 +9,12 @@ class @MergeRequestWidget
constructor: (@opts) -> constructor: (@opts) ->
$('#modal_merge_info').modal(show: false) $('#modal_merge_info').modal(show: false)
@firstCICheck = true @firstCICheck = true
@readyForCICheck = true @readyForCICheck = false
clearInterval @fetchBuildStatusInterval clearInterval @fetchBuildStatusInterval
@clearEventListeners() @clearEventListeners()
@addEventListeners() @addEventListeners()
@getCIStatus(false)
@pollCIStatus() @pollCIStatus()
notifyPermissions() notifyPermissions()
...@@ -71,7 +72,7 @@ class @MergeRequestWidget ...@@ -71,7 +72,7 @@ class @MergeRequestWidget
if data.status is '' if data.status is ''
return return
if @firstCiCheck || data.status isnt @opts.ci_status and data.status? if @firstCICheck || data.status isnt @opts.ci_status and data.status?
@opts.ci_status = data.status @opts.ci_status = data.status
@showCIStatus data.status @showCIStatus data.status
if data.coverage if data.coverage
...@@ -79,7 +80,7 @@ class @MergeRequestWidget ...@@ -79,7 +80,7 @@ class @MergeRequestWidget
# The first check should only update the UI, a notification # The first check should only update the UI, a notification
# should only be displayed on status changes # should only be displayed on status changes
if showNotification and not @firstCiCheck if showNotification and not @firstCICheck
status = @ciLabelForStatus(data.status) status = @ciLabelForStatus(data.status)
if status is "preparing" if status is "preparing"
...@@ -102,7 +103,7 @@ class @MergeRequestWidget ...@@ -102,7 +103,7 @@ class @MergeRequestWidget
@close() @close()
Turbolinks.visit _this.opts.builds_path Turbolinks.visit _this.opts.builds_path
) )
@firstCiCheck = false @firstCICheck = false
showCIStatus: (state) -> showCIStatus: (state) ->
$('.ci_widget').hide() $('.ci_widget').hide()
......
...@@ -42,8 +42,3 @@ ...@@ -42,8 +42,3 @@
.ci_widget.ci-error{style: "display:none"} .ci_widget.ci-error{style: "display:none"}
= icon("times-circle") = icon("times-circle")
Could not connect to the CI server. Please check your settings and try again. Could not connect to the CI server. Please check your settings and try again.
:javascript
$(function() {
merge_request_widget.getCIStatus(false);
});
...@@ -47,3 +47,9 @@ describe 'MergeRequestWidget', -> ...@@ -47,3 +47,9 @@ describe 'MergeRequestWidget', ->
spy = spyOn(@class, 'showCICoverage').and.stub() spy = spyOn(@class, 'showCICoverage').and.stub()
@class.getCIStatus(false) @class.getCIStatus(false)
expect(spy).not.toHaveBeenCalled() expect(spy).not.toHaveBeenCalled()
it 'should not display a notification on the first check after the widget has been created', ->
spy = spyOn(window, 'notify')
@class = new MergeRequestWidget(@opts)
@class.getCIStatus(true)
expect(spy).not.toHaveBeenCalled()
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