From 2b58ce4d5e1e11a1ef259ae0bada093cb7d0db81 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 2 Nov 2024 18:35:41 +0100 Subject: [PATCH] Hide default group if no VM is in this group --- virtweb_frontend/src/routes/VMListRoute.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/virtweb_frontend/src/routes/VMListRoute.tsx b/virtweb_frontend/src/routes/VMListRoute.tsx index ccb788a..7f9c44c 100644 --- a/virtweb_frontend/src/routes/VMListRoute.tsx +++ b/virtweb_frontend/src/routes/VMListRoute.tsx @@ -31,8 +31,13 @@ export function VMListRoute(): React.ReactElement { const loadKey = React.useRef(1); const load = async () => { - setGroups([undefined, ...(await GroupApi.GetList())]); - setList(await VMApi.GetList()); + const groups: Array = await GroupApi.GetList(); + const list = await VMApi.GetList(); + + if (list.find((v) => !v.group) !== undefined) groups.push(undefined); + + setGroups(groups); + setList(list); }; const reload = () => {