mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Only show the UserManagement tab in the sidebar if the sub menus are allowed for that cluster (#2258)
- Optimize Cluster.isAllowedResource Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
c0dddc0f40
commit
47e5cb1732
5 files changed
+71
-41
No files matched your search
@@ -13,29 +13,37 @@ import { isAllowedResource } from "../../../common/rbac";
|
||||
@observer
|
||||
export class UserManagement extends React.Component {
|
||||
static get tabRoutes() {
|
||||
const tabRoutes: TabLayoutRoute[] = [];
|
||||
const query = namespaceUrlParam.toObjectParam();
|
||||
const tabRoutes: TabLayoutRoute[] = [];
|
||||
|
||||
tabRoutes.push(
|
||||
{
|
||||
if (isAllowedResource("serviceaccounts")) {
|
||||
tabRoutes.push({
|
||||
title: "Service Accounts",
|
||||
component: ServiceAccounts,
|
||||
url: serviceAccountsURL({ query }),
|
||||
routePath: serviceAccountsRoute.path.toString(),
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
if (isAllowedResource("rolebindings") || isAllowedResource("clusterrolebindings")) {
|
||||
// TODO: seperate out these two pages
|
||||
tabRoutes.push({
|
||||
title: "Role Bindings",
|
||||
component: RoleBindings,
|
||||
url: roleBindingsURL({ query }),
|
||||
routePath: roleBindingsRoute.path.toString(),
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
if (isAllowedResource("roles") || isAllowedResource("clusterroles")) {
|
||||
// TODO: seperate out these two pages
|
||||
tabRoutes.push({
|
||||
title: "Roles",
|
||||
component: Roles,
|
||||
url: rolesURL({ query }),
|
||||
routePath: rolesRoute.path.toString(),
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (isAllowedResource("podsecuritypolicies")) {
|
||||
tabRoutes.push({
|
||||
|
||||
@@ -257,6 +257,7 @@ export class Sidebar extends React.Component<Props> {
|
||||
id="users"
|
||||
text="Access Control"
|
||||
isActive={isActiveRoute(usersManagementRoute)}
|
||||
isHidden={UserManagement.tabRoutes.length === 0}
|
||||
url={usersManagementURL({ query })}
|
||||
icon={<Icon material="security"/>}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user