mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Workspaces that are managed can now be enabled without the store removing that flag unconditionally via a roundtrip to the FS - Workspace overview should be reactive to the current workspace Signed-off-by: Sebastian Malton <sebastian@malton.name>
86 lines
3.0 KiB
TypeScript
86 lines
3.0 KiB
TypeScript
import "./workspace-overview.scss";
|
|
|
|
import React, { Component } from "react";
|
|
import { disposeOnUnmount, observer } from "mobx-react";
|
|
import { ItemListLayout } from "../item-object-list/item-list-layout";
|
|
import { ClusterItem, WorkspaceClusterStore } from "./workspace-cluster.store";
|
|
import { navigate } from "../../navigation";
|
|
import { clusterViewURL } from "../cluster-manager/cluster-view.route";
|
|
import { WorkspaceClusterMenu } from "./workspace-cluster-menu";
|
|
import { kebabCase } from "lodash";
|
|
import { addClusterURL } from "../+add-cluster";
|
|
import { observable, reaction } from "mobx";
|
|
import { workspaceStore } from "../../../common/workspace-store";
|
|
|
|
enum sortBy {
|
|
name = "name",
|
|
distribution = "distribution",
|
|
version = "version",
|
|
online = "online"
|
|
}
|
|
|
|
@observer
|
|
export class WorkspaceOverview extends Component {
|
|
@observable private workspaceClusterStore?: WorkspaceClusterStore;
|
|
|
|
componentDidMount() {
|
|
disposeOnUnmount(this, [
|
|
reaction(() => workspaceStore.currentWorkspaceId, workspaceId => {
|
|
this.workspaceClusterStore = new WorkspaceClusterStore(workspaceId);
|
|
this.workspaceClusterStore.loadAll().catch(error => console.log("workspaceClusterStore.loadAll", error));
|
|
}, {
|
|
fireImmediately: true,
|
|
})
|
|
]);
|
|
}
|
|
|
|
showCluster = ({ clusterId }: ClusterItem) => {
|
|
navigate(clusterViewURL({ params: { clusterId } }));
|
|
};
|
|
|
|
render() {
|
|
const { workspaceClusterStore } = this;
|
|
|
|
if (!workspaceClusterStore) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ItemListLayout
|
|
renderHeaderTitle="Clusters"
|
|
isClusterScoped
|
|
isSearchable={false}
|
|
isSelectable={false}
|
|
className="WorkspaceOverview"
|
|
store={workspaceClusterStore}
|
|
sortingCallbacks={{
|
|
[sortBy.name]: (item: ClusterItem) => item.name,
|
|
[sortBy.distribution]: (item: ClusterItem) => item.distribution,
|
|
[sortBy.version]: (item: ClusterItem) => item.version,
|
|
[sortBy.online]: (item: ClusterItem) => item.connectionStatus,
|
|
}}
|
|
renderTableHeader={[
|
|
{ title: "Name", className: "name", sortBy: sortBy.name },
|
|
{ title: "Distribution", className: "distribution", sortBy: sortBy.distribution },
|
|
{ title: "Version", className: "version", sortBy: sortBy.version },
|
|
{ title: "Status", className: "status", sortBy: sortBy.online },
|
|
]}
|
|
renderTableContents={(item: ClusterItem) => [
|
|
item.name,
|
|
item.distribution,
|
|
item.version,
|
|
{ title: item.connectionStatus, className: kebabCase(item.connectionStatus) }
|
|
]}
|
|
onDetails={this.showCluster}
|
|
addRemoveButtons={{
|
|
addTooltip: "Add Cluster",
|
|
onAdd: () => navigate(addClusterURL()),
|
|
}}
|
|
renderItemMenu={(clusterItem: ClusterItem) => (
|
|
<WorkspaceClusterMenu clusterItem={clusterItem} workspace={workspaceStore.currentWorkspace} workspaceClusterStore={workspaceClusterStore}/>
|
|
)}
|
|
/>
|
|
);
|
|
}
|
|
}
|