11import Modal from 'flarum/common/components/Modal' ;
2- import app from " flarum/forum/app" ;
3- import Button from " flarum/common/components/Button" ;
2+ import app from ' flarum/forum/app' ;
3+ import Button from ' flarum/common/components/Button' ;
44
55export default class SendToLinearModal extends Modal {
66 static isDismissibleViaCloseButton = true ;
@@ -15,21 +15,17 @@ export default class SendToLinearModal extends Modal {
1515 tags = [ ] ;
1616
1717 loadData ( ) : void {
18- m . request (
19- {
20- method : "GET" ,
21- url : "/api/linear/teams" ,
22- }
23- ) . then ( ( response ) => {
18+ m . request ( {
19+ method : 'GET' ,
20+ url : '/api/linear/teams' ,
21+ } ) . then ( ( response ) => {
2422 this . teams = response . data . attributes ;
2523 } ) ;
2624
27- m . request (
28- {
29- method : "GET" ,
30- url : "/api/linear/priorities" ,
31- }
32- ) . then ( ( response ) => {
25+ m . request ( {
26+ method : 'GET' ,
27+ url : '/api/linear/priorities' ,
28+ } ) . then ( ( response ) => {
3329 this . priorities = response . data . attributes ;
3430 } ) ;
3531 }
@@ -41,75 +37,68 @@ export default class SendToLinearModal extends Modal {
4137
4238 title ( ) {
4339 // Title of the modal.
44- return app . translator . trans ( 'blomstra-linear.forum.modals.title' )
40+ return app . translator . trans ( 'blomstra-linear.forum.modals.title' ) ;
4541 }
4642
4743 content ( ) {
4844 if ( this . teams . length > 0 && this . priorities . length > 0 && this . selectedTeam !== '' ) {
49- return < >
50- < div class = "Modal-body" >
51- < div class = "Form" >
52- < div class = "Form-group" >
53- < label >
54- { app . translator . trans ( 'blomstra-linear.forum.modals.fields.team' ) }
55- </ label >
56- < span class = "Select" >
57- < select
58- value = { this . selectedTeam }
59- class = "Select-input FormControl"
60- onchange = { ( e ) => {
61- this . selectedTeam = e . target . value ; }
62- }
63- >
64- { this . teams . map ( ( team ) => {
65- return < option
66- value = { team . id }
67- > { team . name }
68- </ option >
69- } ) }
70- </ select >
71- </ span >
72- </ div >
73- < div class = "Form-group" >
74- < label >
75- { app . translator . trans ( 'blomstra-linear.forum.modals.fields.priority' ) }
76- </ label >
77- < span class = "Select" >
78- < select
79- class = "Select-input FormControl"
80- value = { this . selectedPriority }
81- onchange = { ( e ) => {
82- this . selectedPriority = e . target . value ;
83- } }
84- >
85- { this . priorities . map ( ( priority ) => {
86- return < option
87- value = { priority . priority }
45+ return (
46+ < >
47+ < div class = "Modal-body" >
48+ < div class = "Form" >
49+ < div class = "Form-group" >
50+ < label > { app . translator . trans ( 'blomstra-linear.forum.modals.fields.team' ) } </ label >
51+ < span class = "Select" >
52+ < select
53+ value = { this . selectedTeam }
54+ class = "Select-input FormControl"
55+ onchange = { ( e ) => {
56+ this . selectedTeam = e . target . value ;
57+ } }
8858 >
89- { priority . label }
90- </ option >
91- } ) }
92- </ select >
93- </ span >
94- </ div >
95- < div class = "Form-group" >
96- < Button className = "Button Button--primary" type = "submit" >
97- < i id = "linear-submission-loading" class = "fa fa-spinner fa-spin visually-hidden" aria-hidden = "true" > </ i >
98- { app . translator . trans ( 'blomstra-linear.forum.controls.send_to_linear_button' ) }
99- </ Button >
59+ { this . teams . map ( ( team ) => {
60+ return < option value = { team . id } > { team . name } </ option > ;
61+ } ) }
62+ </ select >
63+ </ span >
64+ </ div >
65+ < div class = "Form-group" >
66+ < label > { app . translator . trans ( 'blomstra-linear.forum.modals.fields.priority' ) } </ label >
67+ < span class = "Select" >
68+ < select
69+ class = "Select-input FormControl"
70+ value = { this . selectedPriority }
71+ onchange = { ( e ) => {
72+ this . selectedPriority = e . target . value ;
73+ } }
74+ >
75+ { this . priorities . map ( ( priority ) => {
76+ return < option value = { priority . priority } > { priority . label } </ option > ;
77+ } ) }
78+ </ select >
79+ </ span >
80+ </ div >
81+ < div class = "Form-group" >
82+ < Button className = "Button Button--primary" type = "submit" >
83+ < i id = "linear-submission-loading" class = "fa fa-spinner fa-spin visually-hidden" aria-hidden = "true" > </ i >
84+ { app . translator . trans ( 'blomstra-linear.forum.controls.send_to_linear_button' ) }
85+ </ Button >
86+ </ div >
87+ </ div >
10088 </ div >
101- </ div >
102- </ div >
103- </ >
89+ </ >
90+ ) ;
10491 } else {
105- return < >
106- < div class = "Modal-body" >
107- < p class = "center" >
108- < i class = "fas fa-spinner fa-spin" aria-hidden = "true" > </ i >
109- { app . translator . trans ( 'blomstra-linear.forum.modals.loading' ) }
110- </ p >
111- </ div >
112- </ >
92+ return (
93+ < >
94+ < div class = "Modal-body" >
95+ < p class = "center" >
96+ < i class = "fas fa-spinner fa-spin" aria-hidden = "true" > </ i >
97+ { app . translator . trans ( 'blomstra-linear.forum.modals.loading' ) }
98+ </ p >
99+ </ div >
100+ </ >
101+ ) ;
113102 }
114103 }
115104
@@ -119,25 +108,23 @@ export default class SendToLinearModal extends Modal {
119108 // Show the icon in the submit button
120109 document . getElementById ( 'linear-submission-loading' ) . classList . remove ( 'visually-hidden' ) ;
121110
122- m . request (
123- {
124- method : "POST" ,
125- url : "/api/linear/issues" ,
126- headers : {
127- 'X-CSRF-Token' : app . session . csrfToken ,
128- } ,
129- body : {
130- team : this . selectedTeam ,
131- priority : this . selectedPriority ,
132- tags : this . tags ,
133- discussion : this . attrs . discussion . id ( ) ,
134- }
135- }
136- ) . then ( ( response ) => {
111+ m . request ( {
112+ method : 'POST' ,
113+ url : '/api/linear/issues' ,
114+ headers : {
115+ 'X-CSRF-Token' : app . session . csrfToken ,
116+ } ,
117+ body : {
118+ team : this . selectedTeam ,
119+ priority : this . selectedPriority ,
120+ tags : this . tags ,
121+ discussion : this . attrs . discussion . id ( ) ,
122+ } ,
123+ } ) . then ( ( response ) => {
137124 app . forum . pushAttributes ( {
138125 blomstraLinearLastPriority : this . selectedPriority ,
139126 blomstraLinearLastTeamId : this . selectedTeam ,
140- } )
127+ } ) ;
141128
142129 if ( response . data . id !== undefined || response . data . id !== null ) {
143130 this . attrs . linear = response . data . id ;
@@ -162,5 +149,4 @@ export default class SendToLinearModal extends Modal {
162149
163150 this . selectedPriority = app . forum . attribute ( 'blomstraLinearLastPriority' ) ?? 0 ;
164151 }
165-
166152}
0 commit comments