From ce26a06129879a7af0c7629b02103f89479a61a7 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Thu, 18 Jul 2024 17:12:02 +0700 Subject: [PATCH] role table restyle --- .../IdentitySection/IdentitySection.tsx | 2 +- .../OrgRoleTabSection/OrgRoleTable.tsx | 130 ++++++++++-------- 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx index f08196df6..d7134dfee 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx @@ -68,7 +68,7 @@ export const IdentitySection = withPermission( }; return ( -
+

Identities

diff --git a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx index b4e08f51a..8046dd948 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx @@ -1,14 +1,16 @@ -import { useState } from "react"; -import { faEdit, faMagnifyingGlass, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; +import { faEllipsis,faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, - IconButton, - Input, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, Table, TableContainer, TableSkeleton, @@ -28,11 +30,12 @@ type Props = { }; export const OrgRoleTable = ({ onSelectRole }: Props) => { - const [searchRoles, setSearchRoles] = useState(""); const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; - const { popUp, handlePopUpOpen, handlePopUpClose } = usePopUp(["deleteRole"] as const); + const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ + "deleteRole" + ] as const); const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(orgId); @@ -54,50 +57,52 @@ export const OrgRoleTable = ({ onSelectRole }: Props) => { }; return ( -
-
-
- setSearchRoles(e.target.value)} - leftIcon={} - placeholder="Search roles..." - /> -
+
+
+

Organization Roles

{(isAllowed) => ( )}
-
- - - - - - - - - - {isRolesLoading && } - {roles?.map((role) => { - const { id, name, slug } = role; - const isNonMutatable = ["owner", "admin", "member", "no-access"].includes(slug); - - return ( - - - - + + ); + })} + +
NameSlug -
{name}{slug} -
+ + + + + + + + + + {isRolesLoading && } + {roles?.map((role) => { + const { id, name, slug } = role; + const isNonMutatable = ["owner", "admin", "member", "no-access"].includes(slug); + return ( + + + + - - ); - })} - -
NameSlug +
{name}{slug} + + +
+ +
+
+ { allowedLabel="Edit" > {(isAllowed) => ( - onSelectRole(role)} - variant="plain" + disabled={!isAllowed} > - - + Edit Role + )} { } > {(isAllowed) => ( - handlePopUpOpen("deleteRole", role)} - variant="plain" - isDisabled={isNonMutatable || !isAllowed} + disabled={!isAllowed} > - - + Delete Role + )} - -
-
-
+ + +
+
handlePopUpToggle("deleteRole", isOpen)} deleteKey={(popUp?.deleteRole?.data as TOrgRole)?.slug || ""} onClose={() => handlePopUpClose("deleteRole")} onDeleteApproved={handleRoleDelete}