-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d3de54
commit f907a22
Showing
9 changed files
with
275 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.classpath | ||
.project | ||
.settings/ | ||
target/ | ||
work/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
buildPlugin(useContainerAgent: true, configurations: [ | ||
[ platform: "linux", jdk: "8" ], | ||
[ platform: "linux", jdk: "11" ], | ||
[ platform: 'linux', jdk: '17' ] | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Favorite view plugin | ||
============================== | ||
[![Build Status](https://ci.jenkins.io/buildStatus/icon?job=Plugins/favorite-view-plugin/master)](https://ci.jenkins.io/job/plugins/job/favorite-view-plugin/) | ||
[![Jenkins Plugin](https://img.shields.io/jenkins/plugin/v/favorite-view.svg)](https://plugins.jenkins.io/favorite-view/) | ||
[![Jenkins Plugin Installs](https://img.shields.io/jenkins/plugin/i/favorite-view.svg?color=blue)](https://plugins.jenkins.io/favorite-view/) | ||
[![Contributors](https://img.shields.io/github/contributors/jenkinsci/favorite-view-plugin.svg)](https://github.com/jenkinsci/favorite-view-plugin/graphs/contributors) | ||
|
||
An alternative implementation of the tab bar. <br/> | ||
Users can mark some views as favorites, and these will show up as tabs. Other views are listed in a dropdown. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,36 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jvnet.hudson.plugins</groupId> | ||
<artifactId>plugin</artifactId> | ||
<version>1.380</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>favorite-view</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>hpi</packaging> | ||
<name>Favorite View Plugin</name> | ||
<url>http://wiki.hudson-ci.org/display/HUDSON/Favorite+View+Plugin</url> | ||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
</build> | ||
|
||
<properties> | ||
<hudson.version>1.381-SNAPSHOT</hudson.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jvnet.hudson.main</groupId> | ||
<artifactId>hudson-war</artifactId> | ||
<type>war</type> | ||
<version>${hudson.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jvnet.hudson.main</groupId> | ||
<artifactId>hudson-core</artifactId> | ||
<version>${hudson.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jvnet.hudson.main</groupId> | ||
<artifactId>hudson-test-harness</artifactId> | ||
<version>${hudson.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jvnet.hudson.main</groupId> | ||
<artifactId>ui-samples-plugin</artifactId> | ||
<version>${hudson.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jvnet.hudson.main</groupId> | ||
<artifactId>maven-plugin</artifactId> | ||
<version>${hudson.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<repositories> | ||
<repository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>http://repo.jenkins-ci.org/public/</url> | ||
</repository> | ||
</repositories> | ||
<parent> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>plugin</artifactId> | ||
<version>4.47</version> | ||
<relativePath /> | ||
</parent> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>http://repo.jenkins-ci.org/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
<artifactId>favorite-view</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>hpi</packaging> | ||
<name>Favorite View Plugin</name> | ||
<url>https://github.com/jenkinsci/favorite-view-plugin</url> | ||
|
||
<properties> | ||
<jenkins.version>2.346.1</jenkins.version> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>https://repo.jenkins-ci.org/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>https://repo.jenkins-ci.org/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
</project> | ||
|
||
|
||
|
192 changes: 96 additions & 96 deletions
192
src/main/java/hudson/plugins/favoriteview/FavoriteViewsTabBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,96 @@ | ||
package hudson.plugins.favoriteview; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Hudson; | ||
import hudson.model.User; | ||
import hudson.model.View; | ||
import hudson.security.ACL; | ||
import hudson.security.AccessControlled; | ||
import hudson.security.Permission; | ||
import hudson.views.ViewsTabBar; | ||
import hudson.views.ViewsTabBarDescriptor; | ||
|
||
import java.io.IOException; | ||
|
||
import org.acegisecurity.AccessDeniedException; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.HttpResponse; | ||
import org.kohsuke.stapler.HttpResponses; | ||
import org.kohsuke.stapler.QueryParameter; | ||
import org.kohsuke.stapler.Stapler; | ||
|
||
public class FavoriteViewsTabBar extends ViewsTabBar implements | ||
AccessControlled { | ||
|
||
@DataBoundConstructor | ||
public FavoriteViewsTabBar() { | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends ViewsTabBarDescriptor { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Favorite Views"; | ||
} | ||
|
||
public HttpResponse doToggleFavorite( | ||
@QueryParameter("favorite") String favorite, | ||
@QueryParameter("view") String view) throws IOException { | ||
User user = User.current(); | ||
if (user == null) | ||
return HttpResponses.forbidden(); | ||
|
||
FavoriteViewsUserProperty property = user | ||
.getProperty(FavoriteViewsUserProperty.class); | ||
if (property == null) { | ||
property = new FavoriteViewsUserProperty(); | ||
user.addProperty(property); | ||
} | ||
|
||
property.setFavorite(view, "true".equals(favorite)); | ||
user.save(); | ||
|
||
return HttpResponses.forwardToPreviousPage(); | ||
} | ||
|
||
} | ||
|
||
public static View getView() { | ||
return Stapler.getCurrentRequest().findAncestorObject(View.class); | ||
} | ||
|
||
public static String getViewId(View view) { | ||
return view.getDisplayName(); | ||
} | ||
|
||
public static View getViewById(String id) { | ||
return Hudson.getInstance().getView(id); | ||
} | ||
|
||
public boolean isFavorite(View view) { | ||
User user = User.current(); | ||
if (user == null) | ||
return false; | ||
|
||
FavoriteViewsUserProperty property = user | ||
.getProperty(FavoriteViewsUserProperty.class); | ||
if (property == null) | ||
return false; | ||
|
||
String viewId = getViewId(view); | ||
return property.isFavorite(viewId); | ||
} | ||
|
||
public void checkPermission(Permission p) throws AccessDeniedException { | ||
getACL().checkPermission(p); | ||
} | ||
|
||
public ACL getACL() { | ||
return getView().getACL(); | ||
} | ||
|
||
public boolean hasPermission(Permission p) { | ||
return getACL().hasPermission(p); | ||
} | ||
} | ||
package hudson.plugins.favoriteview; | ||
|
||
import hudson.Extension; | ||
import hudson.model.User; | ||
import hudson.model.View; | ||
import hudson.security.ACL; | ||
import hudson.security.AccessControlled; | ||
import hudson.security.Permission; | ||
import hudson.views.ViewsTabBar; | ||
import hudson.views.ViewsTabBarDescriptor; | ||
|
||
import java.io.IOException; | ||
|
||
import jenkins.model.Jenkins; | ||
import org.springframework.security.access.AccessDeniedException; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.HttpResponse; | ||
import org.kohsuke.stapler.HttpResponses; | ||
import org.kohsuke.stapler.QueryParameter; | ||
import org.kohsuke.stapler.Stapler; | ||
|
||
public class FavoriteViewsTabBar extends ViewsTabBar implements | ||
AccessControlled { | ||
|
||
@DataBoundConstructor | ||
public FavoriteViewsTabBar() { | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends ViewsTabBarDescriptor { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Favorite Views"; | ||
} | ||
|
||
public HttpResponse doToggleFavorite( | ||
@QueryParameter("favorite") String favorite, | ||
@QueryParameter("view") String view) throws IOException { | ||
User user = User.current(); | ||
if (user == null) | ||
return HttpResponses.forbidden(); | ||
|
||
FavoriteViewsUserProperty property = user | ||
.getProperty(FavoriteViewsUserProperty.class); | ||
if (property == null) { | ||
property = new FavoriteViewsUserProperty(); | ||
user.addProperty(property); | ||
} | ||
|
||
property.setFavorite(view, "true".equals(favorite)); | ||
user.save(); | ||
|
||
return HttpResponses.forwardToPreviousPage(); | ||
} | ||
|
||
} | ||
|
||
public static View getView() { | ||
return Stapler.getCurrentRequest().findAncestorObject(View.class); | ||
} | ||
|
||
public static String getViewId(View view) { | ||
return view.getDisplayName(); | ||
} | ||
|
||
public static View getViewById(String id) { | ||
return Jenkins.get().getView(id); | ||
} | ||
|
||
public boolean isFavorite(View view) { | ||
User user = User.current(); | ||
if (user == null) | ||
return false; | ||
|
||
FavoriteViewsUserProperty property = user | ||
.getProperty(FavoriteViewsUserProperty.class); | ||
if (property == null) | ||
return false; | ||
|
||
String viewId = getViewId(view); | ||
return property.isFavorite(viewId); | ||
} | ||
|
||
public void checkPermission(Permission p) throws AccessDeniedException { | ||
getACL().checkPermission(p); | ||
} | ||
|
||
public ACL getACL() { | ||
return getView().getACL(); | ||
} | ||
|
||
public boolean hasPermission(Permission p) { | ||
return getACL().hasPermission(p); | ||
} | ||
} |
Oops, something went wrong.