1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+entity-settings/internal-kubernetes-cluster/proxy-settings.injectable.tsx
Sebastian Malton a0a9fc5e4a Add behavioural tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-11-28 12:11:43 -05:00

56 lines
1.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 { withInjectables } from "@ogre-tools/injectable-react";
import React from "react";
import type { GetClusterById } from "../../../../common/cluster-store/get-by-id.injectable";
import getClusterByIdInjectable from "../../../../common/cluster-store/get-by-id.injectable";
import { ClusterProxySetting } from "../../cluster-settings/proxy-setting";
import type { EntitySettingViewProps } from "../extension-registrator.injectable";
import { entitySettingInjectionToken } from "../token";
interface Dependencies {
getClusterById: GetClusterById;
}
function NonInjectedProxyKubernetesClusterSettings({ entity, getClusterById }: EntitySettingViewProps & Dependencies) {
const cluster = getClusterById(entity.getId());
if (!cluster) {
return null;
}
return (
<section>
<ClusterProxySetting cluster={cluster} />
</section>
);
}
const ProxyKubernetesClusterSettings = withInjectables<Dependencies, EntitySettingViewProps>(NonInjectedProxyKubernetesClusterSettings, {
getProps: (di, props) => ({
...props,
getClusterById: di.inject(getClusterByIdInjectable),
}),
});
const proxyKubernetesClusterEntitySettingsInjectable = getInjectable({
id: "proxy-kubernetes-cluster-entity-settings",
instantiate: () => ({
apiVersions: new Set(["entity.k8slens.dev/v1alpha1"]),
kind: "KubernetesCluster",
title: "Proxy",
group: "Settings",
id: "proxy",
orderNumber: 10,
components: {
View: ProxyKubernetesClusterSettings,
},
}),
injectionToken: entitySettingInjectionToken,
});
export default proxyKubernetesClusterEntitySettingsInjectable;