mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
added Select component to landing page title for changing workspace
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
0cd939a82d
commit
12c619aa0c
@ -5,7 +5,10 @@ import { observer } from "mobx-react";
|
|||||||
import { clusterStore } from "../../../common/cluster-store";
|
import { clusterStore } from "../../../common/cluster-store";
|
||||||
import { Workspace, workspaceStore } from "../../../common/workspace-store";
|
import { Workspace, workspaceStore } from "../../../common/workspace-store";
|
||||||
import { PageLayout } from "../layout/page-layout"
|
import { PageLayout } from "../layout/page-layout"
|
||||||
|
import { Select, SelectOption } from "../select";
|
||||||
import { WorkspaceOverview } from "./workspace-overview"
|
import { WorkspaceOverview } from "./workspace-overview"
|
||||||
|
import { autobind } from "../../../common/utils";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class LandingPage extends React.Component {
|
export class LandingPage extends React.Component {
|
||||||
@observable showHint = true;
|
@observable showHint = true;
|
||||||
@ -13,15 +16,37 @@ export class LandingPage extends React.Component {
|
|||||||
|
|
||||||
currentWorkspace = autorun(() => { this.workspace = workspaceStore.currentWorkspace; })
|
currentWorkspace = autorun(() => { this.workspace = workspaceStore.currentWorkspace; })
|
||||||
|
|
||||||
|
@autobind()
|
||||||
|
getHeader() {
|
||||||
|
const onWorkspaceChange = (option: SelectOption) => {
|
||||||
|
const selectedWorkspace = workspaceStore.getByName(option.value);
|
||||||
|
|
||||||
|
if (!selectedWorkspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceStore.setActive(selectedWorkspace.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<h2 className="flex row center">
|
||||||
|
<span>Workspace:</span>
|
||||||
|
<Select
|
||||||
|
options={workspaceStore.enabledWorkspacesList.map(w => ({value: w.name, label: w.name}))}
|
||||||
|
value={this.workspace.name}
|
||||||
|
onChange={onWorkspaceChange}
|
||||||
|
/>
|
||||||
|
</h2>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const clusters = clusterStore.getByWorkspaceId(workspaceStore.currentWorkspaceId);
|
const clusters = clusterStore.getByWorkspaceId(workspaceStore.currentWorkspaceId);
|
||||||
const noClustersInScope = !clusters.length;
|
const noClustersInScope = !clusters.length;
|
||||||
const showStartupHint = this.showHint && noClustersInScope;
|
const showStartupHint = this.showHint && noClustersInScope;
|
||||||
|
|
||||||
const header = <h2>{`Workspace: ${this.workspace?.name}`}</h2>;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout provideBackButtonNavigation={false} className="Workspaces" header={header} headerClass={"box center"}>
|
<PageLayout provideBackButtonNavigation={false} className="Workspaces" header={this.getHeader()} headerClass={"box center"}>
|
||||||
<div className="LandingPage flex auto">
|
<div className="LandingPage flex auto">
|
||||||
{showStartupHint && (
|
{showStartupHint && (
|
||||||
<div className="startup-hint flex column gaps" onMouseEnter={() => this.showHint = false}>
|
<div className="startup-hint flex column gaps" onMouseEnter={() => this.showHint = false}>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import "./workspace-cluster-icon.scss";
|
import "./workspace-cluster-icon.scss";
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component, Fragment } from "react";
|
||||||
import { Workspace } from "../../../common/workspace-store";
|
import { Workspace } from "../../../common/workspace-store";
|
||||||
import { clusterStore } from "../../../common/cluster-store";
|
import { clusterStore } from "../../../common/cluster-store";
|
||||||
import { Cluster } from "../../../main/cluster";
|
import { Cluster } from "../../../main/cluster";
|
||||||
@ -29,6 +29,33 @@ enum sortBy {
|
|||||||
@observer
|
@observer
|
||||||
export class WorkspaceOverview extends Component<Props> {
|
export class WorkspaceOverview extends Component<Props> {
|
||||||
|
|
||||||
|
renderInfo() {
|
||||||
|
const { workspace } = this.props;
|
||||||
|
|
||||||
|
if (workspace.name === "default") {
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<h2>Default Workspace</h2>
|
||||||
|
<p className="info">
|
||||||
|
This is the default workspace. Workspaces are used to organize clusters into logical groups.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
A single workspaces contains a list of clusters and their full configuration.
|
||||||
|
</p>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<h2>Description</h2>
|
||||||
|
<p className="info">
|
||||||
|
{workspace.description}
|
||||||
|
</p>
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
getIcon(clusterItem: ClusterItem) {
|
getIcon(clusterItem: ClusterItem) {
|
||||||
const { cluster } = clusterItem;
|
const { cluster } = clusterItem;
|
||||||
const { name } = cluster;
|
const { name } = cluster;
|
||||||
@ -48,24 +75,27 @@ export class WorkspaceOverview extends Component<Props> {
|
|||||||
const workspaceClusterStore = new WorkspaceClusterStore(workspace.id);
|
const workspaceClusterStore = new WorkspaceClusterStore(workspace.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListLayout
|
<WizardLayout className="Workspaces" infoPanel={this.renderInfo()}>
|
||||||
isClusterScoped
|
<ItemListLayout
|
||||||
className="WorkspaceList" store={workspaceClusterStore}
|
renderHeaderTitle={<div>Clusters</div>}
|
||||||
sortingCallbacks={{
|
isClusterScoped
|
||||||
[sortBy.name]: (cluster: ClusterItem) => cluster.getName(),
|
className="WorkspaceList" store={workspaceClusterStore}
|
||||||
}}
|
sortingCallbacks={{
|
||||||
searchFilters={[]}
|
[sortBy.name]: (cluster: ClusterItem) => cluster.getName(),
|
||||||
renderTableHeader={[
|
}}
|
||||||
{ title: "", className: "icon flex-grow" },
|
searchFilters={[]}
|
||||||
{ title: "Name", className: "name flex-grow", sortBy: sortBy.name },
|
renderTableHeader={[
|
||||||
{ title: "Id", className: "id" },
|
{ title: "", className: "icon" },
|
||||||
]}
|
{ title: "Name", className: "name flex-grow", sortBy: sortBy.name },
|
||||||
renderTableContents={(item: ClusterItem) => [
|
{ title: "Id", className: "id" },
|
||||||
this.getIcon(item),
|
]}
|
||||||
item.getName(),
|
renderTableContents={(item: ClusterItem) => [
|
||||||
item.getId(),
|
this.getIcon(item),
|
||||||
]}
|
item.getName(),
|
||||||
/>
|
item.getId(),
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</WizardLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user