Skip to content

Commit 200a3da

Browse files
authored
Merge pull request #1197 from oncokb/fix/duplicate-service-token
disable create service token button while one is being created
2 parents 93b7566 + e7e91e1 commit 200a3da

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/webapp/app/pages/AccountPage.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import client from 'app/shared/api/clientInstance';
2020
import { Token } from 'app/shared/api/generated/API';
2121
import ButtonWithTooltip from 'app/shared/button/ButtonWithTooltip';
22+
import { LoadingButton } from 'app/shared/button/LoadingButton';
2223
import InfoIcon from 'app/shared/icons/InfoIcon';
2324
import { ContactLink } from 'app/shared/links/ContactLink';
2425
import { SimpleConfirmModal } from 'app/shared/modal/SimpleConfirmModal';
@@ -67,6 +68,7 @@ export class AccountPage extends React.Component<IRegisterProps> {
6768
@observable apiAccessRequested =
6869
this.account?.additionalInfo?.apiAccessRequest?.requested || false;
6970
@observable showCreateServiceAccountTokenModal = false;
71+
@observable isCreatingServiceAccountToken = false;
7072
@observable serviceAccountTokens: Token[] = [];
7173

7274
constructor(props: Readonly<IRegisterProps>) {
@@ -126,13 +128,18 @@ export class AccountPage extends React.Component<IRegisterProps> {
126128

127129
@action.bound
128130
async addServiceAccountToken(name: string) {
131+
this.isCreatingServiceAccountToken = true;
129132
try {
130133
await client.createServiceAccountTokenUsingPOST({ name });
131134
await this.getServiceAccountTokens();
132135
this.hideCreateServiceAccountTokenModal();
133136
notifySuccess('Service account token is added');
134137
} catch (e) {
135138
notifyError(e);
139+
} finally {
140+
setTimeout(() => {
141+
this.isCreatingServiceAccountToken = false;
142+
}, 100);
136143
}
137144
}
138145

@@ -458,7 +465,12 @@ export class AccountPage extends React.Component<IRegisterProps> {
458465
>
459466
Cancel
460467
</Button>
461-
<Button type="submit">Create Token</Button>
468+
<Button
469+
type="submit"
470+
disabled={this.isCreatingServiceAccountToken}
471+
>
472+
Create Token
473+
</Button>
462474
</Modal.Footer>
463475
</AvForm>
464476
</Modal>

0 commit comments

Comments
 (0)