diff --git a/src/renderer/components/+landing-page/workspace-cluster-menu.tsx b/src/renderer/components/+landing-page/workspace-cluster-menu.tsx index 29b108cba4..8c2935c3e1 100644 --- a/src/renderer/components/+landing-page/workspace-cluster-menu.tsx +++ b/src/renderer/components/+landing-page/workspace-cluster-menu.tsx @@ -24,12 +24,12 @@ export class WorkspaceClusterMenu extends React.Component { } @autobind() - settings() { + gotoSettings() { const { clusterItem } = this.props; navigate(clusterSettingsURL({ params: { - clusterId: clusterItem.getId() + clusterId: clusterItem.id } })); } @@ -39,7 +39,7 @@ export class WorkspaceClusterMenu extends React.Component { const { clusterItem, workspace } = this.props; return ( -

Remove cluster {clusterItem.getName()} from workspace {workspace.name}?

+

Remove cluster {clusterItem.name} from workspace {workspace.name}?

); } @@ -49,7 +49,7 @@ export class WorkspaceClusterMenu extends React.Component { return ( <> - + Settings @@ -58,13 +58,13 @@ export class WorkspaceClusterMenu extends React.Component { } render() { - const { clusterItem, className, ...menuProps } = this.props; + const { clusterItem: { cluster: { isManaged } }, className, ...menuProps } = this.props; return ( {this.renderContent()} diff --git a/src/renderer/components/+landing-page/workspace-cluster.store.ts b/src/renderer/components/+landing-page/workspace-cluster.store.ts index dcecd63d31..35b4f64880 100644 --- a/src/renderer/components/+landing-page/workspace-cluster.store.ts +++ b/src/renderer/components/+landing-page/workspace-cluster.store.ts @@ -7,13 +7,25 @@ import { autobind } from "../../utils"; export class ClusterItem implements ItemObject { constructor(public cluster: Cluster) {} - getName() { + get name() { return this.cluster.name; } - getId() { + getName() { + return this.name; + } + + get id() { return this.cluster.id; } + + get clusterId() { + return this.cluster.id; + } + + getId() { + return this.id; + } } /** an ItemStore of the clusters belonging to a given workspace */ @@ -38,15 +50,11 @@ export class WorkspaceClusterStore extends ItemStore { } async remove(clusterItem: ClusterItem) { - const { cluster } = clusterItem; + const { cluster: { isManaged, id: clusterId }} = clusterItem; - if (cluster.isManaged) { - return; + if (!isManaged) { + return super.removeItem(clusterItem, () => clusterStore.removeById(clusterId)); } - - const clusterId = cluster.id; - - return super.removeItem(clusterItem, () => clusterStore.removeById(clusterId)); } async removeSelectedItems() { diff --git a/src/renderer/components/+landing-page/workspace-overview.tsx b/src/renderer/components/+landing-page/workspace-overview.tsx index 2d3130c0bf..b245c2294b 100644 --- a/src/renderer/components/+landing-page/workspace-overview.tsx +++ b/src/renderer/components/+landing-page/workspace-overview.tsx @@ -22,12 +22,10 @@ enum sortBy { @observer export class WorkspaceOverview extends Component { - showCluster = (clusterItem: ClusterItem) => { - const clusterId = clusterItem.getId(); - + showCluster = ({ clusterId }: ClusterItem) => { navigate(clusterViewURL({ params: { clusterId } })); }; - + render() { const { workspace } = this.props; const workspaceClusterStore = new WorkspaceClusterStore(workspace.id); @@ -43,7 +41,7 @@ export class WorkspaceOverview extends Component { className="WorkspaceOverview" store={workspaceClusterStore} sortingCallbacks={{ - [sortBy.name]: (item: ClusterItem) => item.getName(), + [sortBy.name]: (item: ClusterItem) => item.name, [sortBy.contextName]: (item: ClusterItem) => item.cluster.contextName, [sortBy.version]: (item: ClusterItem) => item.cluster.version, }} @@ -54,7 +52,7 @@ export class WorkspaceOverview extends Component { { title: "Status", className: "status" }, ]} renderTableContents={(item: ClusterItem) => [ - item.getName(), + item.name, item.cluster.contextName, item.cluster.version, item.cluster.online ? "online" : "offline"