Skip to content
Snippets Groups Projects
Unverified Commit 8e5db1fc authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett
Browse files

Removed inline JS

made attribute key changes to tests

Attempting to fix mountain of failures
parent 84113d7e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -51,6 +51,7 @@ class Dispatcher
new ZenMode()
new GLForm($('.release-form'))
when 'projects:merge_requests:show'
merge_request_widget = new MergeRequestWidget()
new Diff()
shortcut_handler = new ShortcutsIssuable(true)
new ZenMode()
Loading
Loading
class @MergeRequestWidget
# Initialize MergeRequestWidget behavior
#
# check_enable - Boolean, whether to check automerge status
# merge_check_url - String, URL to use to check automerge status
# checkEnable - Boolean, whether to check automerge status
# mergeCheckUrl - String, URL to use to check automerge status
# ci_status_url - String, URL to use to check CI status
#
 
constructor: (@opts) ->
constructor: (opts) ->
$('#modal_merge_info').modal(show: false)
@firstCICheck = true
@readyForCICheck = false
@cancel = false
clearInterval @fetchBuildStatusInterval
 
@opts = opts || $('.merge-request-widget-options').data()
console.log @opts
@getMergeStatus() if @opts.getMergeStatus
@clearEventListeners()
@addEventListeners()
@getCIStatus(false)
Loading
Loading
@@ -38,7 +43,7 @@ class @MergeRequestWidget
$.ajax
type: 'GET'
url: $('.merge-request').data('url')
success: (data) =>
success: (data) ->
if data.state == "merged"
urlSuffix = if deleteSourceBranch then '?delete_source=true' else ''
 
Loading
Loading
@@ -46,12 +51,12 @@ class @MergeRequestWidget
else if data.merge_error
$('.mr-widget-body').html("<h4>" + data.merge_error + "</h4>")
else
callback = -> merge_request_widget.mergeInProgress(deleteSourceBranch)
callback = => @mergeInProgress(deleteSourceBranch)
setTimeout(callback, 2000)
dataType: 'json'
 
getMergeStatus: ->
$.get @opts.merge_check_url, (data) ->
$.get @opts.mergeCheckUrl, (data) ->
$('.mr-state-widget').replaceWith(data)
 
ciLabelForStatus: (status) ->
Loading
Loading
@@ -73,15 +78,15 @@ class @MergeRequestWidget
_this = @
$('.ci-widget-fetching').show()
 
$.getJSON @opts.ci_status_url, (data) =>
$.getJSON @opts.ciStatusUrl, (data) =>
return if @cancel
@readyForCICheck = true
 
if data.status is ''
return
 
if @firstCICheck || data.status isnt @opts.ci_status and data.status?
@opts.ci_status = data.status
if @firstCICheck || data.status isnt @opts.ciStatus and data.status?
@opts.ciStatus = data.status
@showCIStatus data.status
if data.coverage
@showCICoverage data.coverage
Loading
Loading
@@ -92,12 +97,12 @@ class @MergeRequestWidget
status = @ciLabelForStatus(data.status)
 
if status is "preparing"
title = @opts.ci_title.preparing
title = @opts.ciTitle.preparing
status = status.charAt(0).toUpperCase() + status.slice(1);
message = @opts.ci_message.preparing.replace('{{status}}', status)
message = @opts.ciMessage.preparing.replace('{{status}}', status)
else
title = @opts.ci_title.normal
message = @opts.ci_message.normal.replace('{{status}}', status)
title = @opts.ciTitle.normal
message = @opts.ciMessage.normal.replace('{{status}}', status)
 
title = title.replace('{{status}}', status)
message = message.replace('{{sha}}', data.sha)
Loading
Loading
@@ -106,10 +111,10 @@ class @MergeRequestWidget
notify(
title,
message,
@opts.gitlab_icon,
@opts.gitlabIcon,
->
@close()
Turbolinks.visit _this.opts.builds_path
Turbolinks.visit _this.opts.buildsPath
)
@firstCICheck = false
 
Loading
Loading
Loading
Loading
@@ -7,29 +7,13 @@
- elsif @merge_request.locked?
= render 'projects/merge_requests/widget/locked'
 
:javascript
var opts = {
merge_check_url: "#{merge_check_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}",
check_enable: #{@merge_request.unchecked? ? "true" : "false"},
ci_status_url: "#{ci_status_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}",
gitlab_icon: "#{asset_path 'gitlab_logo.png'}",
ci_status: "#{@merge_request.pipeline ? @merge_request.pipeline.status : ''}",
ci_message: {
normal: "Build {{status}} for \"{{title}}\"",
preparing: "{{status}} build for \"{{title}}\""
},
ci_enable: #{@project.ci_service ? "true" : "false"},
ci_title: {
preparing: "{{status}} build",
normal: "Build {{status}}"
},
builds_path: "#{builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}"
};
if (typeof merge_request_widget !== 'undefined') {
clearInterval(merge_request_widget.fetchBuildStatusInterval);
merge_request_widget.cancelPolling();
merge_request_widget.clearEventListeners();
}
merge_request_widget = new MergeRequestWidget(opts);
.merge-request-widget-options{ data: { :merge_check_url => merge_check_namespace_project_merge_request_path(@project.namespace, @project, @merge_request),
:check_enable => (@merge_request.unchecked? ? true : false),
:ci_status_url => ci_status_namespace_project_merge_request_path(@project.namespace, @project, @merge_request),
:gitlab_icon => asset_path('gitlab_logo.png'),
:ci_status => (@merge_request.pipeline ? @merge_request.pipeline.status : ''),
:ci_message => { :normal => 'Build {{status}} for "{{title}}"', :preparing => '{{status}} build for "{{title}}"' },
:ci_enable => (@project.ci_service ? true : false),
:ci_title => { :preparing => '{{status}} build', :normal => 'Build {{status}}' },
:builds_path => builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request),
:get_merge_status => (@merge_request.open? && @merge_request.unchecked?).to_s } }
%strong
= icon("spinner spin")
Checking ability to merge automatically&hellip;
:javascript
$(function() {
merge_request_widget.getMergeStatus();
});
Loading
Loading
@@ -3,24 +3,25 @@
describe 'MergeRequestWidget', ->
 
beforeEach ->
window.notifyPermissions = () ->
window.notify = () ->
@opts = {
ci_status_url:"http://sampledomain.local/ci/getstatus",
ci_status:"",
ci_message: {
normal: "Build {{status}} for \"{{title}}\"",
preparing: "{{status}} build for \"{{title}}\""
},
ci_title: {
preparing: "{{status}} build",
normal: "Build {{status}}"
},
gitlab_icon:"gitlab_logo.png",
builds_path:"http://sampledomain.local/sampleBuildsPath"
}
@class = new MergeRequestWidget(@opts)
@ciStatusData = {"title":"Sample MR title","sha":"12a34bc5","status":"success","coverage":98}
window.notifyPermissions = ->
window.notify = ->
@opts =
ciStatusUrl: 'http://sampledomain.local/ci/getstatus'
ciStatus:''
ciMessage:
normal: 'Build {{status}} for "{{title}}"'
preparing: '{{status}} build for "{{title}}"'
ciTitle:
preparing: '{{status}} build'
normal: 'Build {{status}}'
gitlabIcon:'gitlab_logo.png'
buildsPath:'http://sampledomain.local/sampleBuildsPath'
@class = new MergeRequestWidget @opts
@ciStatusData =
title:'Sample MR title'
sha:'12a34bc5'
status:'success'
coverage:98
 
describe 'getCIStatus', ->
beforeEach ->
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment