From 52b447948dff1a46831b9fb6ad755983693ec7c8 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 12 Oct 2020 14:05:28 +0300 Subject: [PATCH] adding cluster fix (reverted changes from master) Signed-off-by: Roman --- .../components/+add-cluster/add-cluster.tsx | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/renderer/components/+add-cluster/add-cluster.tsx b/src/renderer/components/+add-cluster/add-cluster.tsx index 4b34d25f2e..0751dd2d8c 100644 --- a/src/renderer/components/+add-cluster/add-cluster.tsx +++ b/src/renderer/components/+add-cluster/add-cluster.tsx @@ -2,7 +2,7 @@ import "./add-cluster.scss" import os from "os"; import React, { Fragment } from "react"; import { observer } from "mobx-react"; -import { action, observable } from "mobx"; +import { action, observable, runInAction } from "mobx"; import { remote } from "electron"; import { KubeConfig } from "@kubernetes/client-node"; import { _i18n } from "../../i18n"; @@ -121,9 +121,7 @@ export class AddCluster extends React.Component { @action addClusters = () => { - const configValidationErrors:string[] = []; let newClusters: ClusterModel[] = []; - try { if (!this.selectedContexts.length) { this.error = Please select at least one cluster context @@ -132,7 +130,7 @@ export class AddCluster extends React.Component { this.error = "" this.isWaiting = true - newClusters = this.selectedContexts.filter(context => { + newClusters = this.selectedContexts.filter(context => { try { const kubeConfig = this.kubeContexts.get(context); validateKubeConfig(kubeConfig); @@ -164,17 +162,21 @@ export class AddCluster extends React.Component { } }) - - clusterStore.addCluster(...newClusters); - - if (newClusters.length === 1) { - const clusterId = newClusters[0].id; - navigate(clusterViewURL({ params: { clusterId } })); - } else { - if (newClusters.length > 1) {Notifications.ok( - Successfully imported {newClusters.length} cluster(s)); + runInAction(() => { + clusterStore.addCluster(...newClusters); + if (newClusters.length === 1) { + const clusterId = newClusters[0].id; + clusterStore.setActive(clusterId); + navigate(clusterViewURL({ params: { clusterId } })); + } else { + if (newClusters.length > 1) { + Notifications.ok( + Successfully imported {newClusters.length} cluster(s) + ); + } } - } + }) + this.refreshContexts(); } catch (err) { this.error = String(err); Notifications.error(Error while adding cluster(s): {this.error}); @@ -226,7 +228,7 @@ export class AddCluster extends React.Component { Select kubeconfig file} - active={this.sourceTab == KubeConfigSourceTab.FILE}/> + active={this.sourceTab == KubeConfigSourceTab.FILE} /> Paste as text} @@ -340,8 +342,8 @@ export class AddCluster extends React.Component { return (
{context} - {isNew && } - {isSelected && } + {isNew && } + {isSelected && }
) };