parent
c49a5511c7
commit
7f8cb11988
3 changed files with 75 additions and 30 deletions
|
@ -3,6 +3,7 @@
|
||||||
"groupDetails": "Group details",
|
"groupDetails": "Group details",
|
||||||
"childGroups": "Child groups",
|
"childGroups": "Child groups",
|
||||||
"createGroup": "Create group",
|
"createGroup": "Create group",
|
||||||
|
"createChildGroup": "Create child group",
|
||||||
"groupName": "Group name",
|
"groupName": "Group name",
|
||||||
"searchForGroups": "Search for groups",
|
"searchForGroups": "Search for groups",
|
||||||
"searchFor": "Search for:",
|
"searchFor": "Search for:",
|
||||||
|
|
|
@ -29,8 +29,10 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
|
|
||||||
const { adminClient } = useAdminClient();
|
const { adminClient } = useAdminClient();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
|
||||||
const [selectedRows, setSelectedRows] = useState<GroupRepresentation[]>([]);
|
const [selectedRows, setSelectedRows] = useState<GroupRepresentation[]>([]);
|
||||||
|
|
||||||
|
const [rename, setRename] = useState<GroupRepresentation>();
|
||||||
|
const [isCreateModalOpen, toggleCreateOpen] = useToggle();
|
||||||
const [showDelete, toggleShowDelete] = useToggle();
|
const [showDelete, toggleShowDelete] = useToggle();
|
||||||
const [move, setMove] = useState<GroupRepresentation>();
|
const [move, setMove] = useState<GroupRepresentation>();
|
||||||
|
|
||||||
|
@ -99,10 +101,6 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleModalToggle = () => {
|
|
||||||
setIsCreateModalOpen(!isCreateModalOpen);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DeleteGroup
|
<DeleteGroup
|
||||||
|
@ -115,6 +113,39 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
setSelectedRows([]);
|
setSelectedRows([]);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{rename && (
|
||||||
|
<GroupsModal
|
||||||
|
id={rename.id}
|
||||||
|
rename={rename.name}
|
||||||
|
refresh={() => {
|
||||||
|
refresh();
|
||||||
|
viewRefresh();
|
||||||
|
}}
|
||||||
|
handleModalToggle={() => setRename(undefined)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isCreateModalOpen && (
|
||||||
|
<GroupsModal
|
||||||
|
id={selectedRows[0]?.id || id}
|
||||||
|
handleModalToggle={toggleCreateOpen}
|
||||||
|
refresh={() => {
|
||||||
|
setSelectedRows([]);
|
||||||
|
refresh();
|
||||||
|
viewRefresh();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{move && (
|
||||||
|
<MoveDialog
|
||||||
|
source={move}
|
||||||
|
refresh={() => {
|
||||||
|
setMove(undefined);
|
||||||
|
refresh();
|
||||||
|
viewRefresh();
|
||||||
|
}}
|
||||||
|
onClose={() => setMove(undefined)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<KeycloakDataTable
|
<KeycloakDataTable
|
||||||
key={`${id}${key}`}
|
key={`${id}${key}`}
|
||||||
onSelect={(rows) => setSelectedRows([...rows])}
|
onSelect={(rows) => setSelectedRows([...rows])}
|
||||||
|
@ -139,7 +170,7 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
/>
|
/>
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
<GroupToolbar
|
<GroupToolbar
|
||||||
toggleCreate={handleModalToggle}
|
toggleCreate={toggleCreateOpen}
|
||||||
toggleDelete={toggleShowDelete}
|
toggleDelete={toggleShowDelete}
|
||||||
kebabDisabled={selectedRows!.length === 0}
|
kebabDisabled={selectedRows!.length === 0}
|
||||||
/>
|
/>
|
||||||
|
@ -149,6 +180,13 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
!isManager
|
!isManager
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
|
{
|
||||||
|
title: t("rename"),
|
||||||
|
onRowClick: async (group) => {
|
||||||
|
setRename(group);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: t("moveTo"),
|
title: t("moveTo"),
|
||||||
onRowClick: async (group) => {
|
onRowClick: async (group) => {
|
||||||
|
@ -156,6 +194,17 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t("createChildGroup"),
|
||||||
|
onRowClick: async (group) => {
|
||||||
|
setSelectedRows([group]);
|
||||||
|
toggleCreateOpen();
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
isSeparator: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: t("common:delete"),
|
title: t("common:delete"),
|
||||||
onRowClick: async (group: GroupRepresentation) => {
|
onRowClick: async (group: GroupRepresentation) => {
|
||||||
|
@ -181,31 +230,10 @@ export const GroupTable = ({ refresh: viewRefresh }: GroupTableProps) => {
|
||||||
`noGroupsInThis${id ? "SubGroup" : "Realm"}Instructions`
|
`noGroupsInThis${id ? "SubGroup" : "Realm"}Instructions`
|
||||||
)}
|
)}
|
||||||
primaryActionText={t("createGroup")}
|
primaryActionText={t("createGroup")}
|
||||||
onPrimaryAction={handleModalToggle}
|
onPrimaryAction={toggleCreateOpen}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{isCreateModalOpen && (
|
|
||||||
<GroupsModal
|
|
||||||
id={id}
|
|
||||||
handleModalToggle={handleModalToggle}
|
|
||||||
refresh={() => {
|
|
||||||
refresh();
|
|
||||||
viewRefresh();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{move && (
|
|
||||||
<MoveDialog
|
|
||||||
source={move}
|
|
||||||
refresh={() => {
|
|
||||||
setMove(undefined);
|
|
||||||
refresh();
|
|
||||||
viewRefresh();
|
|
||||||
}}
|
|
||||||
onClose={() => setMove(undefined)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
Dropdown,
|
Dropdown,
|
||||||
DropdownItem,
|
DropdownItem,
|
||||||
DropdownPosition,
|
DropdownPosition,
|
||||||
|
DropdownSeparator,
|
||||||
KebabToggle,
|
KebabToggle,
|
||||||
TreeView,
|
TreeView,
|
||||||
TreeViewDataItem,
|
TreeViewDataItem,
|
||||||
|
@ -35,12 +36,23 @@ const GroupTreeContextMenu = ({
|
||||||
const { t } = useTranslation("groups");
|
const { t } = useTranslation("groups");
|
||||||
|
|
||||||
const [isOpen, toggleOpen] = useToggle();
|
const [isOpen, toggleOpen] = useToggle();
|
||||||
|
const [renameOpen, toggleRenameOpen] = useToggle();
|
||||||
const [createOpen, toggleCreateOpen] = useToggle();
|
const [createOpen, toggleCreateOpen] = useToggle();
|
||||||
const [moveOpen, toggleMoveOpen] = useToggle();
|
const [moveOpen, toggleMoveOpen] = useToggle();
|
||||||
const [deleteOpen, toggleDeleteOpen] = useToggle();
|
const [deleteOpen, toggleDeleteOpen] = useToggle();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{renameOpen && (
|
||||||
|
<GroupsModal
|
||||||
|
id={group.id}
|
||||||
|
rename={group.name}
|
||||||
|
refresh={() => {
|
||||||
|
refresh();
|
||||||
|
}}
|
||||||
|
handleModalToggle={toggleRenameOpen}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{createOpen && (
|
{createOpen && (
|
||||||
<GroupsModal
|
<GroupsModal
|
||||||
id={group.id}
|
id={group.id}
|
||||||
|
@ -63,12 +75,16 @@ const GroupTreeContextMenu = ({
|
||||||
isPlain
|
isPlain
|
||||||
position={DropdownPosition.right}
|
position={DropdownPosition.right}
|
||||||
dropdownItems={[
|
dropdownItems={[
|
||||||
<DropdownItem key="create" onClick={toggleCreateOpen}>
|
<DropdownItem key="rename" onClick={toggleRenameOpen}>
|
||||||
{t("createGroup")}
|
{t("rename")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
<DropdownItem key="move" onClick={toggleMoveOpen}>
|
<DropdownItem key="move" onClick={toggleMoveOpen}>
|
||||||
{t("moveTo")}
|
{t("moveTo")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
|
<DropdownItem key="create" onClick={toggleCreateOpen}>
|
||||||
|
{t("createChildGroup")}
|
||||||
|
</DropdownItem>,
|
||||||
|
<DropdownSeparator key="separator" />,
|
||||||
<DropdownItem key="delete" onClick={toggleDeleteOpen}>
|
<DropdownItem key="delete" onClick={toggleDeleteOpen}>
|
||||||
{t("common:delete")}
|
{t("common:delete")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
|
|
Loading…
Reference in a new issue