Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
fcba2551
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fcba2551
编写于
3月 16, 2016
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Commit SHA comes from JSON
Removed page refresh - instead clicking takes to the builds tab
上级
b0e2e2e0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
43 deletion
+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
未找到文件。
app/assets/javascripts/lib/notify.js.coffee
浏览文件 @
fcba2551
((
w
)
->
notifyMe
=
(
message
,
body
,
icon
)
->
notifyPermissions
=
->
if
'Notification'
of
window
Notification
.
requestPermission
()
notifyMe
=
(
message
,
body
,
icon
,
onclick
)
->
notification
=
undefined
opts
=
opts
=
body
:
body
icon
:
icon
# Let's check if the browser supports notifications
...
...
@@ -10,17 +14,21 @@
else
if
Notification
.
permission
==
'granted'
# If it's okay let's create a notification
notification
=
new
Notification
(
message
,
opts
)
if
onclick
notification
.
onclick
=
onclick
else
if
Notification
.
permission
!=
'denied'
Notification
.
requestPermission
(
permission
)
->
# If the user accepts, let's create a notification
if
permission
==
'granted'
notification
=
new
Notification
(
message
,
opts
)
if
onclick
notification
.
onclick
=
onclick
return
return
w
.
notify
=
notifyMe
w
.
notifyPermissions
=
notifyPermissions
return
)
window
if
'Notification'
of
window
Notification
.
requestPermission
()
\ No newline at end of file
app/assets/javascripts/merge_request_widget.js.coffee
浏览文件 @
fcba2551
...
...
@@ -7,9 +7,10 @@ class @MergeRequestWidget
#
constructor
:
(
@
opts
)
->
@
first
=
true
@
first
CICheck
=
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
:
->
...
...
app/controllers/projects/merge_requests_controller.rb
浏览文件 @
fcba2551
...
...
@@ -221,7 +221,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
ci_status
ci_commit
=
@merge_request
.
ci_commit
if
ci_commit
status
=
ci_commit
.
try
(
:status
)
status
=
ci_commit
.
status
coverage
=
ci_commit
.
try
(
:coverage
)
else
ci_service
=
@merge_request
.
source_project
.
ci_service
...
...
@@ -233,6 +233,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
response
=
{
sha:
merge_request
.
last_commit
.
sha
,
status:
status
,
coverage:
coverage
}
...
...
app/views/projects/merge_requests/widget/_show.html.haml
浏览文件 @
fcba2551
...
...
@@ -14,17 +14,10 @@
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
}
"
,
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
'
)
{
merge_request_widget
=
new
MergeRequestWidget
(
opts
);
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录