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

ClusterPrometheusSetting refactoring

Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This commit is contained in:
alexfront 2020-08-05 17:26:32 +03:00
parent dbce47bef4
commit 78ab689a10

View File

@ -1,41 +1,36 @@
import React from "react"; import React from "react";
import { Cluster } from "../../../../main/cluster";
import { clusterStore } from "../../../../common/cluster-store"
import { Select, SelectOption, SelectProps } from "../../select";
import { prometheusProviders } from "../../../../common/prometheus-providers";
import { autobind } from "../../../utils";
import { observable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { prometheusProviders } from "../../../../common/prometheus-providers";
import { Cluster } from "../../../../main/cluster";
import { SubTitle } from "../../layout/sub-title";
import { Select, SelectOption } from "../../select";
const prometheusGuide = "https://github.com/lensapp/lens/blob/master/troubleshooting/custom-prometheus.md";
const options: SelectOption<string>[] = [ const options: SelectOption<string>[] = [
{ value: "", label: "Auto detect" }, { value: "", label: "Auto detect" },
...prometheusProviders.map(pp => ({value: pp.id, label: pp.name})) ...prometheusProviders.map(pp => ({value: pp.id, label: pp.name}))
]; ];
interface Props { interface Props {
cluster: Cluster; cluster: Cluster;
} }
@observer @observer
export class ClusterPrometheusSetting extends React.Component<Props> { export class ClusterPrometheusSetting extends React.Component<Props> {
@observable prometheusProvider = this.props.cluster.preferences.prometheusProvider?.type || "";
render() { render() {
return <> return (
<h4>Cluster Prometheus</h4> <>
<p>Use pre-installed Prometheus service for metrics. Please refer to <a href={prometheusGuide}>this guide</a> for possible configuration changes.</p> <SubTitle title="Prometheus"/>
<Select <p>
value={this.prometheusProvider} Use pre-installed Prometheus service for metrics. Please refer to the{" "}
options={options} <a href="https://github.com/lensapp/lens/blob/master/troubleshooting/custom-prometheus.md" target="_blank">guide</a>{" "}
onChange={this.changePrometheusProvider} for possible configuration changes.
/> </p>
</>; <Select
} value={this.props.cluster.preferences.prometheusProvider?.type}
onChange={({type}) => this.props.cluster.preferences.prometheusProvider = { type }}
@autobind() options={options}
changePrometheusProvider({ value: prometheusProvider }: SelectProps<string>) { />
this.prometheusProvider = prometheusProvider; </>
this.props.cluster.preferences.prometheusProvider = { type: prometheusProvider }; );
} }
} }