fix(usage): display usage tabs base on access permissions

This commit is contained in:
jialin
2026-06-24 11:26:40 +08:00
committed by jialin
parent 3052c0b23e
commit 22e5cc3aa5
2 changed files with 9 additions and 2 deletions
+8 -1
View File
@@ -25,7 +25,8 @@ import TokenTab from './token-tab';
const Usage: React.FC = () => {
const access = useAccess();
const intl = useIntl();
// Land on the cross-resource Summary by default.
const canSeeGpuService = !!access?.canSeeGpuService;
const [activeKey, setActiveKey] = useState<string>('summary');
const items: TabsProps['items'] = useMemo(() => {
@@ -69,6 +70,12 @@ const Usage: React.FC = () => {
});
}, [intl, access.canSeeGpuService]);
// Only the Tokens tab is available — render it on its own without the
// single-item tab bar.
if (!canSeeGpuService) {
return <TokenTab />;
}
return (
<Tabs
activeKey={activeKey}
+1 -1
View File
@@ -103,7 +103,7 @@ export const probeAccessFlags = async (): Promise<{
probeHasKubernetesCluster(),
probeHasResourceEvents()
]);
return { hasKubernetesCluster: false, hasResourceEvents: false };
return { hasKubernetesCluster, hasResourceEvents };
};
// Module-scoped marker for "did `getInitialState` actually run the access