mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refresh input values on cluster change (#814)
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
653683c802
commit
a4eff11ee2
@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observable } from "mobx";
|
import { observable, autorun } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer, disposeOnUnmount } from "mobx-react";
|
||||||
import { Cluster } from "../../../../main/cluster";
|
import { Cluster } from "../../../../main/cluster";
|
||||||
import { Input } from "../../input";
|
import { Input } from "../../input";
|
||||||
import { SubTitle } from "../../layout/sub-title";
|
import { SubTitle } from "../../layout/sub-title";
|
||||||
@ -11,7 +11,15 @@ interface Props {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClusterHomeDirSetting extends React.Component<Props> {
|
export class ClusterHomeDirSetting extends React.Component<Props> {
|
||||||
@observable directory = this.props.cluster.preferences.terminalCWD || "";
|
@observable directory = "";
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
disposeOnUnmount(this,
|
||||||
|
autorun(() => {
|
||||||
|
this.directory = this.props.cluster.preferences.terminalCWD || "";
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
save = () => {
|
save = () => {
|
||||||
this.props.cluster.preferences.terminalCWD = this.directory;
|
this.props.cluster.preferences.terminalCWD = this.directory;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Cluster } from "../../../../main/cluster";
|
import { Cluster } from "../../../../main/cluster";
|
||||||
import { Input } from "../../input";
|
import { Input } from "../../input";
|
||||||
import { observable } from "mobx";
|
import { observable, autorun } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer, disposeOnUnmount } from "mobx-react";
|
||||||
import { SubTitle } from "../../layout/sub-title";
|
import { SubTitle } from "../../layout/sub-title";
|
||||||
import { isRequired } from "../../input/input.validators";
|
import { isRequired } from "../../input/input.validators";
|
||||||
|
|
||||||
@ -12,7 +12,15 @@ interface Props {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClusterNameSetting extends React.Component<Props> {
|
export class ClusterNameSetting extends React.Component<Props> {
|
||||||
@observable name = this.props.cluster.preferences.clusterName || "";
|
@observable name = "";
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
disposeOnUnmount(this,
|
||||||
|
autorun(() => {
|
||||||
|
this.name = this.props.cluster.preferences.clusterName;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
save = () => {
|
save = () => {
|
||||||
this.props.cluster.preferences.clusterName = this.name;
|
this.props.cluster.preferences.clusterName = this.name;
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer, disposeOnUnmount } from "mobx-react";
|
||||||
import { prometheusProviders } from "../../../../common/prometheus-providers";
|
import { prometheusProviders } from "../../../../common/prometheus-providers";
|
||||||
import { Cluster } from "../../../../main/cluster";
|
import { Cluster } from "../../../../main/cluster";
|
||||||
import { SubTitle } from "../../layout/sub-title";
|
import { SubTitle } from "../../layout/sub-title";
|
||||||
import { Select, SelectOption } from "../../select";
|
import { Select, SelectOption } from "../../select";
|
||||||
import { Input } from "../../input";
|
import { Input } from "../../input";
|
||||||
import { observable, computed } from "mobx";
|
import { observable, computed, autorun } from "mobx";
|
||||||
|
|
||||||
const options: SelectOption<string>[] = [
|
const options: SelectOption<string>[] = [
|
||||||
{ value: "", label: "Auto detect" },
|
{ value: "", label: "Auto detect" },
|
||||||
@ -27,14 +27,22 @@ export class ClusterPrometheusSetting extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
disposeOnUnmount(this,
|
||||||
|
autorun(() => {
|
||||||
const { prometheus, prometheusProvider } = this.props.cluster.preferences;
|
const { prometheus, prometheusProvider } = this.props.cluster.preferences;
|
||||||
if (prometheus) {
|
if (prometheus) {
|
||||||
const prefix = prometheus.prefix || "";
|
const prefix = prometheus.prefix || "";
|
||||||
this.path = `${prometheus.namespace}/${prometheus.service}:${prometheus.port}${prefix}`;
|
this.path = `${prometheus.namespace}/${prometheus.service}:${prometheus.port}${prefix}`;
|
||||||
|
} else {
|
||||||
|
this.path = "";
|
||||||
}
|
}
|
||||||
if (prometheusProvider) {
|
if (prometheusProvider) {
|
||||||
this.provider = prometheusProvider.type;
|
this.provider = prometheusProvider.type;
|
||||||
|
} else {
|
||||||
|
this.provider = "";
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
parsePrometheusPath = () => {
|
parsePrometheusPath = () => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observable } from "mobx";
|
import { observable, autorun } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer, disposeOnUnmount } from "mobx-react";
|
||||||
import { Cluster } from "../../../../main/cluster";
|
import { Cluster } from "../../../../main/cluster";
|
||||||
import { Input } from "../../input";
|
import { Input } from "../../input";
|
||||||
import { isUrl } from "../../input/input.validators";
|
import { isUrl } from "../../input/input.validators";
|
||||||
@ -12,7 +12,15 @@ interface Props {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClusterProxySetting extends React.Component<Props> {
|
export class ClusterProxySetting extends React.Component<Props> {
|
||||||
@observable proxy = this.props.cluster.preferences.httpsProxy || "";
|
@observable proxy = "";
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
disposeOnUnmount(this,
|
||||||
|
autorun(() => {
|
||||||
|
this.proxy = this.props.cluster.preferences.httpsProxy || "";
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
save = () => {
|
save = () => {
|
||||||
this.props.cluster.preferences.httpsProxy = this.proxy;
|
this.props.cluster.preferences.httpsProxy = this.proxy;
|
||||||
|
|||||||
@ -22,8 +22,6 @@ import { clusterIpc } from "../../../common/cluster-ipc";
|
|||||||
import { clusterViewURL, getMatchedClusterId } from "./cluster-view.route";
|
import { clusterViewURL, getMatchedClusterId } from "./cluster-view.route";
|
||||||
import { DragDropContext, Droppable, Draggable, DropResult, DroppableProvided, DraggableProvided } from "react-beautiful-dnd";
|
import { DragDropContext, Droppable, Draggable, DropResult, DroppableProvided, DraggableProvided } from "react-beautiful-dnd";
|
||||||
|
|
||||||
// fixme: allow to rearrange clusters with drag&drop
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: IClassName;
|
className?: IClassName;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user