Skip to content

Commit

Permalink
Merge pull request #1197 from oncokb/fix/duplicate-service-token
Browse files Browse the repository at this point in the history
disable create service token button while one is being created
  • Loading branch information
bprize15 authored Jan 28, 2025
2 parents 93b7566 + e7e91e1 commit 200a3da
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/webapp/app/pages/AccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import client from 'app/shared/api/clientInstance';
import { Token } from 'app/shared/api/generated/API';
import ButtonWithTooltip from 'app/shared/button/ButtonWithTooltip';
import { LoadingButton } from 'app/shared/button/LoadingButton';
import InfoIcon from 'app/shared/icons/InfoIcon';
import { ContactLink } from 'app/shared/links/ContactLink';
import { SimpleConfirmModal } from 'app/shared/modal/SimpleConfirmModal';
Expand Down Expand Up @@ -67,6 +68,7 @@ export class AccountPage extends React.Component<IRegisterProps> {
@observable apiAccessRequested =
this.account?.additionalInfo?.apiAccessRequest?.requested || false;
@observable showCreateServiceAccountTokenModal = false;
@observable isCreatingServiceAccountToken = false;
@observable serviceAccountTokens: Token[] = [];

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

@action.bound
async addServiceAccountToken(name: string) {
this.isCreatingServiceAccountToken = true;
try {
await client.createServiceAccountTokenUsingPOST({ name });
await this.getServiceAccountTokens();
this.hideCreateServiceAccountTokenModal();
notifySuccess('Service account token is added');
} catch (e) {
notifyError(e);
} finally {
setTimeout(() => {
this.isCreatingServiceAccountToken = false;
}, 100);
}
}

Expand Down Expand Up @@ -458,7 +465,12 @@ export class AccountPage extends React.Component<IRegisterProps> {
>
Cancel
</Button>
<Button type="submit">Create Token</Button>
<Button
type="submit"
disabled={this.isCreatingServiceAccountToken}
>
Create Token
</Button>
</Modal.Footer>
</AvForm>
</Modal>
Expand Down

0 comments on commit 200a3da

Please sign in to comment.