1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 21:39:40 +02:00
portainer/app/react/kubernetes/more-resources/ClusterRolesView/ClusterRolesView.tsx
Yajith Dayarathna 6d31f4876a fix(more resources): fix porting and functionality [r8s-103] (#8)
Co-authored-by: testA113 <aliharriss1995@gmail.com>
Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io>
Co-authored-by: Ali <83188384+testA113@users.noreply.github.com>
2024-11-12 09:55:30 +13:00

54 lines
1.4 KiB
TypeScript

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>
</>
</>
);
}