From 598d14fc5419e09cfae04117522f62904b5c1c8c Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Fri, 24 Jan 2025 19:34:03 -0800 Subject: [PATCH] improvement: move edit/delete identity buttons to dropdown --- .../IdentityDetailsByIDPage.tsx | 88 +----------------- .../components/IdentityDetailsSection.tsx | 89 ++++++++++++++----- 2 files changed, 70 insertions(+), 107 deletions(-) diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx index aea301642..4ec6b3851 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx @@ -1,21 +1,11 @@ import { Helmet } from "react-helmet"; import { useTranslation } from "react-i18next"; import { useNavigate, useParams } from "@tanstack/react-router"; -import { twMerge } from "tailwind-merge"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; -import { - Button, - DeleteActionModal, - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, - PageHeader, - Tooltip -} from "@app/components/v2"; +import { DeleteActionModal, PageHeader } from "@app/components/v2"; import { ROUTE_PATHS } from "@app/const/routes"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; import { useDeleteIdentity, useGetIdentityById } from "@app/hooks/api"; @@ -85,81 +75,7 @@ const Page = () => {
{data && (
- - - -
- - - -
-
- - - {(isAllowed) => ( - { - handlePopUpOpen("identity", { - identityId, - name: data.identity.name, - role: data.role, - customRole: data.customRole - }); - }} - disabled={!isAllowed} - > - Edit Identity - - )} - - - {(isAllowed) => ( - { - handlePopUpOpen("identityAuthMethod", { - identityId, - name: data.identity.name, - allAuthMethods: data.identity.authMethods - }); - }} - disabled={!isAllowed} - > - Add new auth method - - )} - - - {(isAllowed) => ( - { - handlePopUpOpen("deleteIdentity", { - identityId, - name: data.identity.name - }); - }} - disabled={!isAllowed} - > - Delete Identity - - )} - - -
-
+
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx index eb794a77e..3349a420b 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx @@ -1,8 +1,25 @@ -import { faCheck, faCopy, faKey, faPencil } from "@fortawesome/free-solid-svg-icons"; +import { + faCheck, + faChevronDown, + faCopy, + faEdit, + faKey, + faTrash +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { twMerge } from "tailwind-merge"; import { OrgPermissionCan } from "@app/components/permissions"; -import { IconButton, Tag, Tooltip } from "@app/components/v2"; +import { + Button, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, + IconButton, + Tag, + Tooltip +} from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; import { useTimedReset } from "@app/hooks"; import { useGetIdentityById } from "@app/hooks/api"; @@ -11,7 +28,7 @@ import { UsePopUpState } from "@app/hooks/usePopUp"; type Props = { identityId: string; handlePopUpOpen: ( - popUpName: keyof UsePopUpState<["identity", "identityAuthMethod"]>, + popUpName: keyof UsePopUpState<["identity", "identityAuthMethod", "deleteIdentity"]>, data?: object ) => void; }; @@ -26,31 +43,61 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) =

Identity Details

- - {(isAllowed) => { - return ( - - { + + + + + + + {(isAllowed) => ( + } + onClick={async () => { handlePopUpOpen("identity", { identityId, name: data.identity.name, role: data.role, - customRole: data.customRole, - metadata: data.metadata + customRole: data.customRole }); }} + disabled={!isAllowed} > - - - - ); - }} - + Edit Identity + + )} + + + {(isAllowed) => ( + { + handlePopUpOpen("deleteIdentity", { + identityId, + name: data.identity.name + }); + }} + icon={} + disabled={!isAllowed} + > + Delete Identity + + )} + + +