mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import { computed } from "mobx";
|
|
import type { TabLayoutRoute } from "../layout/tab-layout";
|
|
import type { IsAllowedResource } from "../../../common/utils/is-allowed-resource.injectable";
|
|
import isAllowedResourceInjectable from "../../../common/utils/is-allowed-resource.injectable";
|
|
import * as routes from "../../../common/routes";
|
|
import { PodSecurityPolicies } from "../+pod-security-policies";
|
|
import { ClusterRoleBindings } from "./+cluster-role-bindings";
|
|
import { ClusterRoles } from "./+cluster-roles";
|
|
import { RoleBindings } from "./+role-bindings";
|
|
import { Roles } from "./+roles";
|
|
import { ServiceAccounts } from "./+service-accounts";
|
|
|
|
interface Dependencies {
|
|
isAllowedResource: IsAllowedResource;
|
|
}
|
|
|
|
function getRouteTabs({ isAllowedResource }: Dependencies) {
|
|
return computed(() => {
|
|
const tabs: TabLayoutRoute[] = [];
|
|
|
|
if (isAllowedResource("serviceaccounts")) {
|
|
tabs.push({
|
|
title: "Service Accounts",
|
|
component: ServiceAccounts,
|
|
url: routes.serviceAccountsURL(),
|
|
routePath: routes.serviceAccountsRoute.path.toString(),
|
|
});
|
|
}
|
|
|
|
if (isAllowedResource("clusterroles")) {
|
|
tabs.push({
|
|
title: "Cluster Roles",
|
|
component: ClusterRoles,
|
|
url: routes.clusterRolesURL(),
|
|
routePath: routes.clusterRolesRoute.path.toString(),
|
|
});
|
|
}
|
|
|
|
if (isAllowedResource("roles")) {
|
|
tabs.push({
|
|
title: "Roles",
|
|
component: Roles,
|
|
url: routes.rolesURL(),
|
|
routePath: routes.rolesRoute.path.toString(),
|
|
});
|
|
}
|
|
|
|
if (isAllowedResource("clusterrolebindings")) {
|
|
tabs.push({
|
|
title: "Cluster Role Bindings",
|
|
component: ClusterRoleBindings,
|
|
url: routes.clusterRoleBindingsURL(),
|
|
routePath: routes.clusterRoleBindingsRoute.path.toString(),
|
|
});
|
|
}
|
|
|
|
if (isAllowedResource("rolebindings")) {
|
|
tabs.push({
|
|
title: "Role Bindings",
|
|
component: RoleBindings,
|
|
url: routes.roleBindingsURL(),
|
|
routePath: routes.roleBindingsRoute.path.toString(),
|
|
});
|
|
}
|
|
|
|
if (isAllowedResource("podsecuritypolicies")) {
|
|
tabs.push({
|
|
title: "Pod Security Policies",
|
|
component: PodSecurityPolicies,
|
|
url: routes.podSecurityPoliciesURL(),
|
|
routePath: routes.podSecurityPoliciesRoute.path.toString(),
|
|
});
|
|
}
|
|
|
|
return tabs;
|
|
});
|
|
}
|
|
|
|
const userManagementRouteTabsInjectable = getInjectable({
|
|
id: "user-management-route-tabs",
|
|
|
|
instantiate: (di) => getRouteTabs({
|
|
isAllowedResource: di.inject(isAllowedResourceInjectable),
|
|
}),
|
|
});
|
|
|
|
export default userManagementRouteTabsInjectable;
|