-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92698a3
commit e0b9802
Showing
8 changed files
with
101 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
.../[team]/access/service-accounts/[account]/_components/DeleteServiceAccountTokenDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { FaTrash } from 'react-icons/fa' | ||
import { DeleteServiceAccountToken } from '@/graphql/mutations/service-accounts/deleteServiceAccountToken.gql' | ||
import { GetServiceAccounts } from '@/graphql/queries/service-accounts/getServiceAccounts.gql' | ||
import { useMutation } from '@apollo/client' | ||
import { toast } from 'react-toastify' | ||
import { useContext, useRef } from 'react' | ||
import { organisationContext } from '@/contexts/organisationContext' | ||
import { ServiceAccountTokenType, ServiceAccountType } from '@/apollo/graphql' | ||
import { Button } from '@/components/common/Button' | ||
import GenericDialog from '@/components/common/GenericDialog' | ||
import { useRouter } from 'next/navigation' | ||
|
||
export const DeleteServiceAccountTokenDialog = ({ token }: { token: ServiceAccountTokenType }) => { | ||
const { activeOrganisation: organisation } = useContext(organisationContext) | ||
|
||
const dialogRef = useRef<{ closeModal: () => void }>(null) | ||
|
||
const [deleteToken] = useMutation(DeleteServiceAccountToken) | ||
|
||
const handleDelete = async () => { | ||
const deleted = await deleteToken({ | ||
variables: { id: token.id }, | ||
refetchQueries: [{ query: GetServiceAccounts, variables: { orgId: organisation!.id } }], | ||
}) | ||
if (deleted.data.deleteServiceAccountToken.ok) { | ||
toast.success('Deleted token!') | ||
if (dialogRef.current) dialogRef.current.closeModal() | ||
} | ||
} | ||
|
||
return ( | ||
<GenericDialog | ||
title={`Delete ${token.name}`} | ||
buttonContent={ | ||
<> | ||
<FaTrash /> Delete | ||
</> | ||
} | ||
buttonVariant="danger" | ||
ref={dialogRef} | ||
> | ||
<div className="space-y-4"> | ||
<div className="text-neutral-500 py-4">Are you sure you want to delete this token?</div> | ||
<div className="flex justify-end"> | ||
<Button variant="danger" onClick={handleDelete}> | ||
<FaTrash /> Delete | ||
</Button> | ||
</div> | ||
</div> | ||
</GenericDialog> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
frontend/graphql/mutations/service-accounts/deleteServiceAccountToken.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mutation DeleteServiceAccountToken($id: ID!) { | ||
deleteServiceAccountToken(tokenId: $id) { | ||
ok | ||
} | ||
} |