diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2035cdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.classpath +.project +.settings/ +target/ +work/ +.idea diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2ad8a63 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,5 @@ +buildPlugin(useContainerAgent: true, configurations: [ + [ platform: "linux", jdk: "8" ], + [ platform: "linux", jdk: "11" ], + [ platform: 'linux', jdk: '17' ] +]) diff --git a/README.md b/README.md new file mode 100644 index 0000000..1a9a508 --- /dev/null +++ b/README.md @@ -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.
+Users can mark some views as favorites, and these will show up as tabs. Other views are listed in a dropdown. diff --git a/pom.xml b/pom.xml index 0cc3c4c..4b90130 100644 --- a/pom.xml +++ b/pom.xml @@ -1,74 +1,36 @@ - - 4.0.0 - - - org.jvnet.hudson.plugins - plugin - 1.380 - ../pom.xml - - - favorite-view - 1.0-SNAPSHOT - hpi - Favorite View Plugin - http://wiki.hudson-ci.org/display/HUDSON/Favorite+View+Plugin - - ${project.artifactId} - - - - 1.381-SNAPSHOT - - - - - org.jvnet.hudson.main - hudson-war - war - ${hudson.version} - test - - - org.jvnet.hudson.main - hudson-core - ${hudson.version} - provided - - - org.jvnet.hudson.main - hudson-test-harness - ${hudson.version} - test - - - org.jvnet.hudson.main - ui-samples-plugin - ${hudson.version} - test - - - org.jvnet.hudson.main - maven-plugin - ${hudson.version} - test - - - + + 4.0.0 - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - + + org.jenkins-ci.plugins + plugin + 4.47 + + - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - + favorite-view + 1.0-SNAPSHOT + hpi + Favorite View Plugin + https://github.com/jenkinsci/favorite-view-plugin + + + 2.346.1 + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + - + diff --git a/src/main/java/hudson/plugins/favoriteview/FavoriteViewsTabBar.java b/src/main/java/hudson/plugins/favoriteview/FavoriteViewsTabBar.java index 94d4cdd..fd2d4fa 100644 --- a/src/main/java/hudson/plugins/favoriteview/FavoriteViewsTabBar.java +++ b/src/main/java/hudson/plugins/favoriteview/FavoriteViewsTabBar.java @@ -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); + } +} diff --git a/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/tab.jelly b/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/tab.jelly index 8af4e57..86dea95 100644 --- a/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/tab.jelly +++ b/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/tab.jelly @@ -1,72 +1,73 @@ - - - - - - - - - - - - ${name} - - - ${name} - - - ${name} - - - - - - - - - - - - - - - - - - - - - - ${name} - - - - - - \ No newline at end of file + + + + + + + + + + + + + ${name} + + + ${name} + + + ${name} + + + + + + + + + + + + + + + + + + + + + + ${name} + + + + + + diff --git a/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/viewTabs.jelly b/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/viewTabs.jelly index 964631e..773a1e9 100644 --- a/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/viewTabs.jelly +++ b/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsTabBar/viewTabs.jelly @@ -1,41 +1,42 @@ - - - - - - - - - - - - - - - - - - -
- -
- -
-
- - - -
-
+ + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+
diff --git a/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsUserProperty/config.jelly b/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsUserProperty/config.jelly index 994a9d9..9379d16 100644 --- a/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsUserProperty/config.jelly +++ b/src/main/resources/hudson/plugins/favoriteview/FavoriteViewsUserProperty/config.jelly @@ -1,6 +1,7 @@ - - - Favorite views are - configured by clicking the star icon on view tabs. - - \ No newline at end of file + + + + Favorite views are + configured by clicking the star icon on view tabs. + + diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly new file mode 100644 index 0000000..e438fac --- /dev/null +++ b/src/main/resources/index.jelly @@ -0,0 +1,5 @@ + +
+ An alternative implementation of the tab bar.
+ Users can mark some views as favorites, and these will show up as tabs. Other views are listed in a dropdown. +