mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
remove isClusterAdmin call
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
b171524e49
commit
ed2ba5baf6
@ -1,6 +1,15 @@
|
|||||||
import { configStore } from "../config.store";
|
import { configStore } from "../config.store";
|
||||||
|
import { isArray } from "util";
|
||||||
|
|
||||||
export function isAllowedResource(resource: string) {
|
export function isAllowedResource(resources: string|string[]) {
|
||||||
|
if (!isArray(resources)) {
|
||||||
|
resources = [resources];
|
||||||
|
}
|
||||||
const { allowedResources } = configStore;
|
const { allowedResources } = configStore;
|
||||||
return allowedResources.includes(resource)
|
for (const resource of resources) {
|
||||||
|
if (!allowedResources.includes(resource)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import { PodLogsDialog } from "./+workloads-pods/pod-logs-dialog";
|
|||||||
import { DeploymentScaleDialog } from "./+workloads-deployments/deployment-scale-dialog";
|
import { DeploymentScaleDialog } from "./+workloads-deployments/deployment-scale-dialog";
|
||||||
import { CustomResources } from "./+custom-resources/custom-resources";
|
import { CustomResources } from "./+custom-resources/custom-resources";
|
||||||
import { crdRoute } from "./+custom-resources";
|
import { crdRoute } from "./+custom-resources";
|
||||||
|
import { isAllowedResource } from "../api/rbac";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
@ -46,7 +47,7 @@ class App extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const homeUrl = configStore.isClusterAdmin ? clusterURL() : workloadsURL();
|
const homeUrl = (isAllowedResource(["events", "nodes", "pods"])) ? clusterURL() : workloadsURL();
|
||||||
return (
|
return (
|
||||||
<I18nProvider i18n={_i18n}>
|
<I18nProvider i18n={_i18n}>
|
||||||
<Router history={browserHistory}>
|
<Router history={browserHistory}>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user