From 332d7a52ec56c2ed1af736a8026651c8ce84a499 Mon Sep 17 00:00:00 2001 From: netwolfuk Date: Sat, 31 Oct 2015 23:50:18 +1300 Subject: [PATCH] Add reason for not displaying _Root webhooks for non-admin users in Webhooks Project Tab. Fixes issue #11. Removed buildWebHookTab.jsp as it was no longer used. Renamed projectWebHookTab.jsp webHookTab.jsp since it is now used for Build and Project tab pages. --- .../extension/WebHookBuildTabExtension.java | 3 +- .../extension/WebHookProjectTabExtension.java | 10 +++- .../WebHook/buildWebHookTab.jsp | 53 ------------------- .../{projectWebHookTab.jsp => webHookTab.jsp} | 4 +- 4 files changed, 13 insertions(+), 57 deletions(-) delete mode 100644 tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/buildWebHookTab.jsp rename tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/{projectWebHookTab.jsp => webHookTab.jsp} (91%) diff --git a/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookBuildTabExtension.java b/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookBuildTabExtension.java index c04a2832..edc8875f 100644 --- a/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookBuildTabExtension.java +++ b/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookBuildTabExtension.java @@ -113,8 +113,7 @@ protected void fillModel(Map model, HttpServletRequest request, @Override public String getIncludeUrl() { - //return myPluginPath + "WebHook/buildWebHookTab.jsp"; - return myPluginPath + "WebHook/projectWebHookTab.jsp"; + return myPluginPath + "WebHook/webHookTab.jsp"; } diff --git a/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookProjectTabExtension.java b/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookProjectTabExtension.java index 022ee2ff..a32bae1f 100644 --- a/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookProjectTabExtension.java +++ b/tcwebhooks-web-ui/src/main/java/webhook/teamcity/extension/WebHookProjectTabExtension.java @@ -50,8 +50,14 @@ protected void fillModel(Map model, HttpServletRequest request, List projectAndParents = new ArrayList(); List parentProjects = project.getProjectPath(); + + model.put("permissionError", ""); + if (!user.getGlobalPermissions().contains(Permission.CHANGE_SERVER_SETTINGS)){ parentProjects.remove(0); + if (project.getProjectId().equals("_Root")){ + model.put("permissionError", "You do not have permission to view WebHooks for the _Root project. Please contact your TeamCity Administrator"); + } } for (SProject projectParent : parentProjects){ projectAndParents.add( @@ -73,6 +79,8 @@ protected void fillModel(Map model, HttpServletRequest request, model.put("projectAndParents", projectAndParents); + + // model.put("projectWebHookCount", projectWebhooks.size()); // if (projectWebhooks.size() == 0){ // model.put("noProjectWebHooks", "true"); @@ -93,7 +101,7 @@ protected void fillModel(Map model, HttpServletRequest request, @Override public String getIncludeUrl() { - return myPluginPath+ "WebHook/projectWebHookTab.jsp"; + return myPluginPath+ "WebHook/webHookTab.jsp"; } } diff --git a/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/buildWebHookTab.jsp b/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/buildWebHookTab.jsp deleted file mode 100644 index f7b10fe9..00000000 --- a/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/buildWebHookTab.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%@ include file="/include.jsp" %> -

WebHooks configured for ${projectName}

- - -
-

There are no WebHooks configured for this project.

- Add project WebHooks. -
-
- - -
- -
WARNING: Webhook processing is currently disabled for this project
-
-

There are ${projectWebHookCount} WebHooks configured for all builds in this project. - Edit project WebHooks.

- - - - - - - -
URLEnabled
-
- -
- -

WebHooks configured for ${projectName} > ${buildName}

- - -
-

There are no WebHooks configured for this specific build.

- Add build WebHooks. -
-
- - -
-

There are ${buildWebHookCount} WebHooks for this specific build. - Edit build WebHooks.

- - - - - - - -
URLEnabled
-
- -
\ No newline at end of file diff --git a/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/projectWebHookTab.jsp b/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/webHookTab.jsp similarity index 91% rename from tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/projectWebHookTab.jsp rename to tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/webHookTab.jsp index 81d79739..f12060a7 100644 --- a/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/projectWebHookTab.jsp +++ b/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/webHookTab.jsp @@ -1,6 +1,8 @@ <%@ include file="/include.jsp" %>
+ ${permissionError} +
@@ -39,7 +41,7 @@ -

WebHooks configured for ${projectName} > ${config.buildName}

+

WebHooks configured for ${projectName} > ${config.buildName}