Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
56f25c3e
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 搜索 >>
提交
56f25c3e
编写于
12月 07, 2015
作者:
Z
Zeger-Jan van de Weg
提交者:
Stan Hu
12月 08, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve text indication visibility on snippets
上级
e6668f8e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
65 deletion
+53
-65
CHANGELOG
CHANGELOG
+1
-0
app/helpers/visibility_level_helper.rb
app/helpers/visibility_level_helper.rb
+15
-11
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+2
-2
app/views/shared/snippets/_header.html.haml
app/views/shared/snippets/_header.html.haml
+1
-1
spec/helpers/visibility_level_helper_spec.rb
spec/helpers/visibility_level_helper_spec.rb
+34
-51
未找到文件。
CHANGELOG
浏览文件 @
56f25c3e
...
...
@@ -24,6 +24,7 @@ v 8.3.0 (unreleased)
- Fix bug when simultaneously accepting multiple MRs results in MRs that are of "merged" status, but not merged to the target branch
- Add languages page to graphs
- Block LDAP user when they are no longer found in the LDAP server
- Improve wording on project visibility levels (Zeger-Jan van de Weg)
v 8.2.3
- Fix application settings cache not expiring after changes (Stan Hu)
...
...
app/helpers/visibility_level_helper.rb
浏览文件 @
56f25c3e
...
...
@@ -12,22 +12,22 @@ module VisibilityLevelHelper
# Return the description for the +level+ argument.
#
# +level+ One of the Gitlab::VisibilityLevel constants
# +form_model+ Either a model object (Project, Snippet, etc.) or the name of
# a Project or Snippet class.
# +level+
One of the Gitlab::VisibilityLevel constants
# +form_model+
Either a model object (Project, Snippet, etc.) or the name of
#
a Project or Snippet class.
def
visibility_level_description
(
level
,
form_model
)
case
form_model
.
is_a?
(
String
)
?
form_model
:
form_model
.
class
.
name
when
'PersonalSnippet'
,
'ProjectSnippet'
,
'Snippet'
snippet_visibility_level_description
(
level
)
when
'Project'
case
form_model
when
Project
project_visibility_level_description
(
level
)
when
Snippet
snippet_visibility_level_description
(
level
,
form_model
)
end
end
def
project_visibility_level_description
(
level
)
case
level
when
Gitlab
::
VisibilityLevel
::
PRIVATE
"Project access must be granted explicitly
for
each user."
"Project access must be granted explicitly
to
each user."
when
Gitlab
::
VisibilityLevel
::
INTERNAL
"The project can be cloned by any logged in user."
when
Gitlab
::
VisibilityLevel
::
PUBLIC
...
...
@@ -35,12 +35,16 @@ module VisibilityLevelHelper
end
end
def
snippet_visibility_level_description
(
level
)
def
snippet_visibility_level_description
(
level
,
snippet
=
nil
)
case
level
when
Gitlab
::
VisibilityLevel
::
PRIVATE
"The snippet is visible only for me."
if
snippet
.
is_a?
ProjectSnippet
"The snippet is visible only to project members."
else
"The snippet is visible only to me."
end
when
Gitlab
::
VisibilityLevel
::
INTERNAL
"The snippet is visible
for
any logged in user."
"The snippet is visible
to
any logged in user."
when
Gitlab
::
VisibilityLevel
::
PUBLIC
"The snippet can be accessed without any authentication."
end
...
...
app/views/admin/application_settings/_form.html.haml
浏览文件 @
56f25c3e
...
...
@@ -14,11 +14,11 @@
.form-group.project-visibility-level-holder
=
f
.
label
:default_project_visibility
,
class:
'control-label col-sm-2'
.col-sm-10
=
render
(
'shared/visibility_radios'
,
model_method: :default_project_visibility
,
form:
f
,
selected_level:
@application_setting
.
default_project_visibility
,
form_model:
'Project'
)
=
render
(
'shared/visibility_radios'
,
model_method: :default_project_visibility
,
form:
f
,
selected_level:
@application_setting
.
default_project_visibility
,
form_model:
Project
)
.form-group.project-visibility-level-holder
=
f
.
label
:default_snippet_visibility
,
class:
'control-label col-sm-2'
.col-sm-10
=
render
(
'shared/visibility_radios'
,
model_method: :default_snippet_visibility
,
form:
f
,
selected_level:
@application_setting
.
default_snippet_visibility
,
form_model:
'Snippet'
)
=
render
(
'shared/visibility_radios'
,
model_method: :default_snippet_visibility
,
form:
f
,
selected_level:
@application_setting
.
default_snippet_visibility
,
form_model:
PersonalSnippet
)
.form-group
=
f
.
label
:restricted_visibility_levels
,
class:
'control-label col-sm-2'
.col-sm-10
...
...
app/views/shared/snippets/_header.html.haml
浏览文件 @
56f25c3e
.issuable-details
.page-title
.snippet-box.has_tooltip
{
class:
visibility_level_color
(
@snippet
.
visibility_level
),
title:
snippet_visibility_level_description
(
@snippet
.
visibility_level
),
data:
{
container:
'body'
}}
.snippet-box.has_tooltip
{
class:
visibility_level_color
(
@snippet
.
visibility_level
),
title:
snippet_visibility_level_description
(
@snippet
.
visibility_level
,
@snippet
),
data:
{
container:
'body'
}}
=
visibility_level_icon
(
@snippet
.
visibility_level
,
fw:
false
)
=
visibility_level_label
(
@snippet
.
visibility_level
)
Snippet ##{@snippet.id}
...
...
spec/helpers/visibility_level_helper_spec.rb
浏览文件 @
56f25c3e
...
...
@@ -7,69 +7,52 @@ describe VisibilityLevelHelper do
init_haml_helpers
end
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
build
(
:project
)
}
let
(
:personal_snippet
)
{
build
(
:personal_snippet
)
}
let
(
:project_snippet
)
{
build
(
:project_snippet
)
}
describe
'visibility_level_description'
do
shared_examples
'a visibility level description'
do
let
(
:desc
)
do
visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PRIVATE
,
form_model
)
end
let
(
:expected_class
)
do
class_name
=
case
form_model
.
class
.
name
when
'String'
form_model
else
form_model
.
class
.
name
end
class_name
.
match
(
/(project|snippet)$/i
)[
0
]
end
it
'should refer to the correct class'
do
expect
(
desc
).
to
match
(
/
#{
expected_class
}
/i
)
context
'used with a Project'
do
it
'delegates projects to #project_visibility_level_description'
do
expect
(
visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PRIVATE
,
project
))
.
to
match
/project/i
end
end
context
'form_model argument is a String'
do
context
'model object is a personal snippet'
do
it_behaves_like
'a visibility level description'
do
let
(
:form_model
)
{
'PersonalSnippet'
}
end
context
'called with a Snippet'
do
it
'delegates snippets to #snippet_visibility_level_description'
do
expect
(
visibility_level_description
(
Gitlab
::
VisibilityLevel
::
INTERNAL
,
project_snippet
))
.
to
match
/snippet/i
end
end
end
context
'model object is a project snippet'
do
it_behaves_like
'a visibility level description'
do
let
(
:form_model
)
{
'ProjectSnippet'
}
end
end
describe
"#project_visibility_level_description"
do
it
"describes private projects"
do
expect
(
project_visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PRIVATE
))
.
to
eq
"Project access must be granted explicitly to each user."
end
context
'model object is a project'
do
it_behaves_like
'a visibility level description'
do
let
(
:form_model
)
{
'Project'
}
end
end
it
"describes public projects"
do
expect
(
project_visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PUBLIC
))
.
to
eq
"The project can be cloned without any authentication."
end
end
context
'form_model argument is a model object'
do
context
'model object is a personal snippet'
do
it_behaves_like
'a visibility level description'
do
let
(
:form_model
)
{
create
(
:personal_snippet
)
}
end
end
describe
"#snippet_visibility_level_description"
do
it
'describes visibility only for me'
do
expect
(
snippet_visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PRIVATE
,
personal_snippet
))
.
to
eq
"The snippet is visible only to me."
end
context
'model object is a project snippet'
do
it_behaves_like
'a visibility level description'
do
let
(
:form_model
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
it
'describes visibility for project members'
do
expect
(
snippet_visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PRIVATE
,
project_snippet
))
.
to
eq
"The snippet is visible only to project members."
end
context
'model object is a project'
do
it_behaves_like
'a visibility level description'
do
let
(
:form_model
)
{
project
}
end
end
it
'defaults to personal snippet'
do
expect
(
snippet_visibility_level_description
(
Gitlab
::
VisibilityLevel
::
PRIVATE
))
.
to
eq
"The snippet is visible only to me."
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录