@@ -91,13 +91,18 @@ function appendTokenToTable(data) {
9191 const tokenShowButton = apiTokenRow . querySelector (
9292 ".api-token-property-token-show" ,
9393 ) ;
94- const tokenExpirationSpan = apiTokenRow . querySelector ( ".api-token-new-expiration" ) ;
94+ const tokenExpirationSpan = apiTokenRow . querySelector (
95+ ".api-token-new-expiration" ,
96+ ) ;
9597 if ( data . expirationDate === "never" ) {
9698 tokenExpirationSpan . innerText = tokenExpirationSpan . dataset . never ;
9799 tokenExpirationSpan . classList . add ( "warning" ) ;
98100 } else {
99- tokenExpirationSpan . innerText = tokenExpirationSpan . dataset . expiresOn . replace ( "__DATA__" , data . expirationDate ) ;
100- const expirationDate = new Date ( data . expirationDate ) ;
101+ tokenExpirationSpan . innerText =
102+ tokenExpirationSpan . dataset . expiresOn . replace (
103+ "__DATA__" ,
104+ data . expirationDate ,
105+ ) ;
101106 }
102107
103108 apiTokenRow . id = data . tokenUuid ;
@@ -111,11 +116,13 @@ function appendTokenToTable(data) {
111116}
112117
113118function addFormChangesHandling ( form ) {
114- const expirationSelect = form . querySelector ( 'select[name="expirationDuration"]' ) ;
119+ const expirationSelect = form . querySelector (
120+ 'select[name="expirationDuration"]' ,
121+ ) ;
115122 const customDateInput = form . querySelector ( 'input[name="tokenExpiration"]' ) ;
116- const warningDiv = form . querySelector ( ' .token-warning' ) ;
123+ const warningDiv = form . querySelector ( " .token-warning" ) ;
117124
118- expirationSelect . addEventListener ( ' change' , ( ) => {
125+ expirationSelect . addEventListener ( " change" , ( ) => {
119126 if ( expirationSelect . value === "custom" ) {
120127 customDateInput . classList . remove ( "jenkins-hidden" ) ;
121128 const submitButton = form . querySelector ( 'button[data-id="ok"]' ) ;
@@ -136,7 +143,7 @@ function addFormChangesHandling(form) {
136143 }
137144 } ) ;
138145
139- customDateInput . addEventListener ( ' change' , ( ) => {
146+ customDateInput . addEventListener ( " change" , ( ) => {
140147 const submitButton = form . querySelector ( 'button[data-id="ok"]' ) ;
141148 if ( customDateInput . value !== "" ) {
142149 submitButton . disabled = false ;
@@ -149,8 +156,9 @@ function addFormChangesHandling(form) {
149156function addToken ( button ) {
150157 const targetUrl = button . dataset . targetUrl ;
151158 const promptMessage = button . dataset . promptMessage ;
152- const promptName = button . dataset . messageName ;
153- const formTemplate = document . getElementById ( "api-token-add-template" ) . firstElementChild . cloneNode ( true ) ;
159+ const formTemplate = document
160+ . getElementById ( "api-token-add-template" )
161+ . firstElementChild . cloneNode ( true ) ;
154162 const form = document . createElement ( "form" ) ;
155163 const dateInput = formTemplate . querySelector ( 'input[name="tokenExpiration"]' ) ;
156164 const now = new Date ( ) ;
@@ -159,9 +167,9 @@ function addToken(button) {
159167 const presetDate = new Date ( ) ;
160168 presetDate . setDate ( now . getDate ( ) + 30 ) ;
161169 nextYear . setDate ( now . getDate ( ) + 365 ) ;
162- dateInput . min = now . toISOString ( ) . split ( 'T' ) [ 0 ]
163- dateInput . max = nextYear . toISOString ( ) . split ( 'T' ) [ 0 ]
164- dateInput . value = presetDate . toISOString ( ) . split ( 'T' ) [ 0 ]
170+ dateInput . min = now . toISOString ( ) . split ( "T" ) [ 0 ] ;
171+ dateInput . max = nextYear . toISOString ( ) . split ( "T" ) [ 0 ] ;
172+ dateInput . value = presetDate . toISOString ( ) . split ( "T" ) [ 0 ] ;
165173 form . appendChild ( formTemplate ) ;
166174 addFormChangesHandling ( form ) ;
167175 dialog
@@ -176,13 +184,11 @@ function addToken(button) {
176184 . then (
177185 ( formData ) => {
178186 fetch ( targetUrl , {
179- body : new URLSearchParams (
180- {
181- newTokenName : formData . get ( "tokenName" ) ,
182- tokenExpiration : formData . get ( "tokenExpiration" ) ,
183- expirationDuration : formData . get ( "expirationDuration" ) ,
184- }
185- ) ,
187+ body : new URLSearchParams ( {
188+ newTokenName : formData . get ( "tokenName" ) ,
189+ tokenExpiration : formData . get ( "tokenExpiration" ) ,
190+ expirationDuration : formData . get ( "expirationDuration" ) ,
191+ } ) ,
186192 method : "post" ,
187193 headers : crumb . wrap ( {
188194 "Content-Type" : "application/x-www-form-urlencoded" ,
@@ -217,12 +223,15 @@ function showToken(tokenName, tokenValue, expirationDate, doneText) {
217223
218224 const tokenValueSpan = apiTokenMessage . querySelector ( ".api-token-new-value" ) ;
219225 tokenValueSpan . innerText = tokenValue ;
220- const tokenExpirationSpan = apiTokenMessage . querySelector ( ".api-token-new-expiration" ) ;
226+ const tokenExpirationSpan = apiTokenMessage . querySelector (
227+ ".api-token-new-expiration" ,
228+ ) ;
221229 if ( expirationDate === "never" ) {
222230 tokenExpirationSpan . innerText = tokenExpirationSpan . dataset . never ;
223231 tokenExpirationSpan . classList . add ( "warning" ) ;
224232 } else {
225- tokenExpirationSpan . innerText = tokenExpirationSpan . dataset . expiresOn . replace ( "__DATA__" , expirationDate ) ;
233+ tokenExpirationSpan . innerText =
234+ tokenExpirationSpan . dataset . expiresOn . replace ( "__DATA__" , expirationDate ) ;
226235 }
227236
228237 if ( isSecureContext ) {
0 commit comments