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

ClusterWorkspaceSettings refactoring/fixing

Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This commit is contained in:
alexfront 2020-08-05 14:33:46 +03:00
parent f91e0e6a63
commit f533331864
2 changed files with 25 additions and 27 deletions

View File

@ -1,12 +1,11 @@
import React from "react"; import React from "react";
import { Cluster } from "../../../../main/cluster";
import { clusterStore } from "../../../../common/cluster-store"
import { workspaceStore } from "../../../../common/workspace-store"
import { Select, SelectOption } from "../../../components/select";
import { GeneralInputStatus } from "./statuses"
import { observable } from "mobx";
import { autobind } from "../../../utils";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { Link } from "react-router-dom";
import { workspacesURL } from "../../+workspaces";
import { workspaceStore } from "../../../../common/workspace-store";
import { Cluster } from "../../../../main/cluster";
import { Select } from "../../../components/select";
import { SubTitle } from "../../layout/sub-title";
interface Props { interface Props {
cluster: Cluster; cluster: Cluster;
@ -14,23 +13,24 @@ interface Props {
@observer @observer
export class ClusterWorkspaceSetting extends React.Component<Props> { export class ClusterWorkspaceSetting extends React.Component<Props> {
@observable workspace = this.props.cluster.workspace;
render() { render() {
return <> return (
<h4>Cluster Workspace</h4> <>
<p>Change cluster workspace:</p> <SubTitle title="Cluster Workspace"/>
<p>
Define cluster{" "}
<Link to={workspacesURL()}>
workspace
</Link>.
</p>
<Select <Select
value={workspaceStore.currentWorkspaceId} value={this.props.cluster.workspace}
options={workspaceStore.workspacesList.map(w => ({value: w.id, label: <span>{w.name}</span>}))} onChange={({value}) => this.props.cluster.workspace = value}
onChange={this.changeWorkspace} options={workspaceStore.workspacesList.map(w =>
({value: w.id, label: w.name})
)}
/> />
</>; </>
} );
@autobind()
changeWorkspace({ value: workspace }: SelectOption<string>) {
this.workspace = workspace;
this.props.cluster.workspace = workspace;
} }
} }

View File

@ -15,8 +15,6 @@ export class General extends React.Component<Props> {
render() { render() {
return <div> return <div>
<h2>General</h2> <h2>General</h2>
<hr/>
<ClusterNameSetting cluster={this.props.cluster} /> <ClusterNameSetting cluster={this.props.cluster} />
<ClusterWorkspaceSetting cluster={this.props.cluster} /> <ClusterWorkspaceSetting cluster={this.props.cluster} />
<ClusterIconSetting cluster={this.props.cluster} /> <ClusterIconSetting cluster={this.props.cluster} />