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
fcba2551
Commit
fcba2551
authored
Mar 16, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit SHA comes from JSON
Removed page refresh - instead clicking takes to the builds tab
parent
b0e2e2e0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
43 deletions
+49
-43
app/assets/javascripts/lib/notify.js.coffee
app/assets/javascripts/lib/notify.js.coffee
+13
-5
app/assets/javascripts/merge_request_widget.js.coffee
app/assets/javascripts/merge_request_widget.js.coffee
+30
-26
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+2
-1
app/views/projects/merge_requests/widget/_show.html.haml
app/views/projects/merge_requests/widget/_show.html.haml
+4
-11
No files found.
app/assets/javascripts/lib/notify.js.coffee
View file @
fcba2551
((
w
)
->
((
w
)
->
notifyMe
=
(
message
,
body
,
icon
)
->
notifyPermissions
=
->
if
'Notification'
of
window
Notification
.
requestPermission
()
notifyMe
=
(
message
,
body
,
icon
,
onclick
)
->
notification
=
undefined
notification
=
undefined
opts
=
opts
=
body
:
body
body
:
body
icon
:
icon
icon
:
icon
# Let's check if the browser supports notifications
# Let's check if the browser supports notifications
...
@@ -10,17 +14,21 @@
...
@@ -10,17 +14,21 @@
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
)
notification
=
new
Notification
(
message
,
opts
)
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
)
notification
=
new
Notification
(
message
,
opts
)
if
onclick
notification
.
onclick
=
onclick
return
return
return
return
w
.
notify
=
notifyMe
w
.
notify
=
notifyMe
w
.
notifyPermissions
=
notifyPermissions
return
return
)
window
)
window
if
'Notification'
of
window
Notification
.
requestPermission
()
\ No newline at end of file
app/assets/javascripts/merge_request_widget.js.coffee
View file @
fcba2551
...
@@ -7,9 +7,10 @@ class @MergeRequestWidget
...
@@ -7,9 +7,10 @@ class @MergeRequestWidget
#
#
constructor
:
(
@
opts
)
->
constructor
:
(
@
opts
)
->
@
first
=
true
@
first
CICheck
=
true
modal
=
$
(
'#modal_merge_info'
).
modal
(
show
:
false
)
modal
=
$
(
'#modal_merge_info'
).
modal
(
show
:
false
)
@
getBuildStatus
()
@
getCIStatus
()
notifyPermissions
()
@
readyForCICheck
=
true
@
readyForCICheck
=
true
# clear the build poller
# clear the build poller
...
@@ -39,31 +40,34 @@ class @MergeRequestWidget
...
@@ -39,31 +40,34 @@ class @MergeRequestWidget
else
else
status
status
getBuildStatus
:
->
getCIStatus
:
->
urlToCiCheck
=
@
opts
.
url_to_ci_check
urlToCICheck
=
@
opts
.
url_to_ci_check
_this
=
@
@
fetchBuildStatusInterval
=
setInterval
(
=>
@
fetchBuildStatusInterval
=
setInterval
(
->
return
if
not
@
readyForCICheck
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
$
.
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
),
5000
getCiStatus
:
->
getCiStatus
:
->
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
fcba2551
...
@@ -221,7 +221,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -221,7 +221,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
ci_status
def
ci_status
ci_commit
=
@merge_request
.
ci_commit
ci_commit
=
@merge_request
.
ci_commit
if
ci_commit
if
ci_commit
status
=
ci_commit
.
try
(
:status
)
status
=
ci_commit
.
status
coverage
=
ci_commit
.
try
(
:coverage
)
coverage
=
ci_commit
.
try
(
:coverage
)
else
else
ci_service
=
@merge_request
.
source_project
.
ci_service
ci_service
=
@merge_request
.
source_project
.
ci_service
...
@@ -233,6 +233,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -233,6 +233,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
response
=
{
response
=
{
sha:
merge_request
.
last_commit
.
sha
,
status:
status
,
status:
status
,
coverage:
coverage
coverage:
coverage
}
}
...
...
app/views/projects/merge_requests/widget/_show.html.haml
View file @
fcba2551
...
@@ -14,17 +14,10 @@
...
@@ -14,17 +14,10 @@
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
)
}
"
,
url_to_ci_check
:
"
#{
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
:
""
current_status
:
""
,
ci_message
:
"
Build {{status}} for {{sha}}
"
};
};
-
if
@merge_request
.
ci_commit
:javascript
opts
.
ci_message
=
"
Build {{status}} for
#{
@merge_request
.
ci_commit
.
sha
}
"
;
-
else
:javascript
opts
.
ci_message
=
"
Build {{status}} for
#{
@merge_request
.
last_commit
.
sha
}
"
;
:javascript
if
(
typeof
merge_request_widget
===
'
undefined
'
)
{
if
(
typeof
merge_request_widget
===
'
undefined
'
)
{
merge_request_widget
=
new
MergeRequestWidget
(
opts
);
merge_request_widget
=
new
MergeRequestWidget
(
opts
);
}
}
\ No newline at end of file
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