don't lazy load when searching (#31100)

fixes: #31070

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-07-09 13:44:34 +02:00 committed by GitHub
parent 2dc37d2513
commit 932a92a316
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -147,6 +147,21 @@ type GroupTreeProps = {
const SUBGROUP_COUNT = 50;
const TreeLoading = () => {
const { t } = useTranslation();
return (
<>
<Spinner size="sm" /> {t("spinnerLoading")}
</>
);
};
const LOADING_TREE = [
{
name: <TreeLoading />,
},
];
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 = ({
</Tooltip>
),
access: group.access || {},
children: group.subGroupCount
? [
{
name: (
<>
<Spinner size="sm" /> {t("spinnerLoading")}
</>
),
},
]
children: hasSubGroups
? search.length === 0
? LOADING_TREE
: group.subGroups?.map((g) => mapGroup(g, refresh))
: undefined,
action: (hasAccess("manage-users") || group.access?.manage) && (
<GroupTreeContextMenu group={group} refresh={refresh} />