@@ -19,6 +19,7 @@ import {
19
19
import client from 'app/shared/api/clientInstance' ;
20
20
import { Token } from 'app/shared/api/generated/API' ;
21
21
import ButtonWithTooltip from 'app/shared/button/ButtonWithTooltip' ;
22
+ import { LoadingButton } from 'app/shared/button/LoadingButton' ;
22
23
import InfoIcon from 'app/shared/icons/InfoIcon' ;
23
24
import { ContactLink } from 'app/shared/links/ContactLink' ;
24
25
import { SimpleConfirmModal } from 'app/shared/modal/SimpleConfirmModal' ;
@@ -67,6 +68,7 @@ export class AccountPage extends React.Component<IRegisterProps> {
67
68
@observable apiAccessRequested =
68
69
this . account ?. additionalInfo ?. apiAccessRequest ?. requested || false ;
69
70
@observable showCreateServiceAccountTokenModal = false ;
71
+ @observable isCreatingServiceAccountToken = false ;
70
72
@observable serviceAccountTokens : Token [ ] = [ ] ;
71
73
72
74
constructor ( props : Readonly < IRegisterProps > ) {
@@ -126,13 +128,18 @@ export class AccountPage extends React.Component<IRegisterProps> {
126
128
127
129
@action . bound
128
130
async addServiceAccountToken ( name : string ) {
131
+ this . isCreatingServiceAccountToken = true ;
129
132
try {
130
133
await client . createServiceAccountTokenUsingPOST ( { name } ) ;
131
134
await this . getServiceAccountTokens ( ) ;
132
135
this . hideCreateServiceAccountTokenModal ( ) ;
133
136
notifySuccess ( 'Service account token is added' ) ;
134
137
} catch ( e ) {
135
138
notifyError ( e ) ;
139
+ } finally {
140
+ setTimeout ( ( ) => {
141
+ this . isCreatingServiceAccountToken = false ;
142
+ } , 100 ) ;
136
143
}
137
144
}
138
145
@@ -458,7 +465,12 @@ export class AccountPage extends React.Component<IRegisterProps> {
458
465
>
459
466
Cancel
460
467
</ Button >
461
- < Button type = "submit" > Create Token</ Button >
468
+ < Button
469
+ type = "submit"
470
+ disabled = { this . isCreatingServiceAccountToken }
471
+ >
472
+ Create Token
473
+ </ Button >
462
474
</ Modal . Footer >
463
475
</ AvForm >
464
476
</ Modal >
0 commit comments