refactoring, fixes

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2020-07-21 16:01:20 +03:00
1 parent a40a9fec0e
commit 13c29a7fed
8 files changed
+58 -60

No files matched your search

@@ -16,7 +16,7 @@ import { tracker } from "../../../common/tracker";
import { clusterStore } from "../../../common/cluster-store";
import { workspaceStore } from "../../../common/workspace-store";
import { v4 as uuid } from "uuid"
import { navigate } from "../../navigation";
import { navigation } from "../../navigation";
@observer
export class AddCluster extends React.Component {
@@ -94,7 +94,7 @@ export class AddCluster extends React.Component {
httpsProxy: proxyServer || undefined,
},
});
navigate("/");
navigation.goBack(); // return to previous opened page for the cluster view
} catch (err) {
this.error = String(err);
} finally {
@@ -20,7 +20,7 @@ export class ClusterManager extends React.Component<Props> {
@observable isReady = false;
async componentDidMount() {
clusterIpc.refresh.invokeFromRenderer();
await clusterIpc.activate.invokeFromRenderer();
await App.init();
this.isReady = true;
}
@@ -13,6 +13,7 @@ import { clusterIpc } from "../../../common/cluster-ipc";
@observer
export class ClusterStatus extends React.Component {
@observable authOutput: string[] = [];
@observable hasErrors = false;
get cluster() {
return clusterStore.activeCluster;
@@ -26,6 +27,9 @@ export class ClusterStatus extends React.Component {
this.authOutput = ["Connecting ...\n"];
ipcRenderer.on(`kube-auth:${this.clusterId}`, (evt, { data, stream }: KubeAuthProxyResponse) => {
this.authOutput.push(`[${stream}]: ${data}`);
if (stream === "stderr") {
this.hasErrors = true;
}
})
}
@@ -39,20 +43,21 @@ export class ClusterStatus extends React.Component {
}
render() {
const { authOutput, cluster } = this;
const isError = cluster?.accessible === false;
const { authOutput, cluster, hasErrors } = this;
return (
<div className="ClusterStatus flex column gaps">
{!isError && <Icon material="cloud_queue"/>}
{isError && <Icon material="cloud_off" className="error"/>}
<h2>{cluster?.contextName}</h2>
{!hasErrors && <Icon material="cloud_queue"/>}
{hasErrors && <Icon material="cloud_off" className="error"/>}
<h2>
{cluster?.contextName}
</h2>
<pre className="kube-auth-out">
{authOutput.map((data, index) => {
const error = data.startsWith("[stderr]");
return <p key={index} className={cssNames({ error })}>{data}</p>
})}
</pre>
{isError && (
{hasErrors && (
<Button
primary className="box center"
label="Reconnect"
@@ -21,7 +21,6 @@ import { Tooltip, TooltipContent } from "../tooltip";
import { ConfirmDialog } from "../confirm-dialog";
import { clusterIpc } from "../../../common/cluster-ipc";
// fixme: refresh all cluster-icon badges in background (events-count per cluster)
// fixme: allow to rearrange clusters with drag&drop
interface Props {
@@ -101,13 +100,12 @@ export class ClustersMenu extends React.Component<Props> {
)}
<div className="clusters flex column gaps">
{clusters.map(cluster => {
const isActive = cluster.isReady && cluster.id === clusterStore.activeClusterId;
return (
<ClusterIcon
key={cluster.id}
showErrors={true}
cluster={cluster}
isActive={isActive}
isActive={cluster.id === clusterStore.activeClusterId}
onClick={() => this.showCluster(cluster.id)}
onContextMenu={() => this.showContextMenu(cluster)}
/>