提交 71997559 编写于 作者: V Vincent Latombe

Merge branch 'master' into views_include_jobs_folder

Conflicts:
	changelog.html
......@@ -56,7 +56,10 @@ Upcoming changes</a>
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=rfe>
Views can now include jobs located within folders
Views can now include jobs located within folders
<li class=rfe>
Added confirmation dialog before reloading configuration from disk.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15340">issue 15340</a>)
<li class=rfe>
Different text than “Build Now” for parameterized jobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10738">issue 10738</a>)
......
......@@ -31,6 +31,7 @@ import hudson.security.Permission;
import jenkins.model.Jenkins;
import java.util.List;
import org.kohsuke.stapler.interceptor.RequirePOST;
/**
* Extension point to add icon to <tt>http://server/hudson/manage</tt> page.
......@@ -80,6 +81,17 @@ public abstract class ManagementLink implements ExtensionPoint, Action {
*/
public abstract String getUrlName();
/**
* Allows implementations to request that this link show a confirmation dialog, and use POST if confirmed.
* Suitable for links which perform an action rather than simply displaying a page.
* @return true if this link takes an action
* @see RequirePOST
* @since 1.512
*/
public boolean getRequiresConfirmation() {
return false;
}
/**
* All registered instances.
* @deprecated as of 1.286
......
......@@ -51,4 +51,9 @@ public class ReloadLink extends ManagementLink {
public String getUrlName() {
return "reload";
}
@Override public boolean getRequiresConfirmation() {
return true;
}
}
......@@ -3015,6 +3015,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
* Reloads the configuration.
*/
@CLIMethod(name="reload-configuration")
@RequirePOST
public synchronized HttpResponse doReload() throws IOException {
checkPermission(ADMINISTER);
......
......@@ -106,6 +106,17 @@ public interface ModelObjectWithContextMenu extends ModelObject {
return this;
}
/** @since 1.512 */
public ContextMenu add(String url, String icon, String text, boolean post, boolean requiresConfirmation) {
if (text != null && icon != null && url != null) {
MenuItem item = new MenuItem(url,icon,text);
item.post = post;
item.requiresConfirmation = requiresConfirmation;
items.add(item);
}
return this;
}
/**
* Default implementation of the context menu generation.
*
......@@ -184,6 +195,12 @@ public interface ModelObjectWithContextMenu extends ModelObject {
*/
@Exported public boolean post;
/**
* True to require confirmation after a click.
* @since 1.512
*/
@Exported public boolean requiresConfirmation;
/**
* If this is a submenu, definition of subitems.
*/
......
......@@ -32,10 +32,21 @@ THE SOFTWARE.
<!-- table to show a map -->
<d:tag name="feature">
<j:set var="iconUrl" value="${icon.startsWith('/') ? resURL+icon : imagesURL+'/48x48/'+icon}"/>
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.add(href,iconUrl,title) : null}
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.add(href,iconUrl,title,requiresConfirmation,requiresConfirmation) : null}
<!-- XXX summary.jelly should be modified to accept requiresConfirmation so the icon link can be included -->
<j:set var="_href" value="${href}"/>
<t:summary icon="${icon}"
href="${href}" iconOnly="true">
<div class="link"><a href="${href}">${title}</a></div>
href="${requiresConfirmation ? null : href}" iconOnly="true">
<div class="link">
<j:choose>
<j:when test="${requiresConfirmation}">
<l:confirmationLink href="${_href}" post="true" message="${%are.you.sure(title)}">${title}</l:confirmationLink>
</j:when>
<j:otherwise>
<a href="${_href}">${title}</a>
</j:otherwise>
</j:choose>
</div>
<div style="color:gray; text-decoration:none;">
<d:invokeBody />
</div>
......@@ -74,7 +85,7 @@ THE SOFTWARE.
<j:forEach var="m" items="${it.managementLinks}">
<l:hasPermission permission="${m.requiredPermission}">
<j:if test="${m.iconFileName!=null}">
<local:feature icon="${m.iconFileName}" href="${m.urlName}" title="${m.displayName}">
<local:feature icon="${m.iconFileName}" href="${m.urlName}" title="${m.displayName}" requiresConfirmation="${m.requiresConfirmation}">
<j:out value="${m.description}"/>
<st:include it="${m}" page="info.jelly" optional="true"/>
</local:feature>
......
# The MIT License
#
# Copyright 2013 Jesse Glick.
#
# 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.
are.you.sure={0}: are you sure?
......@@ -53,6 +53,16 @@ var breadcrumbs = (function() {
}
}
function requireConfirmation(action, event, cfg) {
if (confirm(cfg.displayName + ': are you sure?')) { // XXX I18N
var form = document.createElement('form');
form.setAttribute('method', cfg.post ? 'POST' : 'GET');
form.setAttribute('action', cfg.url);
document.body.appendChild(form);
form.submit();
}
}
/**
* Wraps a delayed action and its cancellation.
*/
......@@ -158,7 +168,10 @@ var breadcrumbs = (function() {
e.text = makeMenuHtml(e.icon, e.displayName);
if (e.subMenu!=null)
e.subMenu = {id:"submenu"+(iota++), itemdata:e.subMenu.items.each(fillMenuItem)};
if (e.post) {
if (e.requiresConfirmation) {
e.onclick = {fn: requireConfirmation, obj: {url: e.url, displayName: e.displayName, post: e.post}};
delete e.url;
} else if (e.post) {
e.onclick = {fn: postRequest, obj: e.url};
delete e.url;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright 2013 Jesse Glick.
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.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<st:documentation>
Produces a hyperlink which when clicked first asks for confirmation, then goes to that URL if confirmed.
The body is displayed as the link text.
@since 1.512
<st:attribute name="href" use="required">
The URL to go to.
</st:attribute>
<st:attribute name="post">
Use POST rather than GET (recommended).
</st:attribute>
<st:attribute name="message" use="required">
A confirmation dialog message.
</st:attribute>
</st:documentation>
<j:set var="id" value="${h.generateId()}"/>
<form method="${post ? 'POST' : 'GET'}" action="${attrs.href}" name="${id}"/>
<a href="#" onclick="confirmPOST('${id}', '${message}')"><d:invokeBody/></a>
<script>
function confirmPOST(id, message) {
if (confirm(message)) {
document[id].submit();
}
return false;
}
</script>
</j:jelly>
......@@ -23,7 +23,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout">
<st:documentation>
This tag inside &lt;l:tasks> tag renders the left navigation bar of Hudson.
Each &lt;task> tag gets an icon and link.
......@@ -61,6 +61,12 @@ THE SOFTWARE.
(onclick supersedes this except in the context menu.)
(since 1.504)
</st:attribute>
<st:attribute name="requiresConfirmation" type="boolean">
If true, require confirmation before clicking.
Generally used with post="true".
(onclick supersedes this except in the context menu.)
(since 1.512)
</st:attribute>
</st:documentation>
<!--
......@@ -103,9 +109,9 @@ THE SOFTWARE.
<j:otherwise>
<div class="task">
<j:set var="icon" value="${rootURL}${icon.startsWith('images/') || icon.startsWith('plugin/') ? h.resourcePath : ''}/${icon}"/>
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.add(href, icon, title, post == 'true') : null}
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.add(href, icon, title, post == 'true', requiresConfirmation == 'true') : null}
<j:if test="${attrs.onclick == null &amp;&amp; post}">
<j:if test="${attrs.onclick == null and post and not requiresConfirmation}">
<script>
function postRequest(a) {
new Ajax.Request(a.href);
......@@ -115,21 +121,46 @@ THE SOFTWARE.
</script>
</j:if>
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest(this)' : null)}">
<img width="24" height="24" style="margin: 2px;" alt="" src="${icon}"/>
</a>
<j:choose>
<j:when test="${requiresConfirmation and not attrs.onClick}">
<l:confirmationLink href="${href}" post="${post}">
<img width="24" height="24" style="margin: 2px;" alt="" src="${icon}"/>
</l:confirmationLink>
</j:when>
<j:otherwise>
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest(this)' : null)}">
<img width="24" height="24" style="margin: 2px;" alt="" src="${icon}"/>
</a>
</j:otherwise>
</j:choose>
<st:nbsp />
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest(this)' : null)}">
<j:choose>
<j:when test="${match}">
<b>${title}</b>
</j:when>
<j:otherwise>
${title}
</j:otherwise>
</j:choose>
</a>
<j:choose>
<j:when test="${requiresConfirmation and not attrs.onClick}">
<l:confirmationLink href="${href}" post="${post}">
<j:choose>
<j:when test="${match}">
<b>${title}</b>
</j:when>
<j:otherwise>
${title}
</j:otherwise>
</j:choose>
</l:confirmationLink>
</j:when>
<j:otherwise>
<a href="${href}" onclick="${attrs.onclick ?: (post ? 'postRequest(this)' : null)}">
<j:choose>
<j:when test="${match}">
<b>${title}</b>
</j:when>
<j:otherwise>
${title}
</j:otherwise>
</j:choose>
</a>
</j:otherwise>
</j:choose>
<j:if test="${match}">
<div class="subtasks">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册