Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
1242889f
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1242889f
编写于
10月 15, 2017
作者:
T
tinexw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-6290] Add New View link to sidebar
上级
27e59430
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
102 addition
and
0 deletion
+102
-0
core/src/main/java/jenkins/model/NewViewLink.java
core/src/main/java/jenkins/model/NewViewLink.java
+52
-0
core/src/main/resources/jenkins/model/Messages.properties
core/src/main/resources/jenkins/model/Messages.properties
+2
-0
core/src/main/resources/jenkins/model/Messages_de.properties
core/src/main/resources/jenkins/model/Messages_de.properties
+2
-0
core/src/test/java/jenkins/model/NewViewLinkTest.java
core/src/test/java/jenkins/model/NewViewLinkTest.java
+46
-0
未找到文件。
core/src/main/java/jenkins/model/NewViewLink.java
0 → 100644
浏览文件 @
1242889f
package
jenkins.model
;
import
com.google.common.annotations.VisibleForTesting
;
import
hudson.Extension
;
import
hudson.model.Action
;
import
hudson.model.TransientViewActionFactory
;
import
hudson.model.View
;
import
java.util.Collections
;
import
java.util.List
;
@Extension
public
class
NewViewLink
extends
TransientViewActionFactory
{
@VisibleForTesting
static
final
String
ICON_FILE_NAME
=
"folder"
;
@VisibleForTesting
public
static
final
String
URL_NAME
=
"newView"
;
@Override
public
List
<
Action
>
createFor
(
View
v
)
{
return
Collections
.
singletonList
(
new
Action
()
{
@Override
public
String
getIconFileName
()
{
if
(!
hasPermission
(
v
))
{
return
null
;
}
return
ICON_FILE_NAME
;
}
@Override
public
String
getDisplayName
()
{
if
(!
hasPermission
(
v
))
{
return
null
;
}
return
Messages
.
NewViewLink_NewView
();
}
@Override
public
String
getUrlName
()
{
return
URL_NAME
;
}
private
boolean
hasPermission
(
View
view
)
{
return
view
.
hasPermission
(
View
.
CREATE
);
}
});
}
}
core/src/main/resources/jenkins/model/Messages.properties
浏览文件 @
1242889f
...
...
@@ -58,6 +58,8 @@ IdStrategy.CaseSensitiveEmailAddress.DisplayName=Case sensitive (email address)
Mailer.Address.Not.Configured
=
address not configured yet <nobody@nowhere>
Mailer.Localhost.Error
=
Please set a valid host name, instead of localhost
NewViewLink.NewView
=
New View
PatternProjectNamingStrategy.DisplayName
=
Pattern
PatternProjectNamingStrategy.NamePatternRequired
=
Name Pattern is required
PatternProjectNamingStrategy.NamePatternInvalidSyntax
=
regular expression's syntax is invalid.
...
...
core/src/main/resources/jenkins/model/Messages_de.properties
浏览文件 @
1242889f
...
...
@@ -49,6 +49,8 @@ DefaultProjectNamingStrategy.DisplayName=keine Einschr\u00E4nkung
Mailer.Address.Not.Configured
=
Adresse nicht konfiguriert <nobody@nowhere>
Mailer.Localhost.Error
=
Bitte verwenden Sie einen konkreten Hostnamen anstelle von <tt>localhost</tt>.
NewViewLink.NewView
=
Ansicht anlegen
PatternProjectNamingStrategy.DisplayName
=
Muster
PatternProjectNamingStrategy.NamePatternRequired
=
Der Regul
\u
00E4re Ausdruck darf nicht leer sein.
PatternProjectNamingStrategy.NamePatternInvalidSyntax
=
Der Regul
\u
00E4re Ausdruck ist ung
\u
00FCltig.
...
...
core/src/test/java/jenkins/model/NewViewLinkTest.java
0 → 100644
浏览文件 @
1242889f
package
jenkins.model
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
hudson.model.Action
;
import
hudson.model.View
;
import
java.util.List
;
import
org.junit.Test
;
public
class
NewViewLinkTest
{
private
NewViewLink
newViewLink
=
new
NewViewLink
();
private
View
view
=
mock
(
View
.
class
);
@Test
public
void
getActionsHasPermission
()
throws
Exception
{
when
(
view
.
hasPermission
(
any
())).
thenReturn
(
true
);
final
List
<
Action
>
actions
=
newViewLink
.
createFor
(
view
);
assertEquals
(
1
,
actions
.
size
());
final
Action
action
=
actions
.
get
(
0
);
assertEquals
(
Messages
.
NewViewLink_NewView
(),
action
.
getDisplayName
());
assertEquals
(
NewViewLink
.
ICON_FILE_NAME
,
action
.
getIconFileName
());
assertEquals
(
NewViewLink
.
URL_NAME
,
action
.
getUrlName
());
}
@Test
public
void
getActionsNoPermission
()
throws
Exception
{
when
(
view
.
hasPermission
(
any
())).
thenReturn
(
false
);
final
List
<
Action
>
actions
=
newViewLink
.
createFor
(
view
);
assertEquals
(
1
,
actions
.
size
());
final
Action
action
=
actions
.
get
(
0
);
assertNull
(
action
.
getDisplayName
());
assertNull
(
action
.
getIconFileName
());
assertEquals
(
NewViewLink
.
URL_NAME
,
action
.
getUrlName
());
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录