Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8eec0924
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 搜索 >>
提交
8eec0924
编写于
9月 05, 2017
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sets callout dissmiss cookie per project using a path
上级
89e5bc5e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
6 deletion
+41
-6
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+4
-4
app/assets/javascripts/user_callout.js
app/assets/javascripts/user_callout.js
+10
-2
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-0
lib/gitlab/gon_helper.rb
lib/gitlab/gon_helper.rb
+4
-0
spec/javascripts/user_callout_spec.js
spec/javascripts/user_callout_spec.js
+22
-0
未找到文件。
app/assets/javascripts/dispatcher.js
浏览文件 @
8eec0924
...
...
@@ -156,7 +156,7 @@ import initChangesDropdown from './init_changes_dropdown';
new
UsersSelect
();
break
;
case
'
projects:merge_requests:index
'
:
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
break
;
case
'
projects:merge_requests:index
'
:
case
'
projects:issues:index
'
:
...
...
@@ -346,7 +346,7 @@ import initChangesDropdown from './init_changes_dropdown';
case
'
projects:show
'
:
shortcut_handler
=
new
ShortcutsNavigation
();
new
NotificationsForm
();
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
if
(
$
(
'
#tree-slider
'
).
length
)
new
TreeView
();
if
(
$
(
'
.blob-viewer
'
).
length
)
new
BlobViewer
();
...
...
@@ -367,7 +367,7 @@ import initChangesDropdown from './init_changes_dropdown';
new
NewBranchForm
(
$
(
'
.js-new-pipeline-form
'
));
break
;
case
'
projects:pipelines:index
'
:
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
break
;
case
'
projects:pipelines:builds
'
:
case
'
projects:pipelines:failures
'
:
...
...
@@ -426,7 +426,7 @@ import initChangesDropdown from './init_changes_dropdown';
new
TreeView
();
new
BlobViewer
();
new
NewCommitForm
(
$
(
'
.js-create-dir-form
'
));
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
$
(
'
#tree-slider
'
).
waitForImages
(
function
()
{
gl
.
utils
.
ajaxGet
(
document
.
querySelector
(
'
.js-tree-content
'
).
dataset
.
logsPath
);
});
...
...
app/assets/javascripts/user_callout.js
浏览文件 @
8eec0924
import
Cookies
from
'
js-cookie
'
;
export
default
class
UserCallout
{
constructor
(
className
=
'
user-callout
'
)
{
constructor
(
options
=
{})
{
this
.
options
=
options
;
const
className
=
this
.
options
.
className
||
'
user-callout
'
;
this
.
userCalloutBody
=
$
(
`.
${
className
}
`
);
this
.
cookieName
=
this
.
userCalloutBody
.
data
(
'
uid
'
);
this
.
isCalloutDismissed
=
Cookies
.
get
(
this
.
cookieName
);
...
...
@@ -17,7 +21,11 @@ export default class UserCallout {
dismissCallout
(
e
)
{
const
$currentTarget
=
$
(
e
.
currentTarget
);
Cookies
.
set
(
this
.
cookieName
,
'
true
'
,
{
expires
:
365
});
if
(
this
.
options
.
setCalloutPerProject
)
{
Cookies
.
set
(
this
.
cookieName
,
'
true
'
,
{
expires
:
365
,
path
:
gon
.
project_url
});
}
else
{
Cookies
.
set
(
this
.
cookieName
,
'
true
'
,
{
expires
:
365
});
}
if
(
$currentTarget
.
hasClass
(
'
close
'
))
{
this
.
userCalloutBody
.
remove
();
...
...
app/controllers/projects/application_controller.rb
浏览文件 @
8eec0924
...
...
@@ -5,6 +5,7 @@ class Projects::ApplicationController < ApplicationController
before_action
:redirect_git_extension
before_action
:project
before_action
:repository
before_action
:add_gon_project_variables
layout
'project'
helper_method
:repository
,
:can_collaborate_with_project?
...
...
lib/gitlab/gon_helper.rb
浏览文件 @
8eec0924
...
...
@@ -28,5 +28,9 @@ module Gitlab
gon
.
current_user_avatar_url
=
current_user
.
avatar_url
end
end
def
add_gon_project_variables
gon
.
project_url
=
project_url
(
project
)
end
end
end
spec/javascripts/user_callout_spec.js
浏览文件 @
8eec0924
...
...
@@ -33,4 +33,26 @@ describe('UserCallout', function () {
this
.
userCalloutBtn
.
click
();
expect
(
Cookies
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
describe
(
'
Sets cookie with setCalloutPerProject
'
,
()
=>
{
let
originalGon
;
beforeEach
(()
=>
{
originalGon
=
window
.
gon
;
window
.
gon
=
Object
.
assign
({},
{
project_url
:
'
http://localhost:3000/gitlab-org/gitlab-ce
'
,
});
this
.
userCallout
=
new
UserCallout
({
setCalloutPerProject
:
true
});
});
afterEach
(()
=>
{
window
.
gon
=
originalGon
;
});
it
(
'
sets a cookie when the user clicks the close button
'
,
()
=>
{
this
.
userCalloutBtn
.
click
();
// Note the path of a cookie is not accessible via JS, we can not test for that
// We can test if a cookie is set when an option is provided
expect
(
Cookies
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录