mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make EntitySettingRegistry fully injectable (#6604)
* Make EntitySettingRegistry fully injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add behavioural tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Revert tsconfig change Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update snapshot Signed-off-by: Sebastian Malton <sebastian@malton.name> * Improve naming Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
8897bfc26b
commit
9589175604
51 files changed
+2103
-540
No files matched your search
+7
-7
@@ -5,15 +5,15 @@
|
||||
|
||||
import React from "react";
|
||||
import { waitFor } from "@testing-library/react";
|
||||
import { ClusterLocalTerminalSetting } from "../cluster-local-terminal-settings";
|
||||
import { ClusterLocalTerminalSetting } from "../local-terminal-settings";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import type { Stats } from "fs";
|
||||
import type { Cluster } from "../../../../../common/cluster/cluster";
|
||||
import { getDiForUnitTesting } from "../../../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../../../test-utils/renderFor";
|
||||
import { renderFor } from "../../../test-utils/renderFor";
|
||||
import showErrorNotificationInjectable from "../../../notifications/show-error-notification.injectable";
|
||||
import statInjectable from "../../../../../common/fs/stat/stat.injectable";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../../test-utils/renderFor";
|
||||
import { renderFor } from "../../test-utils/renderFor";
|
||||
import showErrorNotificationInjectable from "../../notifications/show-error-notification.injectable";
|
||||
import statInjectable from "../../../../common/fs/stat/stat.injectable";
|
||||
|
||||
describe("ClusterLocalTerminalSettings", () => {
|
||||
let render: DiRender;
|
||||
+4
-4
@@ -5,11 +5,11 @@
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import { EditableList } from "../../editable-list";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import { EditableList } from "../editable-list";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
import { systemName } from "../../input/input_validators";
|
||||
import { systemName } from "../input/input_validators";
|
||||
|
||||
export interface ClusterAccessibleNamespacesProps {
|
||||
cluster: Cluster;
|
||||
@@ -1,118 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { KubernetesCluster } from "../../../common/catalog-entities";
|
||||
import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
||||
import type { EntitySettingViewProps } from "../../../extensions/registries";
|
||||
import type { CatalogEntity } from "../../api/catalog-entity";
|
||||
import * as components from "./components";
|
||||
|
||||
function getClusterForEntity(entity: CatalogEntity) {
|
||||
return ClusterStore.getInstance().getById(entity.getId());
|
||||
}
|
||||
|
||||
export function GeneralSettings({ entity }: EntitySettingViewProps) {
|
||||
const cluster = getClusterForEntity(entity);
|
||||
|
||||
if (!cluster) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<section>
|
||||
<div className="flex">
|
||||
<div className="flex-grow pr-8">
|
||||
<components.ClusterNameSetting cluster={cluster} entity={entity as KubernetesCluster} />
|
||||
</div>
|
||||
<div>
|
||||
<components.ClusterIconSetting cluster={cluster} entity={entity as KubernetesCluster} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section className="small">
|
||||
<components.ClusterKubeconfig cluster={cluster} />
|
||||
</section>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProxySettings({ entity }: EntitySettingViewProps) {
|
||||
const cluster = getClusterForEntity(entity);
|
||||
|
||||
if (!cluster) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<components.ClusterProxySetting cluster={cluster} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function TerminalSettings({ entity }: EntitySettingViewProps) {
|
||||
const cluster = getClusterForEntity(entity);
|
||||
|
||||
if (!cluster) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<components.ClusterLocalTerminalSetting cluster={cluster} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function NamespacesSettings({ entity }: EntitySettingViewProps) {
|
||||
const cluster = getClusterForEntity(entity);
|
||||
|
||||
if (!cluster) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<components.ClusterAccessibleNamespaces cluster={cluster} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function MetricsSettings({ entity }: EntitySettingViewProps) {
|
||||
const cluster = getClusterForEntity(entity);
|
||||
|
||||
if (!cluster) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<section>
|
||||
<components.ClusterPrometheusSetting cluster={cluster} />
|
||||
</section>
|
||||
<hr/>
|
||||
<section>
|
||||
<components.ClusterMetricsSetting cluster={cluster} />
|
||||
<components.ShowMetricsSetting cluster={cluster} />
|
||||
</section>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function NodeShellSettings({ entity }: EntitySettingViewProps) {
|
||||
const cluster = getClusterForEntity(entity);
|
||||
|
||||
if(!cluster) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<components.ClusterNodeShellSetting cluster={cluster} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export * from "./cluster-accessible-namespaces";
|
||||
export * from "./cluster-local-terminal-settings";
|
||||
export * from "./cluster-kubeconfig";
|
||||
export * from "./cluster-metrics-setting";
|
||||
export * from "./cluster-name-setting";
|
||||
export * from "./cluster-prometheus-setting";
|
||||
export * from "./cluster-proxy-setting";
|
||||
export * from "./cluster-show-metrics";
|
||||
export * from "./cluster-icon-settings";
|
||||
export * from "./cluster-node-shell-setting";
|
||||
+6
-6
@@ -4,14 +4,14 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { autoBind } from "../../../utils";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { autoBind } from "../../utils";
|
||||
import { observable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { FilePicker, OverSizeLimitStyle } from "../../file-picker";
|
||||
import { MenuActions, MenuItem } from "../../menu";
|
||||
import { Avatar } from "../../avatar";
|
||||
import type { KubernetesCluster } from "../../../common/catalog-entities";
|
||||
import { FilePicker, OverSizeLimitStyle } from "../file-picker";
|
||||
import { MenuActions, MenuItem } from "../menu";
|
||||
import { Avatar } from "../avatar";
|
||||
|
||||
enum GeneralInputStatus {
|
||||
CLEAN = "clean",
|
||||
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export * from "./cluster-settings";
|
||||
+3
-3
@@ -4,11 +4,11 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { observer } from "mobx-react";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import { shell } from "electron";
|
||||
import { Notice } from "../../+extensions/notice";
|
||||
import { Notice } from "../+extensions/notice";
|
||||
|
||||
export interface ClusterKubeconfigProps {
|
||||
cluster: Cluster;
|
||||
+16
-13
@@ -5,20 +5,20 @@
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { Input } from "../../input";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import type { ShowNotification } from "../../notifications";
|
||||
import { Icon } from "../../icon";
|
||||
import { PathPicker } from "../../path-picker";
|
||||
import { isWindows } from "../../../../common/vars";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { Input } from "../input";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import type { ShowNotification } from "../notifications";
|
||||
import { Icon } from "../icon";
|
||||
import { PathPicker } from "../path-picker";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import showErrorNotificationInjectable from "../../notifications/show-error-notification.injectable";
|
||||
import type { ValidateDirectory } from "../../../../common/fs/validate-directory.injectable";
|
||||
import validateDirectoryInjectable from "../../../../common/fs/validate-directory.injectable";
|
||||
import type { ResolveTilde } from "../../../../common/path/resolve-tilde.injectable";
|
||||
import resolveTildeInjectable from "../../../../common/path/resolve-tilde.injectable";
|
||||
import Gutter from "../../gutter/gutter";
|
||||
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
||||
import type { ValidateDirectory } from "../../../common/fs/validate-directory.injectable";
|
||||
import validateDirectoryInjectable from "../../../common/fs/validate-directory.injectable";
|
||||
import type { ResolveTilde } from "../../../common/path/resolve-tilde.injectable";
|
||||
import resolveTildeInjectable from "../../../common/path/resolve-tilde.injectable";
|
||||
import Gutter from "../gutter/gutter";
|
||||
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
|
||||
|
||||
export interface ClusterLocalTerminalSettingProps {
|
||||
cluster: Cluster;
|
||||
@@ -27,6 +27,7 @@ interface Dependencies {
|
||||
showErrorNotification: ShowNotification;
|
||||
validateDirectory: ValidateDirectory;
|
||||
resolveTilde: ResolveTilde;
|
||||
isWindows: boolean;
|
||||
}
|
||||
|
||||
const NonInjectedClusterLocalTerminalSetting = observer(({
|
||||
@@ -34,6 +35,7 @@ const NonInjectedClusterLocalTerminalSetting = observer(({
|
||||
showErrorNotification,
|
||||
validateDirectory,
|
||||
resolveTilde,
|
||||
isWindows,
|
||||
}: Dependencies & ClusterLocalTerminalSettingProps) => {
|
||||
if (!cluster) {
|
||||
return null;
|
||||
@@ -165,5 +167,6 @@ export const ClusterLocalTerminalSetting = withInjectables<Dependencies, Cluster
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
||||
validateDirectory: di.inject(validateDirectoryInjectable),
|
||||
resolveTilde: di.inject(resolveTildeInjectable),
|
||||
isWindows: di.inject(isWindowsInjectable),
|
||||
}),
|
||||
});
|
||||
+6
-6
@@ -5,13 +5,13 @@
|
||||
|
||||
import React from "react";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { onMultiSelectFor, Select } from "../../select/select";
|
||||
import { Icon } from "../../icon/icon";
|
||||
import { Button } from "../../button/button";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { onMultiSelectFor, Select } from "../select/select";
|
||||
import { Icon } from "../icon/icon";
|
||||
import { Button } from "../button/button";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { observable, reaction, makeObservable } from "mobx";
|
||||
import { ClusterMetricsResourceType } from "../../../../common/cluster-types";
|
||||
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
||||
|
||||
export interface ClusterMetricsSettingProps {
|
||||
cluster: Cluster;
|
||||
+5
-5
@@ -4,13 +4,13 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { Input } from "../../input";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { Input } from "../input";
|
||||
import { observable, autorun, makeObservable } from "mobx";
|
||||
import { observer, disposeOnUnmount } from "mobx-react";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import { isRequired } from "../../input/input_validators";
|
||||
import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import { isRequired } from "../input/input_validators";
|
||||
import type { KubernetesCluster } from "../../../common/catalog-entities";
|
||||
|
||||
export interface ClusterNameSettingProps {
|
||||
cluster: Cluster;
|
||||
+6
-6
@@ -3,15 +3,15 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { makeObservable, observable } from "mobx";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import React from "react";
|
||||
import { Input } from "../../input/input";
|
||||
import { Input } from "../input/input";
|
||||
import { observer } from "mobx-react";
|
||||
import { Icon } from "../../icon/icon";
|
||||
import { initialNodeShellImage } from "../../../../common/cluster-types";
|
||||
import Gutter from "../../gutter/gutter";
|
||||
import { Icon } from "../icon/icon";
|
||||
import { initialNodeShellImage } from "../../../common/cluster-types";
|
||||
import Gutter from "../gutter/gutter";
|
||||
|
||||
export interface ClusterNodeShellSettingProps {
|
||||
cluster: Cluster;
|
||||
+9
-9
@@ -5,17 +5,17 @@
|
||||
|
||||
import React from "react";
|
||||
import { observer, disposeOnUnmount } from "mobx-react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import type { SelectOption } from "../../select";
|
||||
import { Select } from "../../select";
|
||||
import { Input } from "../../input";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
import type { SelectOption } from "../select";
|
||||
import { Select } from "../select";
|
||||
import { Input } from "../input";
|
||||
import { observable, computed, autorun, makeObservable } from "mobx";
|
||||
import { Spinner } from "../../spinner";
|
||||
import type { MetricProviderInfo, RequestMetricsProviders } from "../../../../common/k8s-api/endpoints/metrics.api/request-providers.injectable";
|
||||
import { Spinner } from "../spinner";
|
||||
import type { MetricProviderInfo, RequestMetricsProviders } from "../../../common/k8s-api/endpoints/metrics.api/request-providers.injectable";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import requestMetricsProvidersInjectable from "../../../../common/k8s-api/endpoints/metrics.api/request-providers.injectable";
|
||||
import productNameInjectable from "../../../../common/vars/product-name.injectable";
|
||||
import requestMetricsProvidersInjectable from "../../../common/k8s-api/endpoints/metrics.api/request-providers.injectable";
|
||||
import productNameInjectable from "../../../common/vars/product-name.injectable";
|
||||
|
||||
export interface ClusterPrometheusSettingProps {
|
||||
cluster: Cluster;
|
||||
+3
-3
@@ -6,9 +6,9 @@
|
||||
import React from "react";
|
||||
import { observable, autorun, makeObservable } from "mobx";
|
||||
import { observer, disposeOnUnmount } from "mobx-react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { Input, InputValidators } from "../../input";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { Input, InputValidators } from "../input";
|
||||
import { SubTitle } from "../layout/sub-title";
|
||||
|
||||
export interface ClusterProxySettingProps {
|
||||
cluster: Cluster;
|
||||
+4
-4
@@ -5,11 +5,11 @@
|
||||
|
||||
import React from "react";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { observable, reaction, makeObservable } from "mobx";
|
||||
import { Badge } from "../../badge/badge";
|
||||
import { Icon } from "../../icon/icon";
|
||||
import { Notice } from "../../+extensions/notice";
|
||||
import { Badge } from "../badge/badge";
|
||||
import { Icon } from "../icon/icon";
|
||||
import { Notice } from "../+extensions/notice";
|
||||
|
||||
export interface ShowMetricsSettingProps {
|
||||
cluster: Cluster;
|
||||
Reference in new issue
Block a user