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:
parent
dbce47bef4
commit
78ab689a10
@ -1,41 +1,36 @@
|
||||
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 { 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>[] = [
|
||||
{ value: "", label: "Auto detect" },
|
||||
{ value: "", label: "Auto detect" },
|
||||
...prometheusProviders.map(pp => ({value: pp.id, label: pp.name}))
|
||||
];
|
||||
|
||||
interface Props {
|
||||
cluster: Cluster;
|
||||
cluster: Cluster;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class ClusterPrometheusSetting extends React.Component<Props> {
|
||||
@observable prometheusProvider = this.props.cluster.preferences.prometheusProvider?.type || "";
|
||||
|
||||
render() {
|
||||
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>
|
||||
<Select
|
||||
value={this.prometheusProvider}
|
||||
options={options}
|
||||
onChange={this.changePrometheusProvider}
|
||||
/>
|
||||
</>;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
changePrometheusProvider({ value: prometheusProvider }: SelectProps<string>) {
|
||||
this.prometheusProvider = prometheusProvider;
|
||||
this.props.cluster.preferences.prometheusProvider = { type: prometheusProvider };
|
||||
return (
|
||||
<>
|
||||
<SubTitle title="Prometheus"/>
|
||||
<p>
|
||||
Use pre-installed Prometheus service for metrics. Please refer to the{" "}
|
||||
<a href="https://github.com/lensapp/lens/blob/master/troubleshooting/custom-prometheus.md" target="_blank">guide</a>{" "}
|
||||
for possible configuration changes.
|
||||
</p>
|
||||
<Select
|
||||
value={this.props.cluster.preferences.prometheusProvider?.type}
|
||||
onChange={({type}) => this.props.cluster.preferences.prometheusProvider = { type }}
|
||||
options={options}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user