-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): delete system keys (#4426)
* feat(auth): delete system keys * Fix
- Loading branch information
1 parent
7faaba2
commit a6fa21e
Showing
8 changed files
with
379 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { ReactNode, useCallback, useState } from "react"; | ||
import { graphql, useMutation } from "react-relay"; | ||
|
||
import { | ||
Button, | ||
Dialog, | ||
DialogContainer, | ||
Flex, | ||
Icon, | ||
Icons, | ||
Text, | ||
View, | ||
} from "@arizeai/components"; | ||
|
||
import { useNotifySuccess } from "@phoenix/contexts"; | ||
|
||
export function DeleteSystemAPIKeyButton({ | ||
id, | ||
onDeleted, | ||
}: { | ||
id: string; | ||
onDeleted: () => void; | ||
}) { | ||
const [dialog, setDialog] = useState<ReactNode>(null); | ||
const notifySuccess = useNotifySuccess(); | ||
const [commit] = useMutation(graphql` | ||
mutation DeleteSystemAPIKeyButtonMutation($input: DeleteApiKeyInput!) { | ||
deleteSystemApiKey(input: $input) { | ||
__typename | ||
id | ||
} | ||
} | ||
`); | ||
const handleDelete = useCallback(() => { | ||
commit({ | ||
variables: { | ||
input: { | ||
id, | ||
}, | ||
}, | ||
onCompleted: () => { | ||
notifySuccess({ | ||
title: "System key deleted", | ||
message: "The system key has been deleted and is no longer active.", | ||
}); | ||
setDialog(null); | ||
onDeleted(); | ||
}, | ||
}); | ||
}, [commit, id, notifySuccess, setDialog]); | ||
const onDelete = () => { | ||
setDialog( | ||
<Dialog title="Delete System Key"> | ||
<View padding="size-200"> | ||
<Text color="danger"> | ||
{`Are you sure you want to delete this system key? This cannot be undone and will disable all services using this key.`} | ||
</Text> | ||
</View> | ||
<View | ||
paddingEnd="size-200" | ||
paddingTop="size-100" | ||
paddingBottom="size-100" | ||
borderTopColor="light" | ||
borderTopWidth="thin" | ||
> | ||
<Flex direction="row" justifyContent="end"> | ||
<Button | ||
variant="danger" | ||
onClick={() => { | ||
handleDelete(); | ||
setDialog(null); | ||
}} | ||
> | ||
Delete Key | ||
</Button> | ||
</Flex> | ||
</View> | ||
</Dialog> | ||
); | ||
}; | ||
return ( | ||
<> | ||
<Button | ||
variant="danger" | ||
size="compact" | ||
icon={<Icon svg={<Icons.TrashOutline />} />} | ||
aria-label="Delete System Key" | ||
onClick={onDelete} | ||
/> | ||
<DialogContainer | ||
isDismissable | ||
onDismiss={() => { | ||
setDialog(null); | ||
}} | ||
> | ||
{dialog} | ||
</DialogContainer> | ||
</> | ||
); | ||
} |
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
100 changes: 100 additions & 0 deletions
100
app/src/pages/settings/__generated__/DeleteSystemAPIKeyButtonMutation.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 12 additions & 4 deletions
16
app/src/pages/settings/__generated__/SystemAPIKeysTableFragment.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.