mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce fix for metrics components visible on all details
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
01f66c4d41
commit
026053db1e
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* 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 type { ClusterMetricsResourceType } from "../../../../common/cluster-types";
|
||||||
|
import currentKubeObjectInDetailsInjectable from "../../../components/kube-object-details/current-kube-object-in-details.injectable";
|
||||||
|
import enabledMetricsInjectable from "./metrics-enabled.injectable";
|
||||||
|
|
||||||
|
const metricsDetailsComponentEnabledInjectable = getInjectable({
|
||||||
|
id: "metrics-details-component-enabled",
|
||||||
|
instantiate: (di, kind) => {
|
||||||
|
const metricsEnabled = di.inject(enabledMetricsInjectable, kind);
|
||||||
|
const currentKubeObjectInDetails = di.inject(currentKubeObjectInDetailsInjectable);
|
||||||
|
|
||||||
|
return computed(() => {
|
||||||
|
const current = currentKubeObjectInDetails.value.get();
|
||||||
|
|
||||||
|
if (!current?.object) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return current.object.kind == kind && metricsEnabled.get();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
lifecycle: lifecycleEnum.keyedSingleton({
|
||||||
|
getInstanceKey: (di, kind: ClusterMetricsResourceType) => kind,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default metricsDetailsComponentEnabledInjectable;
|
||||||
@ -12,7 +12,7 @@ const enabledMetricsInjectable = getInjectable({
|
|||||||
instantiate: (di, kind) => {
|
instantiate: (di, kind) => {
|
||||||
const getActiveClusterEntity = di.inject(getActiveClusterEntityInjectable);
|
const getActiveClusterEntity = di.inject(getActiveClusterEntityInjectable);
|
||||||
|
|
||||||
return computed(() => !getActiveClusterEntity()?.isMetricsHidden(kind));
|
return computed(() => !getActiveClusterEntity()?.isMetricHidden(kind));
|
||||||
},
|
},
|
||||||
lifecycle: lifecycleEnum.keyedSingleton({
|
lifecycle: lifecycleEnum.keyedSingleton({
|
||||||
getInstanceKey: (di, kind: ClusterMetricsResourceType) => kind,
|
getInstanceKey: (di, kind: ClusterMetricsResourceType) => kind,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user