@@ -7,8 +7,8 @@ require([
77 'bitbucket/util/server' ,
88 '@bitbucket/apps/pull-requests/initial-data'
99] , function ( registry , $ , AJS , _ , thirdParty , srv , prData ) {
10- var prId = prData . pullRequest . id
11- var repoId = prData . repository . id
10+ var prId = prData . pullRequest . id ;
11+ var repoId = prData . repository . id ;
1212 var buttonsAdminUrl = "/rest/prnfb-admin/1.0/settings/buttons" ;
1313
1414 var waiting = '<span class="aui-icon aui-icon-wait aui-icon-small">Wait</span>' ;
@@ -197,77 +197,77 @@ require([
197197 } ;
198198
199199 function submitButton ( item , formResult ) {
200- srv . ajax ( {
201- "type" : "POST" ,
202- "url" : buttonsAdminUrl + '/' + item . uuid + '/press/repository/' + repoId + '/pullrequest/' + prId ,
203- "data" : {
204- "form" : formResult
205- } ,
206- "success" : function ( content ) {
207- setTimeout ( function ( ) {
208- if ( content . confirmation == "on" ) {
209- presentResult ( content . notificationResponses ) ;
210- }
211- } , 500 ) ;
212- } ,
213- "error" : function ( content ) {
214- AJS . flag ( {
215- close : 'manual' ,
216- type : 'error' ,
217- title : "Unknown error" ,
218- body : '<p>' + content . status + '</p>' + '<p>Check the Bitbucket Server log for more details.</p>'
219- } ) ;
200+ srv . ajax ( {
201+ "type" : "POST" ,
202+ "url" : buttonsAdminUrl + '/' + item . uuid + '/press/repository/' + repoId + '/pullrequest/' + prId ,
203+ "data" : {
204+ "form" : formResult
205+ } ,
206+ "success" : function ( content ) {
207+ setTimeout ( function ( ) {
208+ if ( content . confirmation == "on" ) {
209+ presentResult ( content . notificationResponses ) ;
220210 }
221- } ) ;
222-
223- if ( item . redirectUrl ) {
224- window . location . replace ( item . redirectUrl ) ;
211+ } , 500 ) ;
212+ } ,
213+ "error" : function ( content ) {
214+ AJS . flag ( {
215+ close : 'manual' ,
216+ type : 'error' ,
217+ title : "Unknown error" ,
218+ body : '<p>' + content . status + '</p>' + '<p>Check the Bitbucket Server log for more details.</p>'
219+ } ) ;
225220 }
221+ } ) ;
222+
223+ if ( item . redirectUrl ) {
224+ window . location . replace ( item . redirectUrl ) ;
225+ }
226226 }
227227
228228 function loadSettingsAndShowButtons ( ) {
229229 srv . rest ( {
230- url : buttonsAdminUrl + '/repository/' + repoId + '/pullrequest/' + prId ,
231- success : function ( settings ) {
232- settings . forEach ( function ( item , index ) {
233- registry . registerExtension (
234- 'se.bjurr.prnfs.pull-request-notifier-for-stash:custom-buttons' + index ,
235- function buttonFactory ( extensionAPI , context ) {
236- return {
237- type : 'button' ,
238- label : item . name ,
239- onAction : function ( ) {
240- if ( item . confirmationText || item . buttonFormList && item . buttonFormList . length > 0 ) {
241- // Create the form and dialog
242- var confirmationText = confirmationTextTemplate ( item . confirmationText ) ;
243- var form = formTemplate ( item . buttonFormList ) ;
244- var formHtml = $ ( "<div/>" ) . append ( confirmationText ) . append ( form ) . html ( ) ;
245- var $dialog = $ ( dialogTemplate ( item . name , formHtml ) ) ;
246- $dialog . appendTo ( $ ( "body" ) ) ;
230+ url : buttonsAdminUrl + '/repository/' + repoId + '/pullrequest/' + prId ,
231+ success : function ( settings ) {
232+ settings . forEach ( function ( item , index ) {
233+ registry . registerExtension (
234+ 'se.bjurr.prnfs.pull-request-notifier-for-stash:custom-buttons' + index ,
235+ function buttonFactory ( extensionAPI , context ) {
236+ return {
237+ type : 'button' ,
238+ label : item . name ,
239+ onAction : function ( ) {
240+ if ( item . confirmationText || item . buttonFormList && item . buttonFormList . length > 0 ) {
241+ // Create the form and dialog
242+ var confirmationText = confirmationTextTemplate ( item . confirmationText ) ;
243+ var form = formTemplate ( item . buttonFormList ) ;
244+ var formHtml = $ ( "<div/>" ) . append ( confirmationText ) . append ( form ) . html ( ) ;
245+ var $dialog = $ ( dialogTemplate ( item . name , formHtml ) ) ;
246+ $dialog . appendTo ( $ ( "body" ) ) ;
247247
248- var dialogRef = AJS . dialog2 ( $dialog ) ;
248+ var dialogRef = AJS . dialog2 ( $dialog ) ;
249249
250- // When you submit the form, we will post to the server with all the form data.
251- AJS . $ ( "#dialog-submit-button" ) . click ( function ( e ) {
252- var formResult = $dialog . find ( "form" ) . serializeJSON ( ) ;
253- e . preventDefault ( ) ;
254- dialogRef . hide ( ) ;
255- submitButton ( item , formResult ) ;
256- } ) ;
257- AJS . $ ( "#dialog-close-button" ) . click ( function ( e ) {
258- e . preventDefault ( ) ;
259- dialogRef . hide ( ) ;
260- } ) ;
261- dialogRef . show ( ) ;
262- } else {
263- submitButton ( item , null ) ;
264- }
265- }
266- } ;
250+ // When you submit the form, we will post to the server with all the form data.
251+ AJS . $ ( "#dialog-submit-button" ) . click ( function ( e ) {
252+ var formResult = $dialog . find ( "form" ) . serializeJSON ( ) ;
253+ e . preventDefault ( ) ;
254+ dialogRef . hide ( ) ;
255+ submitButton ( item , formResult ) ;
256+ } ) ;
257+ AJS . $ ( "#dialog-close-button" ) . click ( function ( e ) {
258+ e . preventDefault ( ) ;
259+ dialogRef . hide ( ) ;
260+ } ) ;
261+ dialogRef . show ( ) ;
262+ } else {
263+ submitButton ( item , null ) ;
267264 }
268- ) ;
269- } ) ;
270- }
265+ }
266+ } ;
267+ }
268+ ) ;
269+ } ) ;
270+ }
271271 } ) ;
272272 }
273273
0 commit comments