1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Less hardcoded values

Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
Piotr Roszatycki 2023-10-22 11:50:38 +02:00
parent 4ff49bdbd7
commit dbad7bbdc9
3 changed files with 10 additions and 3 deletions

View File

@ -175,6 +175,11 @@ export enum ClusterMetricsResourceType {
Namespace = "Namespace", Namespace = "Namespace",
} }
/**
* The default filesystem mountpoints for metrics
*/
export const initialFilesystemMountpoints = "/";
/** /**
* The default node shell image * The default node shell image
*/ */

View File

@ -6,7 +6,7 @@
import { apiPrefix } from "../../../common/vars"; import { apiPrefix } from "../../../common/vars";
import { getRouteInjectable } from "../../router/router.injectable"; import { getRouteInjectable } from "../../router/router.injectable";
import type { ClusterPrometheusMetadata } from "../../../common/cluster-types"; import type { ClusterPrometheusMetadata } from "../../../common/cluster-types";
import { ClusterMetadataKey } from "../../../common/cluster-types"; import { ClusterMetadataKey, initialFilesystemMountpoints } from "../../../common/cluster-types";
import type { Cluster } from "../../../common/cluster/cluster"; import type { Cluster } from "../../../common/cluster/cluster";
import { clusterRoute } from "../../router/route"; import { clusterRoute } from "../../router/route";
import { isObject } from "lodash"; import { isObject } from "lodash";
@ -69,7 +69,7 @@ const addMetricsRouteInjectable = getRouteInjectable({
const queryParams: Partial<Record<string, string>> = Object.fromEntries(query.entries()); const queryParams: Partial<Record<string, string>> = Object.fromEntries(query.entries());
const prometheusMetadata: ClusterPrometheusMetadata = {}; const prometheusMetadata: ClusterPrometheusMetadata = {};
const prometheusHandler = di.inject(prometheusHandlerInjectable, cluster); const prometheusHandler = di.inject(prometheusHandlerInjectable, cluster);
const mountpoints = cluster.preferences.filesystemMountpoints || "/"; const mountpoints = cluster.preferences.filesystemMountpoints || initialFilesystemMountpoints;
try { try {
const { prometheusPath, provider } = await prometheusHandler.getPrometheusDetails(); const { prometheusPath, provider } = await prometheusHandler.getPrometheusDetails();

View File

@ -6,6 +6,7 @@
import React from "react"; import React from "react";
import { observer, disposeOnUnmount } from "mobx-react"; import { observer, disposeOnUnmount } from "mobx-react";
import type { Cluster } from "../../../common/cluster/cluster"; import type { Cluster } from "../../../common/cluster/cluster";
import { initialFilesystemMountpoints } from "../../../common/cluster-types";
import { SubTitle } from "../layout/sub-title"; import { SubTitle } from "../layout/sub-title";
import type { SelectOption } from "../select"; import type { SelectOption } from "../select";
import { Select } from "../select"; import { Select } from "../select";
@ -36,6 +37,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
@observable path = ""; @observable path = "";
@observable selectedOption: ProviderValue = autoDetectPrometheus; @observable selectedOption: ProviderValue = autoDetectPrometheus;
@observable loading = true; @observable loading = true;
readonly initialFilesystemMountpoints = initialFilesystemMountpoints;
readonly loadedOptions = observable.map<string, MetricProviderInfo>(); readonly loadedOptions = observable.map<string, MetricProviderInfo>();
@computed get options(): SelectOption<ProviderValue>[] { @computed get options(): SelectOption<ProviderValue>[] {
@ -183,7 +185,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
value={this.mountpoints} value={this.mountpoints}
onChange={(value) => this.mountpoints = value} onChange={(value) => this.mountpoints = value}
onBlur={this.onSaveMountpoints} onBlur={this.onSaveMountpoints}
placeholder="/" placeholder={this.initialFilesystemMountpoints}
/> />
<small className="hint"> <small className="hint">
{`A regexp for the label with the filesystem mountpoints that will create a graph for disk usage. For the root disk only use "/" and for all disks use ".*".`} {`A regexp for the label with the filesystem mountpoints that will create a graph for disk usage. For the root disk only use "/" and for all disks use ".*".`}