You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/kubernetes/more-resources/ClusterRolesView/ClusterRolesView.tsx

55 lines
1.4 KiB

import { UserCheck, Link } from 'lucide-react';
import { useCurrentStateAndParams } from '@uirouter/react';
import { useUnauthorizedRedirect } from '@/react/hooks/useUnauthorizedRedirect';
import { PageHeader } from '@@/PageHeader';
import { Tab, WidgetTabs, findSelectedTabIndex } from '@@/Widget/WidgetTabs';
import { ClusterRolesDatatable } from './ClusterRolesDatatable/ClusterRolesDatatable';
import { ClusterRoleBindingsDatatable } from './ClusterRoleBindingsDatatable/ClusterRoleBindingsDatatable';
export function ClusterRolesView() {
useUnauthorizedRedirect(
{
authorizations: ['K8sClusterRoleBindingsW', 'K8sClusterRolesW'],
adminOnlyCE: true,
},
{ to: 'kubernetes.dashboard' }
);
const tabs: Tab[] = [
{
name: 'Cluster Roles',
icon: UserCheck,
widget: <ClusterRolesDatatable />,
selectedTabParam: 'clusterRoles',
},
{
name: 'Cluster Role Bindings',
icon: Link,
widget: <ClusterRoleBindingsDatatable />,
selectedTabParam: 'clusterRoleBindings',
},
];
const currentTabIndex = findSelectedTabIndex(
useCurrentStateAndParams(),
tabs
);
return (
<>
<PageHeader
title="Cluster Role list"
breadcrumbs="Cluster Roles"
reload
/>
<>
<WidgetTabs tabs={tabs} currentTabIndex={currentTabIndex} />
<div className="content">{tabs[currentTabIndex].widget}</div>
</>
</>
);
}