-
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): add admin user management ui (#4631)
* feat(auth): add admin user management ui * block changing admins role, block resetting password when not using local auth * remove user form changes * remove blocked wording for user delete
- Loading branch information
1 parent
79cc9c3
commit cc453e0
Showing
17 changed files
with
817 additions
and
156 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
This file was deleted.
Oops, something went wrong.
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,80 @@ | ||
import React, { useCallback } from "react"; | ||
import { graphql, useMutation } from "react-relay"; | ||
|
||
import { Button, Dialog, Flex, Text, View } from "@arizeai/components"; | ||
|
||
import { useNotifyError, useNotifySuccess } from "@phoenix/contexts"; | ||
|
||
export function DeleteUserDialog({ | ||
userId, | ||
onDeleted, | ||
onClose, | ||
}: { | ||
userId: string; | ||
onDeleted: () => void; | ||
onClose: () => void; | ||
}) { | ||
const [commit, isCommitting] = useMutation(graphql` | ||
mutation DeleteUserDialogMutation($input: DeleteUsersInput!) { | ||
deleteUsers(input: $input) | ||
} | ||
`); | ||
|
||
const notifySuccess = useNotifySuccess(); | ||
const notifyError = useNotifyError(); | ||
|
||
const handleDelete = useCallback(() => { | ||
commit({ | ||
variables: { | ||
input: { | ||
userIds: [userId], | ||
}, | ||
}, | ||
onCompleted: () => { | ||
notifySuccess({ | ||
title: "User deleted", | ||
message: "User has been deleted.", | ||
}); | ||
onDeleted(); | ||
onClose(); | ||
}, | ||
onError: (error) => { | ||
notifyError({ | ||
title: "Failed to delete user", | ||
message: error.message, | ||
}); | ||
}, | ||
}); | ||
}, [commit, notifyError, notifySuccess, onClose, onDeleted, userId]); | ||
return ( | ||
<Dialog title="Delete User" isDismissable onDismiss={onClose}> | ||
<View padding="size-200"> | ||
<Text color="danger"> | ||
{`Are you sure you want to delete this user? This action cannot be undone.`} | ||
</Text> | ||
</View> | ||
<View | ||
paddingEnd="size-200" | ||
paddingTop="size-100" | ||
paddingBottom="size-100" | ||
borderTopColor="light" | ||
borderTopWidth="thin" | ||
> | ||
<Flex direction="row" justifyContent="end" gap={"size-100"}> | ||
<Button variant="default" onClick={onClose}> | ||
Cancel | ||
</Button> | ||
<Button | ||
variant="danger" | ||
onClick={() => { | ||
handleDelete(); | ||
}} | ||
disabled={isCommitting} | ||
> | ||
Delete user | ||
</Button> | ||
</Flex> | ||
</View> | ||
</Dialog> | ||
); | ||
} |
Oops, something went wrong.