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

Commit

Permalink
Adjustments after merge of #372
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Dec 5, 2020
1 parent 7de2b9c commit 86daca7
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 77 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ As suggested: https://community.developer.atlassian.com/t/how-to-get-ajs-context

[e06f971ca6b2f05](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/e06f971ca6b2f05) Mads Opheim *2019-10-10 14:15:44*

### GitHub [#372](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/pull/372) Changes for bitbucket 7+
Changes for bitbucket 7+ ()

Co-authored-by: sreer <[email protected]>

[7de2b9c500cbe8a](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/7de2b9c500cbe8a) Rajesh Krishna *2020-12-05 17:41:51*

### No issue
doc

[ec660104ede0b3c](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/ec660104ede0b3c) Tomas Bjerre *2020-04-26 05:54:39*

Correcting custom keystore

Using custom keystore even if "Accept Any Certificate" is disabled.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,4 @@ Changelog of Pull Request Notifier for Bitbucket.
<quick.reload.version>2.0.0</quick.reload.version>
<amps.version>8.0.2</amps.version>
</properties>
</project>
</project>
2 changes: 1 addition & 1 deletion src/main/resources/atlassian-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@
<dependency>com.atlassian.bitbucket.server.bitbucket-web-api:server</dependency>
<context>bitbucket.ui.pullrequest.action</context>
</web-resource>
</atlassian-plugin>
</atlassian-plugin>
128 changes: 64 additions & 64 deletions src/main/resources/pr-triggerbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require([
'bitbucket/util/server',
'@bitbucket/apps/pull-requests/initial-data'
], function(registry, $, AJS, _, thirdParty, srv, prData) {
var prId = prData.pullRequest.id
var repoId = prData.repository.id
var prId = prData.pullRequest.id;
var repoId = prData.repository.id;
var buttonsAdminUrl = "/rest/prnfb-admin/1.0/settings/buttons";

var waiting = '<span class="aui-icon aui-icon-wait aui-icon-small">Wait</span>';
Expand Down Expand Up @@ -197,77 +197,77 @@ require([
};

function submitButton(item, formResult) {
srv.ajax({
"type": "POST",
"url": buttonsAdminUrl + '/' + item.uuid + '/press/repository/' + repoId +'/pullrequest/' + prId,
"data": {
"form": formResult
},
"success": function(content) {
setTimeout(function() {
if (content.confirmation == "on") {
presentResult(content.notificationResponses);
}
}, 500);
},
"error": function(content) {
AJS.flag({
close: 'manual',
type: 'error',
title: "Unknown error",
body: '<p>' + content.status + '</p>' + '<p>Check the Bitbucket Server log for more details.</p>'
});
srv.ajax({
"type": "POST",
"url": buttonsAdminUrl + '/' + item.uuid + '/press/repository/' + repoId + '/pullrequest/' + prId,
"data": {
"form": formResult
},
"success": function(content) {
setTimeout(function() {
if (content.confirmation == "on") {
presentResult(content.notificationResponses);
}
});

if (item.redirectUrl) {
window.location.replace(item.redirectUrl);
}, 500);
},
"error": function(content) {
AJS.flag({
close: 'manual',
type: 'error',
title: "Unknown error",
body: '<p>' + content.status + '</p>' + '<p>Check the Bitbucket Server log for more details.</p>'
});
}
});

if (item.redirectUrl) {
window.location.replace(item.redirectUrl);
}
}

function loadSettingsAndShowButtons() {
srv.rest({
url : buttonsAdminUrl + '/repository/' + repoId + '/pullrequest/' + prId,
success : function(settings) {
settings.forEach(function(item, index) {
registry.registerExtension(
'se.bjurr.prnfs.pull-request-notifier-for-stash:custom-buttons' + index,
function buttonFactory(extensionAPI, context) {
return {
type: 'button',
label: item.name,
onAction : function() {
if (item.confirmationText || item.buttonFormList && item.buttonFormList.length > 0) {
// Create the form and dialog
var confirmationText = confirmationTextTemplate(item.confirmationText);
var form = formTemplate(item.buttonFormList);
var formHtml = $("<div/>").append(confirmationText).append(form).html();
var $dialog = $(dialogTemplate(item.name, formHtml));
$dialog.appendTo($("body"));
url: buttonsAdminUrl + '/repository/' + repoId + '/pullrequest/' + prId,
success: function(settings) {
settings.forEach(function(item, index) {
registry.registerExtension(
'se.bjurr.prnfs.pull-request-notifier-for-stash:custom-buttons' + index,
function buttonFactory(extensionAPI, context) {
return {
type: 'button',
label: item.name,
onAction: function() {
if (item.confirmationText || item.buttonFormList && item.buttonFormList.length > 0) {
// Create the form and dialog
var confirmationText = confirmationTextTemplate(item.confirmationText);
var form = formTemplate(item.buttonFormList);
var formHtml = $("<div/>").append(confirmationText).append(form).html();
var $dialog = $(dialogTemplate(item.name, formHtml));
$dialog.appendTo($("body"));

var dialogRef = AJS.dialog2($dialog);
var dialogRef = AJS.dialog2($dialog);

// When you submit the form, we will post to the server with all the form data.
AJS.$("#dialog-submit-button").click(function(e) {
var formResult = $dialog.find("form").serializeJSON();
e.preventDefault();
dialogRef.hide();
submitButton(item, formResult);
});
AJS.$("#dialog-close-button").click(function(e) {
e.preventDefault();
dialogRef.hide();
});
dialogRef.show();
} else {
submitButton(item, null);
}
}
};
// When you submit the form, we will post to the server with all the form data.
AJS.$("#dialog-submit-button").click(function(e) {
var formResult = $dialog.find("form").serializeJSON();
e.preventDefault();
dialogRef.hide();
submitButton(item, formResult);
});
AJS.$("#dialog-close-button").click(function(e) {
e.preventDefault();
dialogRef.hide();
});
dialogRef.show();
} else {
submitButton(item, null);
}
);
});
}
}
};
}
);
});
}
});
}

Expand Down
22 changes: 11 additions & 11 deletions src/main/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ define('plugin/prnfb/utils', [

function getProjects(whenDone) {
var projectsUrl = "/rest/api/1.0/projects?limit=999999";
srv.rest ({
url : projectsUrl,
success: function(data) {
whenDone(data);
}
srv.rest({
url: projectsUrl,
success: function(data) {
whenDone(data);
}
});
}

Expand Down Expand Up @@ -95,12 +95,12 @@ define('plugin/prnfb/utils', [
return;
}
var reposUrl = "/rest/api/1.0/projects/" + projectKey + "/repos?limit=999999";
srv.rest ({
url : reposUrl,
success: function(data) {
whenDone(data);
}
});
srv.rest({
url: reposUrl,
success: function(data) {
whenDone(data);
}
});
}

function setupProjectAndRepoSettingsInForm($form, hasProjectAndRepo) {
Expand Down

0 comments on commit 86daca7

Please sign in to comment.