From 932a92a31688e08a95e174c99e6cc15fcf2cfa14 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 9 Jul 2024 13:44:34 +0200 Subject: [PATCH] don't lazy load when searching (#31100) fixes: #31070 Signed-off-by: Erik Jan de Wit --- .../src/groups/components/GroupTree.tsx | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/js/apps/admin-ui/src/groups/components/GroupTree.tsx b/js/apps/admin-ui/src/groups/components/GroupTree.tsx index 9b68602190..7d8e0ac40b 100644 --- a/js/apps/admin-ui/src/groups/components/GroupTree.tsx +++ b/js/apps/admin-ui/src/groups/components/GroupTree.tsx @@ -147,6 +147,21 @@ type GroupTreeProps = { const SUBGROUP_COUNT = 50; +const TreeLoading = () => { + const { t } = useTranslation(); + return ( + <> + {t("spinnerLoading")} + + ); +}; + +const LOADING_TREE = [ + { + name: , + }, +]; + export const GroupTree = ({ refresh: viewRefresh, canViewDetails, @@ -183,6 +198,7 @@ export const GroupTree = ({ group: GroupRepresentation, refresh: () => void, ): ExtendedTreeViewDataItem => { + const hasSubGroups = group.subGroupCount; return { id: group.id, name: ( @@ -191,16 +207,10 @@ export const GroupTree = ({ ), access: group.access || {}, - children: group.subGroupCount - ? [ - { - name: ( - <> - {t("spinnerLoading")} - - ), - }, - ] + children: hasSubGroups + ? search.length === 0 + ? LOADING_TREE + : group.subGroups?.map((g) => mapGroup(g, refresh)) : undefined, action: (hasAccess("manage-users") || group.access?.manage) && (