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

Commit 2d290b7

Browse files
committed
Only showing repo settings on repo admin page #123
* Was also showing global settings, with "any" repo/project. Changing it to make implementation simpler.
1 parent 5970139 commit 2d290b7

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Changelog of Pull Request Notifier for Bitbucket.
44

5-
## Unreleased
5+
## 2.24
66
### GitHub [#123](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/123) Question on the configuration permissions.
77
Checking for admin permission on the repo/project
88

99
* If a user is only admin in one repo, the user should not be able to administrate the plugin in another repo.
1010
* 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.
1111
* Sorting notifications and buttons by name in REST API.
1212

13-
[8eb180033a79346](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/8eb180033a79346) Tomas Bjerre *2016-06-20 17:32:05*
13+
[15d2bd2ed9f8d6b](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/15d2bd2ed9f8d6b) Tomas Bjerre *2016-06-20 17:37:21*
1414

1515
## 2.23
1616
### 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

src/main/java/se/bjurr/prnfb/presentation/GlobalAdminServlet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {
6666
"repository", repository.orNull(), //
6767
"isAdmin", isAdmin, //
6868
"isSystemAdmin", isSystemAdmin);
69+
} else {
70+
context = of( //
71+
"isAdmin", isAdmin, //
72+
"isSystemAdmin", isSystemAdmin);
6973
}
7074

7175
response.setContentType("text/html;charset=UTF-8");

src/main/resources/admin.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,22 @@ define('plugin/prnfb/admin', [
33
'aui',
44
'plugin/prnfb/utils'
55
], function($, AJS, utils) {
6-
var settingsAdminUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings"; 
7-
var notificationsAdminUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/notifications"; 
8-
var buttonsAdminUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/buttons"; 
6+
var settingsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings"; 
7+
var settingsAdminUrl = settingsAdminUrlPostUrl;
8+
9+
var notificationsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/notifications"; 
10+
var notificationsAdminUrl = notificationsAdminUrlPostUrl;
11+
12+
var buttonsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/buttons"; 
13+
var buttonsAdminUrl = buttonsAdminUrlPostUrl;
14+
15+
if ($('#prnfbRepositorySlug').length != 0) {
16+
var projectKey = $('#prnfbProjectKey').val();
17+
var repositorySlug = $('#prnfbRepositorySlug').val();
18+
19+
notificationsAdminUrl = notificationsAdminUrlPostUrl + '/projectKey/'+projectKey+'/repositorySlug/'+repositorySlug;
20+
buttonsAdminUrl = buttonsAdminUrlPostUrl + '/projectKey/'+projectKey+'/repositorySlug/'+repositorySlug;
21+
}
922

1023

1124
$(document)
@@ -17,9 +30,9 @@ define('plugin/prnfb/admin', [
1730
});
1831

1932
$(document).ready(function() {
20-
utils.setupForm('#prnfbsettingsadmin', settingsAdminUrl);
21-
utils.setupForms('#prnfbbuttonadmin', buttonsAdminUrl);
22-
utils.setupForms('#prnfbnotificationadmin', notificationsAdminUrl);
33+
utils.setupForm('#prnfbsettingsadmin', settingsAdminUrl, settingsAdminUrlPostUrl);
34+
utils.setupForms('#prnfbbuttonadmin', buttonsAdminUrl ,buttonsAdminUrlPostUrl);
35+
utils.setupForms('#prnfbnotificationadmin', notificationsAdminUrl, notificationsAdminUrlPostUrl);
2336
});
2437
});
2538

src/main/resources/admin.vm

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424

2525
<body>
2626

27+
<!-- //-->
28+
#if($repository)
29+
<!-- //-->
30+
<input type="hidden" id="prnfbProjectKey" name="projectKey" value="$repository.project.key" />
31+
<input type="hidden" id="prnfbRepositorySlug" name="repositorySlug" value="$repository.slug" />
32+
<!-- //-->
33+
#end
34+
<!-- //-->
35+
2736
<div class="statusresponse"></div>
2837

2938

@@ -84,7 +93,9 @@
8493
<li><b>${PULL_REQUEST_TO_REPO_SLUG}</b> Example: rep_1</li>
8594
</ul>
8695
</div>
87-
<a id="replace-text-trigger" data-replace-text="Read less" class="aui-expander-trigger" aria-controls="prnfb-expander-variables">Read more</a> #if(!$repository)
96+
<a id="replace-text-trigger" data-replace-text="Read less" class="aui-expander-trigger" aria-controls="prnfb-expander-variables">Read more</a>
97+
<!-- //-->
98+
#if(!$repository)
8899
<!-- //-->
89100
<h3>Global settings</h3>
90101
<p>
@@ -147,7 +158,6 @@
147158
<!-- //-->
148159
#end
149160

150-
151161
<!-- //-->
152162
<h3>Buttons</h3>
153163
<p>
@@ -189,6 +199,7 @@
189199
<!-- //-->
190200
#end
191201

202+
192203
<fieldset class="group">
193204
<legend>
194205
<span>Visibility</span>

src/main/resources/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ define('plugin/prnfb/utils', [
172172
$(formSelector).find('input[type=radio]').prop('checked', false);
173173
}
174174

175-
function setupForm(formSelector, url) {
175+
function setupForm(formSelector, url, postUrl) {
176176
$(formSelector).submit(function(e) {
177177
e.preventDefault();
178-
postForm(url, formSelector, function() {});
178+
postForm(postUrl, formSelector, function() {});
179179
});
180180

181181
doSetupForm(formSelector, url);
@@ -188,7 +188,7 @@ define('plugin/prnfb/utils', [
188188
});
189189
}
190190

191-
function setupForms(formSelector, restResource) {
191+
function setupForms(formSelector, restResource, postUrl) {
192192

193193
setupProjectAndRepoSettingsInForm($(formSelector));
194194

@@ -214,7 +214,7 @@ define('plugin/prnfb/utils', [
214214
$(formSelector + ' [name=uuid]').change(function() {
215215
var changedTo = $(this).val();
216216
if (changedTo) {
217-
doSetupForm(formSelector, restResource + '/' + changedTo);
217+
doSetupForm(formSelector, postUrl + '/' + changedTo);
218218
} else {
219219
populateSelect();
220220
}
@@ -224,7 +224,7 @@ define('plugin/prnfb/utils', [
224224

225225
$(formSelector).submit(function(e) {
226226
e.preventDefault();
227-
postForm(restResource, formSelector, populateSelect);
227+
postForm(postUrl, formSelector, populateSelect);
228228
});
229229

230230
$(formSelector + ' button[name=delete]').click(function(e) {

0 commit comments

Comments
 (0)