Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Only showing repo settings on repo admin page #123
Browse files Browse the repository at this point in the history
 * Was also showing global settings, with "any" repo/project. Changing it to make implementation simpler.
  • Loading branch information
tomasbjerre committed Jun 22, 2016
1 parent 5970139 commit 2d290b7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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

* If a user is only admin in one repo, the user should not be able to administrate the plugin in another repo.
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
25 changes: 19 additions & 6 deletions src/main/resources/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
});
});

Expand Down
15 changes: 13 additions & 2 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

<body>

<!-- //-->
#if($repository)
<!-- //-->
<input type="hidden" id="prnfbProjectKey" name="projectKey" value="$repository.project.key" />
<input type="hidden" id="prnfbRepositorySlug" name="repositorySlug" value="$repository.slug" />
<!-- //-->
#end
<!-- //-->

<div class="statusresponse"></div>


Expand Down Expand Up @@ -84,7 +93,9 @@
<li><b>${PULL_REQUEST_TO_REPO_SLUG}</b> Example: rep_1</li>
</ul>
</div>
<a id="replace-text-trigger" data-replace-text="Read less" class="aui-expander-trigger" aria-controls="prnfb-expander-variables">Read more</a> #if(!$repository)
<a id="replace-text-trigger" data-replace-text="Read less" class="aui-expander-trigger" aria-controls="prnfb-expander-variables">Read more</a>
<!-- //-->
#if(!$repository)
<!-- //-->
<h3>Global settings</h3>
<p>
Expand Down Expand Up @@ -147,7 +158,6 @@
<!-- //-->
#end


<!-- //-->
<h3>Buttons</h3>
<p>
Expand Down Expand Up @@ -189,6 +199,7 @@
<!-- //-->
#end


<fieldset class="group">
<legend>
<span>Visibility</span>
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -188,7 +188,7 @@ define('plugin/prnfb/utils', [
});
}

function setupForms(formSelector, restResource) {
function setupForms(formSelector, restResource, postUrl) {

setupProjectAndRepoSettingsInForm($(formSelector));

Expand All @@ -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();
}
Expand All @@ -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) {
Expand Down

0 comments on commit 2d290b7

Please sign in to comment.