Dynamic dashboard UI based on RBAC rules (#366)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2020-06-05 08:38:56 +03:00
1 parent 65900e728d
commit a7cb8d2d04
16 files changed
+213 -97

No files matched your search

@@ -12,6 +12,7 @@ import { Ingresses, ingressRoute, ingressURL } from "../+network-ingresses";
import { NetworkPolicies, networkPoliciesRoute, networkPoliciesURL } from "../+network-policies";
import { namespaceStore } from "../+namespaces/namespace.store";
import { networkURL } from "./network.route";
import { isAllowedResource } from "../../api/rbac";
interface Props extends RouteComponentProps<{}> {
}
@@ -20,32 +21,40 @@ interface Props extends RouteComponentProps<{}> {
export class Network extends React.Component<Props> {
static get tabRoutes(): TabRoute[] {
const query = namespaceStore.getContextParams()
return [
{
const routes: TabRoute[] = [];
if (isAllowedResource("services")) {
routes.push({
title: <Trans>Services</Trans>,
component: Services,
url: servicesURL({ query }),
path: servicesRoute.path,
},
{
})
}
if (isAllowedResource("endpoints")) {
routes.push({
title: <Trans>Endpoints</Trans>,
component: Endpoints,
url: endpointURL({ query }),
path: endpointRoute.path,
},
{
})
}
if (isAllowedResource("ingresses")) {
routes.push({
title: <Trans>Ingresses</Trans>,
component: Ingresses,
url: ingressURL({ query }),
path: ingressRoute.path,
},
{
})
}
if (isAllowedResource("networkpolicies")) {
routes.push({
title: <Trans>Network Policies</Trans>,
component: NetworkPolicies,
url: networkPoliciesURL({ query }),
path: networkPoliciesRoute.path,
},
]
})
}
return routes
}
render() {
@@ -59,4 +68,4 @@ export class Network extends React.Component<Props> {
</MainLayout>
)
}
}
}