diff options
author | Phil Hughes <me@iamphill.com> | 2016-03-16 17:31:35 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-03-18 13:26:48 +0300 |
commit | fcba25515321f57e36b9a8f2156d6b72eafb4c14 (patch) | |
tree | 8b482660cdba07ea007e835fbf9d553647ddfbe5 /app/assets/javascripts/merge_request_widget.js.coffee | |
parent | b0e2e2e06ed38d8a23e8f834d389baa18a7a885e (diff) |
Commit SHA comes from JSON
Removed page refresh - instead clicking takes to the builds tab
Diffstat (limited to 'app/assets/javascripts/merge_request_widget.js.coffee')
-rw-r--r-- | app/assets/javascripts/merge_request_widget.js.coffee | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/app/assets/javascripts/merge_request_widget.js.coffee b/app/assets/javascripts/merge_request_widget.js.coffee index 168de57288b..9afb6a0ce86 100644 --- a/app/assets/javascripts/merge_request_widget.js.coffee +++ b/app/assets/javascripts/merge_request_widget.js.coffee @@ -7,9 +7,10 @@ class @MergeRequestWidget # constructor: (@opts) -> - @first = true + @firstCICheck = true modal = $('#modal_merge_info').modal(show: false) - @getBuildStatus() + @getCIStatus() + notifyPermissions() @readyForCICheck = true # clear the build poller @@ -39,31 +40,34 @@ class @MergeRequestWidget else status - getBuildStatus: -> - urlToCiCheck = @opts.url_to_ci_check - _this = @ - @fetchBuildStatusInterval = setInterval (-> - if not _this.readyForCICheck - return; - $.getJSON urlToCiCheck, (data) -> - _this.readyForCICheck = true - if _this.first - _this.first = false - _this.opts.current_status = data.status - if data.status isnt _this.opts.current_status - notify("Build #{_this.ciLabelForStatus(data.status)}", - _this.opts.ci_message.replace('{{status}}', - _this.ciLabelForStatus(data.status)), - _this.opts.gitlab_icon) - setTimeout (-> - Turbolinks.visit(location.href) - return - ), 2000 - _this.opts.current_status = data.status - return - _this.readyForCICheck = false - return + getCIStatus: -> + urlToCICheck = @opts.url_to_ci_check + @fetchBuildStatusInterval = setInterval ( => + return if not @readyForCICheck + $.getJSON urlToCICheck, (data) => + @readyForCICheck = true + + if @firstCICheck + @firstCICheck = false + @opts.current_status = data.status + + if data.status isnt @opts.current_status + message = @opts.ci_message.replace('{{status}}', @ciLabelForStatus(data.status)) + message = message.replace('{{sha}}', data.sha) + + notify( + "Build #{_this.ciLabelForStatus(data.status)}", + message, + @opts.gitlab_icon, + -> + @close() + Turbolinks.visit "#{window.location.pathname}/builds" + ) + + @opts.current_status = data.status + + @readyForCICheck = false ), 5000 getCiStatus: -> |