diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a6a5e7e..7c62e71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Changelog of Pull Request Notifier for Bitbucket. -## Unreleased +## 2.24 ### GitHub [#123](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/123) Question on the configuration permissions. Checking for admin permission on the repo/project @@ -10,7 +10,7 @@ Changelog of Pull Request Notifier for Bitbucket. * Hiding admin restriction levels, in buttons config, that the user does not have access to. So that the user cannot create buttons that the user cannot see. * Sorting notifications and buttons by name in REST API. - [8eb180033a79346](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/8eb180033a79346) Tomas Bjerre *2016-06-20 17:32:05* + [15d2bd2ed9f8d6b](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/15d2bd2ed9f8d6b) Tomas Bjerre *2016-06-20 17:37:21* ## 2.23 ### GitHub [#122](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/122) Preserving configs when upgrading from stash 3.x to bitbucket 4.x diff --git a/src/main/java/se/bjurr/prnfb/presentation/GlobalAdminServlet.java b/src/main/java/se/bjurr/prnfb/presentation/GlobalAdminServlet.java index fd4bb73c..1ae3d2e1 100644 --- a/src/main/java/se/bjurr/prnfb/presentation/GlobalAdminServlet.java +++ b/src/main/java/se/bjurr/prnfb/presentation/GlobalAdminServlet.java @@ -66,6 +66,10 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) { "repository", repository.orNull(), // "isAdmin", isAdmin, // "isSystemAdmin", isSystemAdmin); + } else { + context = of( // + "isAdmin", isAdmin, // + "isSystemAdmin", isSystemAdmin); } response.setContentType("text/html;charset=UTF-8"); diff --git a/src/main/resources/admin.js b/src/main/resources/admin.js index 9d309169..10bd4bc5 100644 --- a/src/main/resources/admin.js +++ b/src/main/resources/admin.js @@ -3,9 +3,22 @@ define('plugin/prnfb/admin', [ 'aui', 'plugin/prnfb/utils' ], function($, AJS, utils) { - var settingsAdminUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings";  - var notificationsAdminUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/notifications";  - var buttonsAdminUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/buttons";  + var settingsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings";  + var settingsAdminUrl = settingsAdminUrlPostUrl; + + var notificationsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/notifications";  + var notificationsAdminUrl = notificationsAdminUrlPostUrl; + + var buttonsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/buttons";  + var buttonsAdminUrl = buttonsAdminUrlPostUrl; + + if ($('#prnfbRepositorySlug').length != 0) { + var projectKey = $('#prnfbProjectKey').val(); + var repositorySlug = $('#prnfbRepositorySlug').val(); + + notificationsAdminUrl = notificationsAdminUrlPostUrl + '/projectKey/'+projectKey+'/repositorySlug/'+repositorySlug; + buttonsAdminUrl = buttonsAdminUrlPostUrl + '/projectKey/'+projectKey+'/repositorySlug/'+repositorySlug; + } $(document) @@ -17,9 +30,9 @@ define('plugin/prnfb/admin', [ }); $(document).ready(function() { - utils.setupForm('#prnfbsettingsadmin', settingsAdminUrl); - utils.setupForms('#prnfbbuttonadmin', buttonsAdminUrl); - utils.setupForms('#prnfbnotificationadmin', notificationsAdminUrl); + utils.setupForm('#prnfbsettingsadmin', settingsAdminUrl, settingsAdminUrlPostUrl); + utils.setupForms('#prnfbbuttonadmin', buttonsAdminUrl ,buttonsAdminUrlPostUrl); + utils.setupForms('#prnfbnotificationadmin', notificationsAdminUrl, notificationsAdminUrlPostUrl); }); }); diff --git a/src/main/resources/admin.vm b/src/main/resources/admin.vm index 4ed7e66d..2ee94190 100644 --- a/src/main/resources/admin.vm +++ b/src/main/resources/admin.vm @@ -24,6 +24,15 @@ + + #if($repository) + + + + +#end + +
@@ -84,7 +93,9 @@
  • ${PULL_REQUEST_TO_REPO_SLUG} Example: rep_1
  • - Read more #if(!$repository) + Read more + + #if(!$repository)

    Global settings

    @@ -147,7 +158,6 @@ #end -

    Buttons

    @@ -189,6 +199,7 @@ #end +

    Visibility diff --git a/src/main/resources/utils.js b/src/main/resources/utils.js index c29e0617..4ddf9556 100644 --- a/src/main/resources/utils.js +++ b/src/main/resources/utils.js @@ -172,10 +172,10 @@ define('plugin/prnfb/utils', [ $(formSelector).find('input[type=radio]').prop('checked', false); } - function setupForm(formSelector, url) { + function setupForm(formSelector, url, postUrl) { $(formSelector).submit(function(e) { e.preventDefault(); - postForm(url, formSelector, function() {}); + postForm(postUrl, formSelector, function() {}); }); doSetupForm(formSelector, url); @@ -188,7 +188,7 @@ define('plugin/prnfb/utils', [ }); } - function setupForms(formSelector, restResource) { + function setupForms(formSelector, restResource, postUrl) { setupProjectAndRepoSettingsInForm($(formSelector)); @@ -214,7 +214,7 @@ define('plugin/prnfb/utils', [ $(formSelector + ' [name=uuid]').change(function() { var changedTo = $(this).val(); if (changedTo) { - doSetupForm(formSelector, restResource + '/' + changedTo); + doSetupForm(formSelector, postUrl + '/' + changedTo); } else { populateSelect(); } @@ -224,7 +224,7 @@ define('plugin/prnfb/utils', [ $(formSelector).submit(function(e) { e.preventDefault(); - postForm(restResource, formSelector, populateSelect); + postForm(postUrl, formSelector, populateSelect); }); $(formSelector + ' button[name=delete]').click(function(e) {