Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b172ef2f
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 搜索 >>
未验证
提交
b172ef2f
编写于
5月 26, 2017
作者:
L
Luke "Jared" Bennett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restore notifications to MR widget
上级
8f2af757
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
53 addition
and
43 deletion
+53
-43
app/assets/javascripts/lib/utils/notify.js
app/assets/javascripts/lib/utils/notify.js
+37
-42
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
app/assets/javascripts/vue_merge_request_widget/dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+1
-0
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+12
-0
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
...cripts/vue_merge_request_widget/stores/mr_widget_store.js
+2
-0
lib/gitlab/gon_helper.rb
lib/gitlab/gon_helper.rb
+1
-0
未找到文件。
app/assets/javascripts/lib/utils/notify.js
浏览文件 @
b172ef2f
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, consistent-return, prefer-arrow-callback, no-return-assign, object-shorthand, comma-dangle, no-param-reassign, max-len */
(
function
()
{
(
function
(
w
)
{
var
notificationGranted
,
notifyMe
,
notifyPermissions
;
notificationGranted
=
function
(
message
,
opts
,
onclick
)
{
var
notification
;
notification
=
new
Notification
(
message
,
opts
);
setTimeout
(
function
()
{
return
notification
.
close
();
// Hide the notification after X amount of seconds
},
8000
);
if
(
onclick
)
{
return
notification
.
onclick
=
onclick
;
}
};
notifyPermissions
=
function
()
{
if
(
'
Notification
'
in
window
)
{
return
Notification
.
requestPermission
();
}
};
notifyMe
=
function
(
message
,
body
,
icon
,
onclick
)
{
var
opts
;
opts
=
{
body
:
body
,
icon
:
icon
};
// Let's check if the browser supports notifications
if
(
!
(
'
Notification
'
in
window
))
{
function
notificationGranted
(
message
,
opts
,
onclick
)
{
var
notification
;
notification
=
new
Notification
(
message
,
opts
);
setTimeout
(
function
()
{
// Hide the notification after X amount of seconds
return
notification
.
close
();
},
8000
);
return
notification
.
onclick
=
onclick
||
notification
.
close
;
}
// do nothing
}
else
if
(
Notification
.
permission
===
'
granted
'
)
{
// If it's okay let's create a notification
function
notifyPermissions
()
{
if
(
'
Notification
'
in
window
)
{
return
Notification
.
requestPermission
();
}
}
function
notifyMe
(
message
,
body
,
icon
,
onclick
)
{
var
opts
;
opts
=
{
body
:
body
,
icon
:
icon
};
// Let's check if the browser supports notifications
if
(
!
(
'
Notification
'
in
window
))
{
// do nothing
}
else
if
(
Notification
.
permission
===
'
granted
'
)
{
// If it's okay let's create a notification
return
notificationGranted
(
message
,
opts
,
onclick
);
}
else
if
(
Notification
.
permission
!==
'
denied
'
)
{
return
Notification
.
requestPermission
(
function
(
permission
)
{
// If the user accepts, let's create a notification
if
(
permission
===
'
granted
'
)
{
return
notificationGranted
(
message
,
opts
,
onclick
);
}
else
if
(
Notification
.
permission
!==
'
denied
'
)
{
return
Notification
.
requestPermission
(
function
(
permission
)
{
// If the user accepts, let's create a notification
if
(
permission
===
'
granted
'
)
{
return
notificationGranted
(
message
,
opts
,
onclick
);
}
});
}
};
w
.
notify
=
notifyMe
;
return
w
.
notifyPermissions
=
notifyPermissions
;
})(
window
);
}).
call
(
window
)
;
}
)
;
}
}
export
{
notifyMe
as
default
,
notifyPermissions
,
notificationGranted
}
;
app/assets/javascripts/main.js
浏览文件 @
b172ef2f
...
...
@@ -56,7 +56,6 @@ import './lib/utils/animate';
import
'
./lib/utils/bootstrap_linked_tabs
'
;
import
'
./lib/utils/common_utils
'
;
import
'
./lib/utils/datetime_utility
'
;
import
'
./lib/utils/notify
'
;
import
'
./lib/utils/pretty_time
'
;
import
'
./lib/utils/text_utility
'
;
import
'
./lib/utils/url_utility
'
;
...
...
app/assets/javascripts/vue_merge_request_widget/dependencies.js
浏览文件 @
b172ef2f
...
...
@@ -41,3 +41,4 @@ export { default as getStateKey } from './stores/get_state_key';
export
{
default
as
mrWidgetOptions
}
from
'
./mr_widget_options
'
;
export
{
default
as
stateMaps
}
from
'
./stores/state_maps
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
./components/states/mr_widget_squash_before_merge
'
;
export
{
default
as
notifyMe
}
from
'
../lib/utils/notify
'
;
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
浏览文件 @
b172ef2f
...
...
@@ -29,6 +29,7 @@ import {
eventHub
,
stateMaps
,
SquashBeforeMerge
,
notifyMe
,
}
from
'
./dependencies
'
;
export
default
{
...
...
@@ -77,8 +78,10 @@ export default {
this
.
service
.
checkStatus
()
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
this
.
handleNotification
(
res
);
this
.
mr
.
setData
(
res
);
this
.
setFavicon
();
if
(
cb
)
{
cb
.
call
(
null
,
res
);
}
...
...
@@ -136,6 +139,15 @@ export default {
new
Flash
(
'
Something went wrong. Please try again.
'
);
// eslint-disable-line
});
},
handleNotification
(
data
)
{
if
(
data
.
ci_status
===
this
.
mr
.
ciStatus
)
return
;
const
label
=
data
.
pipeline
.
details
.
status
.
label
;
const
title
=
`Pipeline
${
label
}
`
;
const
message
=
`Pipeline
${
label
}
for "
${
data
.
title
}
"`
;
notifyMe
(
title
,
message
,
this
.
mr
.
gitlabLogo
);
},
resumePolling
()
{
this
.
pollingInterval
.
resume
();
},
...
...
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
浏览文件 @
b172ef2f
...
...
@@ -5,6 +5,8 @@ export default class MergeRequestStore {
constructor
(
data
)
{
this
.
sha
=
data
.
diff_head_sha
;
this
.
gitlabLogo
=
gon
.
gitlab_logo
;
this
.
setData
(
data
);
}
...
...
lib/gitlab/gon_helper.rb
浏览文件 @
b172ef2f
...
...
@@ -13,6 +13,7 @@ module Gitlab
gon
.
sentry_dsn
=
current_application_settings
.
clientside_sentry_dsn
if
current_application_settings
.
clientside_sentry_enabled
gon
.
gitlab_url
=
Gitlab
.
config
.
gitlab
.
url
gon
.
revision
=
Gitlab
::
REVISION
gon
.
gitlab_logo
=
ActionController
::
Base
.
helpers
.
asset_path
(
'gitlab_logo.png'
)
if
current_user
gon
.
current_user_id
=
current_user
.
id
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录