From 7f8cb11988bfec9fd44988633132b8ba188db6f4 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 1 Nov 2022 13:23:57 +0100 Subject: [PATCH] added more options in the context menu (#3676) fixes: #3607 --- apps/admin-ui/public/resources/en/groups.json | 1 + apps/admin-ui/src/groups/GroupTable.tsx | 84 ++++++++++++------- .../src/groups/components/GroupTree.tsx | 20 ++++- 3 files changed, 75 insertions(+), 30 deletions(-) diff --git a/apps/admin-ui/public/resources/en/groups.json b/apps/admin-ui/public/resources/en/groups.json index ba7d63d2b8..42e1276a53 100644 --- a/apps/admin-ui/public/resources/en/groups.json +++ b/apps/admin-ui/public/resources/en/groups.json @@ -3,6 +3,7 @@ "groupDetails": "Group details", "childGroups": "Child groups", "createGroup": "Create group", + "createChildGroup": "Create child group", "groupName": "Group name", "searchForGroups": "Search for groups", "searchFor": "Search for:", diff --git a/apps/admin-ui/src/groups/GroupTable.tsx b/apps/admin-ui/src/groups/GroupTable.tsx index ddde798370..e8a36bd872 100644 --- a/apps/admin-ui/src/groups/GroupTable.tsx +++ b/apps/admin-ui/src/groups/GroupTable.tsx @@ -29,8 +29,10 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => { const { adminClient } = useAdminClient(); const { realm } = useRealm(); - const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [selectedRows, setSelectedRows] = useState([]); + + const [rename, setRename] = useState(); + const [isCreateModalOpen, toggleCreateOpen] = useToggle(); const [showDelete, toggleShowDelete] = useToggle(); const [move, setMove] = useState(); @@ -99,10 +101,6 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => { ); }; - const handleModalToggle = () => { - setIsCreateModalOpen(!isCreateModalOpen); - }; - return ( <> { setSelectedRows([]); }} /> + {rename && ( + { + refresh(); + viewRefresh(); + }} + handleModalToggle={() => setRename(undefined)} + /> + )} + {isCreateModalOpen && ( + { + setSelectedRows([]); + refresh(); + viewRefresh(); + }} + /> + )} + {move && ( + { + setMove(undefined); + refresh(); + viewRefresh(); + }} + onClose={() => setMove(undefined)} + /> + )} setSelectedRows([...rows])} @@ -139,7 +170,7 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => { /> @@ -149,6 +180,13 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => { !isManager ? [] : [ + { + title: t("rename"), + onRowClick: async (group) => { + setRename(group); + return false; + }, + }, { title: t("moveTo"), onRowClick: async (group) => { @@ -156,6 +194,17 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => { return false; }, }, + { + title: t("createChildGroup"), + onRowClick: async (group) => { + setSelectedRows([group]); + toggleCreateOpen(); + return false; + }, + }, + { + isSeparator: true, + }, { title: t("common:delete"), onRowClick: async (group: GroupRepresentation) => { @@ -181,31 +230,10 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => { `noGroupsInThis${id ? "SubGroup" : "Realm"}Instructions` )} primaryActionText={t("createGroup")} - onPrimaryAction={handleModalToggle} + onPrimaryAction={toggleCreateOpen} /> } /> - {isCreateModalOpen && ( - { - refresh(); - viewRefresh(); - }} - /> - )} - {move && ( - { - setMove(undefined); - refresh(); - viewRefresh(); - }} - onClose={() => setMove(undefined)} - /> - )} ); }; diff --git a/apps/admin-ui/src/groups/components/GroupTree.tsx b/apps/admin-ui/src/groups/components/GroupTree.tsx index 5176ed8528..d864939129 100644 --- a/apps/admin-ui/src/groups/components/GroupTree.tsx +++ b/apps/admin-ui/src/groups/components/GroupTree.tsx @@ -5,6 +5,7 @@ import { Dropdown, DropdownItem, DropdownPosition, + DropdownSeparator, KebabToggle, TreeView, TreeViewDataItem, @@ -35,12 +36,23 @@ const GroupTreeContextMenu = ({ const { t } = useTranslation("groups"); const [isOpen, toggleOpen] = useToggle(); + const [renameOpen, toggleRenameOpen] = useToggle(); const [createOpen, toggleCreateOpen] = useToggle(); const [moveOpen, toggleMoveOpen] = useToggle(); const [deleteOpen, toggleDeleteOpen] = useToggle(); return ( <> + {renameOpen && ( + { + refresh(); + }} + handleModalToggle={toggleRenameOpen} + /> + )} {createOpen && ( - {t("createGroup")} + + {t("rename")} , {t("moveTo")} , + + {t("createChildGroup")} + , + , {t("common:delete")} ,