Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
7ae71bf1
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,发现更多精彩内容 >>
提交
7ae71bf1
编写于
12月 30, 2010
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added a mechanism to filter out descriptors
上级
70fde5f7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
1 deletion
+62
-1
core/src/main/java/hudson/Functions.java
core/src/main/java/hudson/Functions.java
+5
-0
core/src/main/java/hudson/model/DescriptorVisibilityFilter.java
...rc/main/java/hudson/model/DescriptorVisibilityFilter.java
+54
-0
core/src/main/resources/lib/hudson/newFromList/form.jelly
core/src/main/resources/lib/hudson/newFromList/form.jelly
+3
-1
未找到文件。
core/src/main/java/hudson/Functions.java
浏览文件 @
7ae71bf1
...
...
@@ -30,6 +30,7 @@ import hudson.model.AbstractProject;
import
hudson.model.Action
;
import
hudson.model.Describable
;
import
hudson.model.Descriptor
;
import
hudson.model.DescriptorVisibilityFilter
;
import
hudson.model.Hudson
;
import
hudson.model.Item
;
import
hudson.model.ItemGroup
;
...
...
@@ -1273,6 +1274,10 @@ public class Functions {
if
(
o
instanceof
Secret
)
return
((
Secret
)
o
).
getEncryptedValue
();
return
o
.
toString
();
}
public
List
filterDescriptors
(
Object
context
,
Iterable
descriptors
)
{
return
DescriptorVisibilityFilter
.
apply
(
context
,
descriptors
);
}
private
static
final
Pattern
SCHEME
=
Pattern
.
compile
(
"[a-z]+://.+"
);
...
...
core/src/main/java/hudson/model/DescriptorVisibilityFilter.java
0 → 100644
浏览文件 @
7ae71bf1
package
hudson.model
;
import
hudson.ExtensionList
;
import
hudson.ExtensionPoint
;
import
hudson.scm.SCMDescriptor
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Hides {@link Descriptor}s from users.
*
* @author Kohsuke Kawaguchi
* @since 1.393
*/
public
abstract
class
DescriptorVisibilityFilter
implements
ExtensionPoint
{
/**
* Decides if the given descriptor should be visible to the user.
*
* @param context
* The object that indicates where the visibility of a descriptor is evaluated.
* For example, if Hudson is deciding whether a {@link FreeStyleProject} should gets a
* {@link SCMDescriptor}, the context object will be the {@link FreeStyleProject}.
* The caller can pass in null if there's no context.
* @param descriptor
* Descriptor whose visibility is evaluated. Never null.
*
* @return
* true to allow the descriptor to be visible. false to hide it.
* If any of the installed {@link DescriptorVisibilityFilter} returns false,
* the descriptor is not shown.
*/
public
abstract
boolean
filter
(
Object
context
,
Descriptor
descriptor
);
public
static
ExtensionList
<
DescriptorVisibilityFilter
>
all
()
{
return
Hudson
.
getInstance
().
getExtensionList
(
DescriptorVisibilityFilter
.
class
);
}
public
static
<
T
extends
Descriptor
>
List
<
T
>
apply
(
Object
context
,
Iterable
<
T
>
source
)
{
ExtensionList
<
DescriptorVisibilityFilter
>
filters
=
all
();
List
<
T
>
r
=
new
ArrayList
<
T
>();
OUTER:
for
(
T
d
:
source
)
{
for
(
DescriptorVisibilityFilter
f
:
filters
)
{
if
(!
f
.
filter
(
context
,
d
))
continue
OUTER
;
// veto-ed. not shown
}
r
.
add
(
d
);
}
return
r
;
}
}
core/src/main/resources/lib/hudson/newFromList/form.jelly
浏览文件 @
7ae71bf1
...
...
@@ -33,6 +33,8 @@ THE SOFTWARE.
@checkUrl : form field validation url
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
<j:set var="descriptors" value="${h.filterDescriptors(it,attrs.descriptors)}" />
<s:form method="post" action="createItem">
<s:entry title="${attrs.nameTitle}">
<s:textbox id="name" name="name" checkUrl="'${rootURL}/${attrs.checkUrl}?value='+encodeURIComponent(this.value)"
...
...
@@ -40,7 +42,7 @@ THE SOFTWARE.
<script>$('name').focus();</script>
</s:entry>
<j:forEach var="descriptor" items="${
attrs.
descriptors}">
<j:forEach var="descriptor" items="${descriptors}">
<s:block>
<input type="radio" name="mode" value="${descriptor.class.name}" onchange="updateOk(this.form)" onclick="updateOk(this.form)" />
<st:nbsp/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录