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
iv
gitlab-ce
Commits
3d6573fd
Commit
3d6573fd
authored
Mar 18, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to fix issues risen during feedback
Correctly updates the on-screen CI text feedback
parent
33aeaf6a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
67 deletions
+53
-67
app/assets/javascripts/lib/notify.js.coffee
app/assets/javascripts/lib/notify.js.coffee
+8
-12
app/assets/javascripts/merge_request_widget.js.coffee
app/assets/javascripts/merge_request_widget.js.coffee
+19
-17
app/views/projects/merge_requests/widget/_heading.html.haml
app/views/projects/merge_requests/widget/_heading.html.haml
+21
-34
app/views/projects/merge_requests/widget/_show.html.haml
app/views/projects/merge_requests/widget/_show.html.haml
+5
-4
No files found.
app/assets/javascripts/lib/notify.js.coffee
View file @
3d6573fd
((
w
)
->
((
w
)
->
notificationGranted
=
(
message
,
opts
,
onclick
)
->
notification
=
new
Notification
(
message
,
opts
)
if
onclick
notification
.
onclick
=
onclick
notifyPermissions
=
->
notifyPermissions
=
->
if
'Notification'
of
window
if
'Notification'
of
window
Notification
.
requestPermission
()
Notification
.
requestPermission
()
notifyMe
=
(
message
,
body
,
icon
,
onclick
)
->
notifyMe
=
(
message
,
body
,
icon
,
onclick
)
->
notification
=
undefined
opts
=
opts
=
body
:
body
body
:
body
icon
:
icon
icon
:
icon
...
@@ -13,22 +18,13 @@
...
@@ -13,22 +18,13 @@
# do nothing
# do nothing
else
if
Notification
.
permission
==
'granted'
else
if
Notification
.
permission
==
'granted'
# If it's okay let's create a notification
# If it's okay let's create a notification
notification
=
new
Notification
(
message
,
opts
)
notificationGranted
message
,
opts
,
onclick
if
onclick
notification
.
onclick
=
onclick
else
if
Notification
.
permission
!=
'denied'
else
if
Notification
.
permission
!=
'denied'
Notification
.
requestPermission
(
permission
)
->
Notification
.
requestPermission
(
permission
)
->
# If the user accepts, let's create a notification
# If the user accepts, let's create a notification
if
permission
==
'granted'
if
permission
==
'granted'
notification
=
new
Notification
(
message
,
opts
)
notificationGranted
message
,
opts
,
onclick
if
onclick
notification
.
onclick
=
onclick
return
return
w
.
notify
=
notifyMe
w
.
notify
=
notifyMe
w
.
notifyPermissions
=
notifyPermissions
w
.
notifyPermissions
=
notifyPermissions
return
)
window
)
window
app/assets/javascripts/merge_request_widget.js.coffee
View file @
3d6573fd
...
@@ -2,8 +2,8 @@ class @MergeRequestWidget
...
@@ -2,8 +2,8 @@ class @MergeRequestWidget
# Initialize MergeRequestWidget behavior
# Initialize MergeRequestWidget behavior
#
#
# check_enable - Boolean, whether to check automerge status
# check_enable - Boolean, whether to check automerge status
#
url_to_automerge_check
- String, URL to use to check automerge status
#
merge_check_url
- String, URL to use to check automerge status
#
url_to_ci_check
- String, URL to use to check CI status
#
ci_status_url
- String, URL to use to check CI status
#
#
constructor
:
(
@
opts
)
->
constructor
:
(
@
opts
)
->
...
@@ -31,7 +31,7 @@ class @MergeRequestWidget
...
@@ -31,7 +31,7 @@ class @MergeRequestWidget
dataType
:
'json'
dataType
:
'json'
getMergeStatus
:
->
getMergeStatus
:
->
$
.
get
@
opts
.
url_to_automerge_check
,
(
data
)
->
$
.
get
@
opts
.
merge_check_url
,
(
data
)
->
$
(
'.mr-state-widget'
).
replaceWith
(
data
)
$
(
'.mr-state-widget'
).
replaceWith
(
data
)
ciLabelForStatus
:
(
status
)
->
ciLabelForStatus
:
(
status
)
->
...
@@ -41,26 +41,28 @@ class @MergeRequestWidget
...
@@ -41,26 +41,28 @@ class @MergeRequestWidget
status
status
getCIStatus
:
->
getCIStatus
:
->
urlToCICheck
=
@
opts
.
url_to_ci_check
_this
=
@
_this
=
@
@
fetchBuildStatusInterval
=
setInterval
(
=>
@
fetchBuildStatusInterval
=
setInterval
(
=>
return
if
not
@
readyForCICheck
return
if
not
@
readyForCICheck
$
.
getJSON
urlToCICheck
,
(
data
)
=>
$
.
getJSON
@
opts
.
ci_status_url
,
(
data
)
=>
@
readyForCICheck
=
true
@
readyForCICheck
=
true
if
@
firstCICheck
if
@
firstCICheck
@
firstCICheck
=
false
@
firstCICheck
=
false
@
opts
.
current_status
=
data
.
status
@
opts
.
ci_status
=
data
.
status
if
data
.
status
isnt
@
opts
.
ci_status
@
showCIState
data
.
status
if
data
.
coverage
@
showCICoverage
data
.
coverage
if
data
.
status
isnt
@
opts
.
current_status
message
=
@
opts
.
ci_message
.
replace
(
'{{status}}'
,
@
ciLabelForStatus
(
data
.
status
))
message
=
@
opts
.
ci_message
.
replace
(
'{{status}}'
,
@
ciLabelForStatus
(
data
.
status
))
message
=
message
.
replace
(
'{{sha}}'
,
data
.
sha
)
message
=
message
.
replace
(
'{{sha}}'
,
data
.
sha
)
message
=
message
.
replace
(
'{{title}}'
,
data
.
title
)
message
=
message
.
replace
(
'{{title}}'
,
data
.
title
)
notify
(
notify
(
"Build
#{
_this
.
ciLabelForStatus
(
data
.
status
)
}
"
,
"Build
#{
@
ciLabelForStatus
(
data
.
status
)
}
"
,
message
,
message
,
@
opts
.
gitlab_icon
,
@
opts
.
gitlab_icon
,
->
->
...
@@ -68,19 +70,19 @@ class @MergeRequestWidget
...
@@ -68,19 +70,19 @@ class @MergeRequestWidget
Turbolinks
.
visit
_this
.
opts
.
builds_path
Turbolinks
.
visit
_this
.
opts
.
builds_path
)
)
@
opts
.
c
urrent
_status
=
data
.
status
@
opts
.
c
i
_status
=
data
.
status
@
readyForCICheck
=
false
@
readyForCICheck
=
false
),
5000
),
5000
getCiStatus
:
->
getCIState
:
->
$
.
get
@
opts
.
url_to_ci_check
,
(
data
)
=>
$
(
'.ci-widget-fetching'
).
show
()
this
.
showCiState
data
.
status
$
.
getJSON
@
opts
.
ci_status_url
,
(
data
)
=>
@
showCIState
data
.
status
if
data
.
coverage
if
data
.
coverage
this
.
showCiCoverage
data
.
coverage
@
showCICoverage
data
.
coverage
,
'json'
showC
i
State
:
(
state
)
->
showC
I
State
:
(
state
)
->
$
(
'.ci_widget'
).
hide
()
$
(
'.ci_widget'
).
hide
()
allowed_states
=
[
"failed"
,
"canceled"
,
"running"
,
"pending"
,
"success"
,
"skipped"
,
"not_found"
]
allowed_states
=
[
"failed"
,
"canceled"
,
"running"
,
"pending"
,
"success"
,
"skipped"
,
"not_found"
]
if
state
in
allowed_states
if
state
in
allowed_states
...
@@ -94,7 +96,7 @@ class @MergeRequestWidget
...
@@ -94,7 +96,7 @@ class @MergeRequestWidget
$
(
'.ci_widget.ci-error'
).
show
()
$
(
'.ci_widget.ci-error'
).
show
()
@
setMergeButtonClass
(
'btn-danger'
)
@
setMergeButtonClass
(
'btn-danger'
)
showC
i
Coverage
:
(
coverage
)
->
showC
I
Coverage
:
(
coverage
)
->
text
=
'Coverage '
+
coverage
+
'%'
text
=
'Coverage '
+
coverage
+
'%'
$
(
'.ci_widget:visible .ci-coverage'
).
text
(
text
)
$
(
'.ci_widget:visible .ci-coverage'
).
text
(
text
)
...
...
app/views/projects/merge_requests/widget/_heading.html.haml
View file @
3d6573fd
-
if
@ci_commit
-
if
@ci_commit
or
@merge_request
.
has_ci?
.mr-widget-heading
.ci_widget
{
class:
"ci-#{@ci_commit.status}"
}
=
ci_status_icon
(
@ci_commit
)
%span
Build
%span
.ci-status-label
=
ci_status_label
(
@ci_commit
)
for
=
succeed
"."
do
=
link_to
@ci_commit
.
short_sha
,
namespace_project_commit_path
(
@merge_request
.
source_project
.
namespace
,
@merge_request
.
source_project
,
@ci_commit
.
sha
),
class:
"monospace"
%span
.ci-coverage
=
link_to
"View details"
,
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
"js-show-tab"
,
data:
{
action:
'builds'
}
-
elsif
@merge_request
.
has_ci?
-
# Compatibility with old CI integrations (ex jenkins) when you request status from CI server via AJAX
-
# Remove in later versions when services like Jenkins will set CI status via Commit status API
.mr-widget-heading
.mr-widget-heading
-
if
@merge_request
.
has_ci?
.ci_widget.ci-widget-fetching
=
icon
(
'spinner spin'
)
%span
Checking CI status for
#{
@merge_request
.
last_commit_short_sha
}
…
-
%w[success skipped canceled failed running pending]
.
each
do
|
status
|
-
%w[success skipped canceled failed running pending]
.
each
do
|
status
|
.ci_widget
{
class:
"ci-#{status}"
,
style:
"display:none"
}
.ci_widget
{
class:
"ci-#{status}"
,
style:
(
"display:none"
unless
status
==
@ci_commit
.
status
)
}
=
ci_icon_for_status
(
status
)
=
ci_icon_for_status
(
status
)
%span
%span
CI build
CI build
...
@@ -27,22 +16,20 @@
...
@@ -27,22 +16,20 @@
=
succeed
"."
do
=
succeed
"."
do
=
link_to
commit
.
short_id
,
namespace_project_commit_path
(
@merge_request
.
source_project
.
namespace
,
@merge_request
.
source_project
,
commit
),
class:
"monospace"
=
link_to
commit
.
short_id
,
namespace_project_commit_path
(
@merge_request
.
source_project
.
namespace
,
@merge_request
.
source_project
,
commit
),
class:
"monospace"
%span
.ci-coverage
%span
.ci-coverage
-
if
details_path
=
ci_build_details_path
(
@merge_request
)
-
if
details_path
=
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
=
link_to
"View details"
,
details_path
,
:"data-no-turbolink"
=>
"data-no-turbolink"
=
link_to
"View details"
,
details_path
,
:"data-no-turbolink"
=>
"data-no-turbolink"
-
if
@merge_request
.
has_ci?
-
# Compatibility with old CI integrations (ex jenkins) when you request status from CI server via AJAX
-
# Remove in later versions when services like Jenkins will set CI status via Commit status API
.ci_widget.ci-not_found
{
style:
"display:none"
}
=
icon
(
"times-circle"
)
Could not find CI status for
#{
@merge_request
.
last_commit_short_sha
}
.
.ci_widget
.ci_widget.ci-error
{
style:
"display:none"
}
=
icon
(
"spinner spin"
)
=
icon
(
"times-circle"
)
Checking CI status for
#{
@merge_request
.
last_commit_short_sha
}
…
Could not connect to the CI server. Please check your settings and try again.
.ci_widget.ci-not_found
{
style:
"display:none"
}
=
icon
(
"times-circle"
)
Could not find CI status for
#{
@merge_request
.
last_commit_short_sha
}
.
.ci_widget.ci-error
{
style:
"display:none"
}
=
icon
(
"times-circle"
)
Could not connect to the CI server. Please check your settings and try again.
:javascript
:javascript
$
(
function
()
{
$
(
function
()
{
merge_request_widget
.
getCiStatus
();
merge_request_widget
.
getCIState
();
});
});
app/views/projects/merge_requests/widget/_show.html.haml
View file @
3d6573fd
...
@@ -10,12 +10,13 @@
...
@@ -10,12 +10,13 @@
:javascript
:javascript
var
merge_request_widget
;
var
merge_request_widget
;
var
opts
=
{
var
opts
=
{
url_to_automerge_check
:
"
#{
merge_check_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
merge_check_url
:
"
#{
merge_check_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
ci_status_url
:
"
#{
ci_status_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
gitlab_icon
:
"
#{
asset_path
'gitlab_logo.png'
}
"
,
gitlab_icon
:
"
#{
asset_path
'gitlab_logo.png'
}
"
,
current_status
:
""
,
ci_status
:
""
,
ci_message
:
"
Build {{status}} for {{title}}
\n
{{sha}}
"
,
ci_message
:
"
Build {{status}} for
\"
{{title}}
\"
"
,
ci_enable
:
#{
@project
.
ci_service
?
"true"
:
"false"
}
,
builds_path
:
"
#{
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
builds_path
:
"
#{
builds_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
};
};
...
...
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