From 5bf914d1f2f9dfa65dff774d1d59960e83562ee0 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 6 Dec 2024 19:02:21 +0100 Subject: [PATCH] Show only relevant tabs --- remote_frontend/src/App.tsx | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/remote_frontend/src/App.tsx b/remote_frontend/src/App.tsx index a8951d7..9d5ebd5 100644 --- a/remote_frontend/src/App.tsx +++ b/remote_frontend/src/App.tsx @@ -59,6 +59,10 @@ function AuthenticatedApp(): React.ReactElement { const load = async () => { setRights(await ServerApi.GetRights()); + + if (rights!.groups.length > 0) setTab("group"); + else if (rights!.vms.length > 0) setTab("vm"); + else setTab("info"); }; return ( @@ -87,27 +91,21 @@ function AuthenticatedApp(): React.ReactElement { selectedValue={tab} onTabSelect={(_, d) => setTab(d.value as any)} > - } - disabled={rights!.groups.length === 0} - > - Groups - - } - disabled={rights!.vms.length === 0} - > - Virtual machines - - } - disabled={!rights!.sys_info} - > - System info - + {rights!.groups.length > 0 && ( + }> + Groups + + )} + {rights!.vms.length > 0 && ( + }> + Virtual machines + + )} + {rights!.sys_info && ( + }> + System info + + )}