Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
363cc0e3
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,发现更多精彩内容 >>
提交
363cc0e3
编写于
8月 02, 2012
作者:
N
Nicolas De Loof
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'Vlatombe/user-transient-actions'
上级
7c18ba29
39572fba
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
136 addition
and
25 deletion
+136
-25
changelog.html
changelog.html
+2
-0
core/src/main/java/hudson/model/TransientUserActionFactory.java
...rc/main/java/hudson/model/TransientUserActionFactory.java
+60
-0
core/src/main/java/hudson/model/User.java
core/src/main/java/hudson/model/User.java
+40
-9
core/src/main/resources/hudson/model/User/sidepanel.jelly
core/src/main/resources/hudson/model/User/sidepanel.jelly
+4
-2
test/src/test/java/hudson/model/UserTestCase.java
test/src/test/java/hudson/model/UserTestCase.java
+30
-14
未找到文件。
changelog.html
浏览文件 @
363cc0e3
...
...
@@ -99,6 +99,8 @@ Upcoming changes</a>
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-14327"
>
issue 14327
</a>
)
<li
class=
rfe
>
Option to set java executable path for managed windows slaves
<li
class=
rfe
>
Added new extension point for transient user actions, and displays user properties if they are also Actions.
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/TransientUserActionFactory.java
0 → 100644
浏览文件 @
363cc0e3
/*
* The MIT License
*
* Copyright (c) 2012, Vincent Latombe.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson.model
;
import
hudson.Extension
;
import
hudson.ExtensionList
;
import
hudson.ExtensionPoint
;
import
jenkins.model.Jenkins
;
import
java.util.Collection
;
import
java.util.Collections
;
/**
* Extension point for inserting transient {@link Action}s into {@link User}s.
*
* To register your implementation, put {@link Extension} on your subtype.
*
* @author Vincent Latombe
* @since 1.477
* @see Action
*/
public
abstract
class
TransientUserActionFactory
implements
ExtensionPoint
{
/**
* Creates actions for the given user.
*
* @param target for which the action objects are requested. Never null.
* @return Can be empty but must not be null.
*/
public
Collection
<?
extends
Action
>
createFor
(
User
target
)
{
return
Collections
.
emptyList
();
}
/**
* Returns all the registered {@link TransientUserActionFactory}s.
*/
public
static
ExtensionList
<
TransientUserActionFactory
>
all
()
{
return
Jenkins
.
getInstance
().
getExtensionList
(
TransientUserActionFactory
.
class
);
}
}
\ No newline at end of file
core/src/main/java/hudson/model/User.java
浏览文件 @
363cc0e3
/*
* The MIT License
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, Tom Huybrechts
* Copyright (c) 2004-2012, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt,
* Tom Huybrechts, Vincent Latombe
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -101,7 +102,7 @@ import java.util.logging.Logger;
*/
@ExportedBean
public
class
User
extends
AbstractModelObject
implements
AccessControlled
,
DescriptorByNameOwner
,
Saveable
,
Comparable
<
User
>
{
private
transient
final
String
id
;
private
volatile
String
fullName
;
...
...
@@ -591,15 +592,45 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
public
Descriptor
getDescriptorByName
(
String
className
)
{
return
Jenkins
.
getInstance
().
getDescriptorByName
(
className
);
}
public
Object
getDynamic
(
String
token
)
{
for
(
UserProperty
property:
getProperties
().
values
())
{
if
(
property
instanceof
Action
)
{
Action
a
=
(
Action
)
property
;
if
(
a
.
getUrlName
().
equals
(
token
)
||
a
.
getUrlName
().
equals
(
'/'
+
token
))
return
a
;
}
for
(
Action
action:
getTransientActions
()){
if
(
action
.
getUrlName
().
equals
(
token
))
return
action
;
}
for
(
Action
action:
getPropertyActions
()){
if
(
action
.
getUrlName
().
equals
(
token
))
return
action
;
}
return
null
;
}
/**
* Return all properties that are also actions.
*
* @return the list can be empty but never null. read only.
*/
public
List
<
Action
>
getPropertyActions
()
{
List
<
Action
>
actions
=
new
ArrayList
<
Action
>();
for
(
UserProperty
userProp
:
getProperties
().
values
())
{
if
(
userProp
instanceof
Action
)
{
actions
.
add
((
Action
)
userProp
);
}
}
return
Collections
.
unmodifiableList
(
actions
);
}
/**
* Return all transient actions associated with this user.
*
* @return the list can be empty but never null. read only.
*/
public
List
<
Action
>
getTransientActions
()
{
List
<
Action
>
actions
=
new
ArrayList
<
Action
>();
for
(
TransientUserActionFactory
factory:
TransientUserActionFactory
.
all
())
{
actions
.
addAll
(
factory
.
createFor
(
this
));
}
return
Collections
.
unmodifiableList
(
actions
);
}
}
core/src/main/resources/hudson/model/User/sidepanel.jelly
浏览文件 @
363cc0e3
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts, id:cactusman
Copyright (c) 2004-2012, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts,
id:cactusman, Vincent Latombe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
...
...
@@ -35,10 +36,11 @@ THE SOFTWARE.
<l:task icon="images/24x24/notepad.png" href="${rootURL}/${it.url}/builds" title="${%Builds}" />
<l:task icon="images/24x24/notepad.png" href="${rootURL}/${it.url}/my-views/" title="${%My Views}" />
<l:task icon="images/24x24/setting.png" href="${rootURL}/${it.url}/configure" title="${%Configure}" permission="${app.ADMINISTER}" />
<t:actions actions="${it.propertyActions}"/>
<t:actions actions="${it.transientActions}"/>
<j:if test="${it.canDelete()}">
<l:task icon="images/24x24/edit-delete.png" href="${rootURL}/${it.url}/delete" title="${%Delete}" />
</j:if>
<!-- TODO add all UserProperties that are also actions -->
</l:tasks>
</l:side-panel>
</j:jelly>
test/src/test/java/hudson/model/UserTestCase.java
浏览文件 @
363cc0e3
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt
* Copyright (c) 2004-2012, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt,
* Vincent Latombe
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -29,7 +30,7 @@ import org.jvnet.hudson.test.HudsonTestCase;
public
class
UserTestCase
extends
HudsonTestCase
{
public
static
class
UserPropertyImpl
extends
UserProperty
{
public
static
class
UserPropertyImpl
extends
UserProperty
implements
Action
{
private
final
String
testString
;
private
UserPropertyDescriptor
descriptorImpl
=
new
UserPropertyDescriptorImpl
();
...
...
@@ -47,23 +48,35 @@ public class UserTestCase extends HudsonTestCase {
return
descriptorImpl
;
}
public
static
class
UserPropertyDescriptorImpl
extends
UserPropertyDescriptor
{
@Override
public
UserProperty
newInstance
(
User
user
)
{
return
null
;
}
public
String
getIconFileName
()
{
return
"/images/24x24/gear.png"
;
}
@Override
public
String
getDisplayName
()
{
return
"Property"
;
}
public
String
getDisplayName
()
{
return
"UserPropertyImpl"
;
}
public
String
getUrlName
()
{
return
"userpropertyimpl"
;
}
public
static
class
UserPropertyDescriptorImpl
extends
UserPropertyDescriptor
{
@Override
public
UserProperty
newInstance
(
User
user
)
{
return
null
;
}
@Override
public
String
getDisplayName
()
{
return
"Property"
;
}
}
}
/**
* Asserts that bug# is fixed.
*/
public
void
testUserPropertySummary
Is
ShownInUserPage
()
throws
Exception
{
public
void
testUserPropertySummary
AndActionAre
ShownInUserPage
()
throws
Exception
{
UserProperty
property
=
new
UserPropertyImpl
(
"NeedleInPage"
);
UserProperty
.
all
().
add
(
property
.
getDescriptor
());
...
...
@@ -72,9 +85,12 @@ public class UserTestCase extends HudsonTestCase {
user
.
addProperty
(
property
);
HtmlPage
page
=
new
WebClient
().
goTo
(
"user/user-test-case"
);
WebAssert
.
assertTextPresent
(
page
,
"NeedleInPage"
);
WebAssert
.
assertTextPresentInElement
(
page
,
"NeedleInPage"
,
"main-panel"
);
WebAssert
.
assertTextPresentInElement
(
page
,
((
Action
)
property
).
getDisplayName
(),
"side-panel"
);
}
/**
* Asserts that the default user avatar can be fetched (ie no 404)
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录