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

Remove icons / checks from RemoveClusterButton

Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This commit is contained in:
alexfront 2020-08-05 11:40:47 +03:00
parent 0bee7b6c1a
commit 6018bf0c42
5 changed files with 30 additions and 55 deletions

View File

@ -16,7 +16,7 @@
.settings-wrapper { .settings-wrapper {
margin: 0 auto; margin: 0 auto;
width: 70%; width: 70%;
min-width: 800px; min-width: 690px;
> div { > div {
margin-top: $margin * 3; margin-top: $margin * 3;
@ -37,8 +37,10 @@
border: 1px solid var(--drawerSubtitleBackground); border: 1px solid var(--drawerSubtitleBackground);
border-radius: $radius; border-radius: $radius;
.TableCell { .TableRow {
border-bottom: 1px solid var(--drawerSubtitleBackground); &:not(:last-of-type) {
border-bottom: 1px solid var(--drawerSubtitleBackground);
}
&.value { &.value {
color: var(--textColorSecondary); color: var(--textColorSecondary);

View File

@ -1,63 +1,40 @@
import React from "react"; import React from "react";
import { Cluster } from "../../../../main/cluster";
import { Button } from "../../button";
import { autobind } from "../../../utils";
import { Spinner } from "../../spinner";
import { Icon } from "../../icon";
import { ConfirmDialog } from "../../confirm-dialog";
import { Trans } from "@lingui/macro"; import { Trans } from "@lingui/macro";
import { observer } from "mobx-react";
import { clusterIpc } from "../../../../common/cluster-ipc"; import { clusterIpc } from "../../../../common/cluster-ipc";
import { clusterStore } from "../../../../common/cluster-store"; import { clusterStore } from "../../../../common/cluster-store";
import { observable } from "mobx"; import { Cluster } from "../../../../main/cluster";
import { observer } from "mobx-react"; import { autobind } from "../../../utils";
import { RemovalStatus } from "./statuses" import { Button } from "../../button";
import { ConfirmDialog } from "../../confirm-dialog";
interface Props { interface Props {
cluster: Cluster; cluster: Cluster;
} }
@observer @observer
export class RemoveClusterButton extends React.Component<Props> { export class RemoveClusterButton extends React.Component<Props> {
@observable status = RemovalStatus.PRESENT; @autobind()
@observable errorText?: string;
render() {
return (
<div className="center">
<Button accent onClick={this.confirmRemoveCluster}>Remove Cluster {this.getStatusIcon()}</Button>
</div>
);
}
getStatusIcon(): React.ReactNode {
switch (this.status) {
case RemovalStatus.PRESENT:
return null;
case RemovalStatus.PROCESSING:
return <Spinner />;
case RemovalStatus.ERROR:
return <Icon size="16px" material="error" title={this.errorText}></Icon>;
}
}
@autobind()
confirmRemoveCluster() { confirmRemoveCluster() {
const { cluster } = this.props; const { cluster } = this.props;
ConfirmDialog.open({ ConfirmDialog.open({
message: <p>Are you sure you want to remove <b>{cluster.preferences.clusterName}</b> from Lens?</p>, message: <p>Are you sure you want to remove <b>{cluster.preferences.clusterName}</b> from Lens?</p>,
labelOk: <Trans>Yes</Trans>, labelOk: <Trans>Yes</Trans>,
labelCancel: <Trans>No</Trans>, labelCancel: <Trans>No</Trans>,
ok: async () => { ok: async () => {
try { await clusterIpc.disconnect.invokeFromRenderer(cluster.id);
this.status = RemovalStatus.PROCESSING; await clusterStore.removeById(cluster.id);
await clusterIpc.disconnect.invokeFromRenderer(cluster.id);
await clusterStore.removeById(cluster.id);
} catch (err) {
this.status = RemovalStatus.ERROR;
this.errorText = err.toString();
}
} }
}) })
} }
render() {
return (
<div className="flex gaps align-center">
<Button accent onClick={this.confirmRemoveCluster}>
Remove Cluster
</Button>
</div>
);
}
} }

View File

@ -16,9 +16,3 @@ export enum ActionStatus {
PROCESSING = "processing", PROCESSING = "processing",
ERROR = "error" ERROR = "error"
} }
export enum RemovalStatus {
PRESENT = "present",
PROCESSING = "processing",
ERROR = "error",
}

View File

@ -3,7 +3,7 @@ import { Cluster } from "../../../main/cluster";
import { RemoveClusterButton } from "./components/remove-cluster-button"; import { RemoveClusterButton } from "./components/remove-cluster-button";
interface Props { interface Props {
cluster: Cluster; cluster: Cluster;
} }
export class Removal extends React.Component<Props> { export class Removal extends React.Component<Props> {

View File

@ -18,9 +18,11 @@ export class WizardLayout extends React.Component<Props> {
const { className, contentClass, infoPanelClass, infoPanel, header, headerClass, children: content } = this.props; const { className, contentClass, infoPanelClass, infoPanel, header, headerClass, children: content } = this.props;
return ( return (
<div className={cssNames("WizardLayout", className)}> <div className={cssNames("WizardLayout", className)}>
<div className={cssNames("head-col flex gaps align-center", headerClass)}> {header && (
{header} <div className={cssNames("head-col flex gaps align-center", headerClass)}>
</div> {header}
</div>
)}
<div className={cssNames("content-col flex column gaps", contentClass)}> <div className={cssNames("content-col flex column gaps", contentClass)}>
{content} {content}
</div> </div>