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

adding cluster fix (reverted changes from master)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-10-12 14:05:28 +03:00
parent 2b37fe3cc1
commit 52b447948d

View File

@ -2,7 +2,7 @@ import "./add-cluster.scss"
import os from "os"; import os from "os";
import React, { Fragment } from "react"; import React, { Fragment } from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { action, observable } from "mobx"; import { action, observable, runInAction } from "mobx";
import { remote } from "electron"; import { remote } from "electron";
import { KubeConfig } from "@kubernetes/client-node"; import { KubeConfig } from "@kubernetes/client-node";
import { _i18n } from "../../i18n"; import { _i18n } from "../../i18n";
@ -121,9 +121,7 @@ export class AddCluster extends React.Component {
@action @action
addClusters = () => { addClusters = () => {
const configValidationErrors:string[] = [];
let newClusters: ClusterModel[] = []; let newClusters: ClusterModel[] = [];
try { try {
if (!this.selectedContexts.length) { if (!this.selectedContexts.length) {
this.error = <Trans>Please select at least one cluster context</Trans> this.error = <Trans>Please select at least one cluster context</Trans>
@ -164,17 +162,21 @@ export class AddCluster extends React.Component {
} }
}) })
runInAction(() => {
clusterStore.addCluster(...newClusters); clusterStore.addCluster(...newClusters);
if (newClusters.length === 1) { if (newClusters.length === 1) {
const clusterId = newClusters[0].id; const clusterId = newClusters[0].id;
clusterStore.setActive(clusterId);
navigate(clusterViewURL({ params: { clusterId } })); navigate(clusterViewURL({ params: { clusterId } }));
} else { } else {
if (newClusters.length > 1) {Notifications.ok( if (newClusters.length > 1) {
<Trans>Successfully imported <b>{newClusters.length}</b> cluster(s)</Trans>); Notifications.ok(
<Trans>Successfully imported <b>{newClusters.length}</b> cluster(s)</Trans>
);
} }
} }
})
this.refreshContexts();
} catch (err) { } catch (err) {
this.error = String(err); this.error = String(err);
Notifications.error(<Trans>Error while adding cluster(s): {this.error}</Trans>); Notifications.error(<Trans>Error while adding cluster(s): {this.error}</Trans>);