mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
|
import { computed } from "mobx";
|
|
import hostedClusterInjectable from "./hosted-cluster.injectable";
|
|
import { shouldShowResourceInjectionToken } from "../../common/cluster-store/allowed-resources-injection-token";
|
|
import type { KubeApiResourceDescriptor } from "../../common/rbac";
|
|
import { formatKubeApiResource } from "../../common/rbac";
|
|
|
|
const shouldShowResourceInjectable = getInjectable({
|
|
id: "should-show-resource",
|
|
instantiate: (di, resource) => {
|
|
const cluster = di.inject(hostedClusterInjectable);
|
|
|
|
return cluster
|
|
? computed(() => cluster.shouldShowResource(resource))
|
|
: computed(() => false);
|
|
},
|
|
injectionToken: shouldShowResourceInjectionToken,
|
|
lifecycle: lifecycleEnum.keyedSingleton({
|
|
getInstanceKey: (di, resource: KubeApiResourceDescriptor) => formatKubeApiResource(resource),
|
|
}),
|
|
});
|
|
|
|
export default shouldShowResourceInjectable;
|