mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add cluster item list to workspace landing page
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
9af42dac5c
commit
fb7b1b47ae
@ -0,0 +1,35 @@
|
|||||||
|
import { WorkspaceId } from "../../../common/workspace-store";
|
||||||
|
import { Cluster } from "../../../main/cluster";
|
||||||
|
import { clusterStore } from "../../../common/cluster-store";
|
||||||
|
import { ItemStore } from "../../item.store";
|
||||||
|
|
||||||
|
export class ClusterItem {
|
||||||
|
cluster: Cluster;
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.cluster.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.cluster.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** an ItemStore of the clusters belonging to a given workspace */
|
||||||
|
export class WorkspaceClusterStore extends ItemStore<ClusterItem> {
|
||||||
|
|
||||||
|
workspaceId: WorkspaceId;
|
||||||
|
|
||||||
|
constructor(workspaceId: WorkspaceId) {
|
||||||
|
super();
|
||||||
|
this.workspaceId = workspaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadAll() {
|
||||||
|
return this.loadItems(() => clusterStore.getByWorkspaceId(this.workspaceId).map(cluster => {
|
||||||
|
let clusterItem = new ClusterItem();
|
||||||
|
clusterItem.cluster = cluster;
|
||||||
|
return clusterItem;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,54 +4,51 @@ import { clusterStore } from "../../../common/cluster-store";
|
|||||||
import { Cluster } from "../../../main/cluster";
|
import { Cluster } from "../../../main/cluster";
|
||||||
import { observable, autorun } from "mobx";
|
import { observable, autorun } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Drawer, DrawerItem, DrawerTitle } from "../drawer";
|
import { WizardLayout } from "../layout/wizard-layout";
|
||||||
|
import { TabLayout } from "../layout/tab-layout";
|
||||||
|
import { ItemListLayout, ItemListLayoutProps } from "../item-object-list/item-list-layout";
|
||||||
import { autobind, stopPropagation } from "../../utils";
|
import { autobind, stopPropagation } from "../../utils";
|
||||||
import { MarkdownViewer } from "../markdown-viewer";
|
import { MarkdownViewer } from "../markdown-viewer";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { Select, SelectOption } from "../select";
|
import { Select, SelectOption } from "../select";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
|
import { ClusterItem, WorkspaceClusterStore } from "./workspace-cluster.store";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
workspace: Workspace;
|
workspace: Workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum sortBy {
|
||||||
|
name = "name",
|
||||||
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class WorkspaceOverview extends Component<Props> {
|
export class WorkspaceOverview extends Component<Props> {
|
||||||
|
|
||||||
renderClusters() {
|
|
||||||
const { workspace } = this.props;
|
|
||||||
const clusters = clusterStore.getByWorkspaceId(workspace.id);
|
|
||||||
return <div>
|
|
||||||
{clusters.map(cluster => <div>{cluster.contextName}</div>)}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { workspace } = this.props;
|
const { workspace } = this.props;
|
||||||
|
const workspaceClusterStore = new WorkspaceClusterStore(workspace.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<TabLayout>
|
||||||
className="WorkspaceDetails"
|
<ItemListLayout
|
||||||
usePortal={true}
|
isClusterScoped
|
||||||
open={!!workspace}
|
className="WorkspaceList" store={workspaceClusterStore}
|
||||||
title={"Details"}
|
sortingCallbacks={{
|
||||||
>
|
[sortBy.name]: (cluster: ClusterItem) => cluster.getName(),
|
||||||
<DrawerItem name={"Description"}>
|
}}
|
||||||
{workspace.description}
|
searchFilters={[]}
|
||||||
</DrawerItem>
|
renderTableHeader={[
|
||||||
<DrawerItem name={"Id"}>
|
{ title: "Name", className: "name flex-grow", sortBy: sortBy.name },
|
||||||
{workspace.id}
|
{ title: "Id", className: "id" },
|
||||||
</DrawerItem>
|
]}
|
||||||
<DrawerItem name={"Owner Ref"}>
|
renderTableContents={(item: ClusterItem) => [
|
||||||
{workspace.ownerRef}
|
item.getName(),
|
||||||
</DrawerItem>
|
item.getId(),
|
||||||
<DrawerItem name={"Enabled"} renderBoolean={true}>
|
]}
|
||||||
{workspace.enabled}
|
/>
|
||||||
</DrawerItem>
|
</TabLayout>
|
||||||
<DrawerTitle title={"Clusters"}/>
|
|
||||||
{this.renderClusters()}
|
|
||||||
</Drawer>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user