提交 6ce5b797 编写于 作者: M mindless

[FIXED HUDSON-6832] Hide some sidepanel links that should not be shown in

user-private views.  Use it="${app}" for Manage Hudson and New Job links,
so these check the proper permission.  Replaced !it.isDefault() check
with new ViewGroup.canDelete API call.. Hudson ViewGroup uses isDefault()
for this method; MyViewsProperty checks views.size() > 1 so link is
hidden when there is only one user-private view.
Used !=false in jelly for backward compatibility (if a plugin implements
ViewGroup but does not have canDelete, null!=false will result in true).


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@32319 71c3de6d-444a-0410-be80-ed276b4c234a
上级 40ffa913
......@@ -1280,9 +1280,13 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
save();
}
public boolean canDelete(View view) {
return !view.isDefault(); // Cannot delete primary view
}
public synchronized void deleteView(View view) throws IOException {
if(views.size()<=1)
throw new IllegalStateException();
if (views.size() <= 1)
throw new IllegalStateException("Cannot delete last view");
views.remove(view);
save();
}
......
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Tom Huybrechts
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Tom Huybrechts
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -113,9 +113,13 @@ public class MyViewsProperty extends UserProperty implements ViewGroup, Action {
return null;
}
public boolean canDelete(View view) {
return views.size() > 1; // Cannot delete last view
}
public void deleteView(View view) throws IOException {
if (views.size() <= 1) {
throw new IllegalStateException();
throw new IllegalStateException("Cannot delete last view");
}
views.remove(view);
if (view.getViewName().equals(primaryViewName)) {
......@@ -194,7 +198,7 @@ public class MyViewsProperty extends UserProperty implements ViewGroup, Action {
///// Action methods /////
public String getDisplayName() {
return "My Views";
return Messages.MyViewsProperty_DisplayName();
}
public String getIconFileName() {
......@@ -210,7 +214,7 @@ public class MyViewsProperty extends UserProperty implements ViewGroup, Action {
@Override
public String getDisplayName() {
return "My Views";
return Messages.MyViewsProperty_DisplayName();
}
@Override
......
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -39,7 +39,6 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.text.ParseException;
/**
*
......@@ -125,6 +124,10 @@ public class TreeView extends View implements ViewGroup {
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
}
public boolean canDelete(View view) {
return true;
}
public void deleteView(View view) throws IOException {
views.remove(view);
}
......
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi,
* Tom Huybrechts, Alan Harder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -31,12 +32,16 @@ import java.util.Collection;
/**
* Container of {@link View}s.
*
* <h2>STILL EXPERIMENTAL: DO NOT IMPLEMENT</h2>
*
* @author Kohsuke Kawaguchi
* @since 1.269
*/
public interface ViewGroup extends Saveable, ModelObject, AccessControlled {
/**
* Determine whether a view may be deleted.
* @since 1.365
*/
boolean canDelete(View view);
/**
* Deletes a view in this group.
*/
......
......@@ -267,6 +267,7 @@ Cause.RemoteCause.ShortDescriptionWithNote=Started by remote host {0} with note:
ProxyView.NoSuchViewExists=Global view {0} does not exist
ProxyView.DisplayName=Include a global view
MyViewsProperty.DisplayName=My Views
MyViewsProperty.GlobalAction.DisplayName=My Views
MyViewsProperty.ViewExistsCheck.NotExist=A view with name {0} does not exist
MyViewsProperty.ViewExistsCheck.AlreadyExists=A view with name {0} already exists
......
......@@ -35,8 +35,8 @@ THE SOFTWARE.
</l:header>
<l:side-panel>
<l:tasks>
<l:task icon="images/24x24/new-package.gif" href="${rootURL}/${it.viewUrl}newJob" title="${%New Job}" permission="${it.itemCreatePermission}" />
<l:task icon="images/24x24/setting.gif" href="${rootURL}/manage" title="${%Manage Hudson}" permission="${app.ADMINISTER}" />
<l:task icon="images/24x24/new-package.gif" href="${rootURL}/${it.viewUrl}newJob" title="${%New Job}" permission="${it.itemCreatePermission}" it="${app}" />
<l:task icon="images/24x24/setting.gif" href="${rootURL}/manage" title="${%Manage Hudson}" permission="${app.ADMINISTER}" it="${app}" />
<j:choose>
<j:when test="${it.class.name=='hudson.model.AllView'}">
<l:task icon="images/24x24/user.gif" href="${rootURL}/people/" title="${%People}" />
......@@ -50,8 +50,7 @@ THE SOFTWARE.
<!-- /configure URL on Hudson object is overloaded with Hudson's system config, so always use the explicit name. -->
<l:task icon="images/24x24/gear.gif" href="${rootURL}/${it.viewUrl}configure" title="${%Edit View}" permission="${it.CONFIGURE}" />
</j:if>
<j:if test="${!it.isDefault()}">
<!-- this is ugly, but Hudson delegates the rendering of its pages to its primary view -->
<j:if test="${it.owner.canDelete(it)!=false}"><!-- !=false for backward compatibility -->
<l:task icon="images/24x24/edit-delete.gif" href="delete" title="${%Delete View}" permission="${it.CONFIGURE}" />
</j:if>
<j:if test="${app.fingerprintMap.ready}">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册