mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Using TopBar in cluster views
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
d88cf3bc51
commit
d15af15433
@ -44,7 +44,7 @@ import { cssNames } from "../../utils";
|
|||||||
import { TopBar } from "../layout/topbar";
|
import { TopBar } from "../layout/topbar";
|
||||||
import { welcomeURL } from "../+welcome";
|
import { welcomeURL } from "../+welcome";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { MaterialTooltip } from "./material-tooltip/material-tooltip";
|
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
||||||
|
|
||||||
enum sortBy {
|
enum sortBy {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -142,7 +142,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
renderNavigation() {
|
renderNavigation() {
|
||||||
return (
|
return (
|
||||||
<Tabs className={cssNames(styles.tabs, "flex column")} scrollable={false} onChange={this.onTabChange} value={this.activeTab}>
|
<Tabs className={cssNames(styles.tabs, "flex column")} scrollable={false} onChange={this.onTabChange} value={this.activeTab}>
|
||||||
<div className="pt-4">
|
<div>
|
||||||
<Tab
|
<Tab
|
||||||
value={undefined}
|
value={undefined}
|
||||||
key="*"
|
key="*"
|
||||||
@ -210,7 +210,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TopBar sidebar={<div>Catalog</div>}>
|
<TopBar label="Catalog">
|
||||||
<div>
|
<div>
|
||||||
<MaterialTooltip title="Close Catalog" placement="left">
|
<MaterialTooltip title="Close Catalog" placement="left">
|
||||||
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(welcomeURL())}/>
|
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(welcomeURL())}/>
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
.Welcome {
|
.Welcome {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
#lens-views {
|
#lens-views {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: var(--main-layout-header); // Move below the TopBar
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import React from "react";
|
|||||||
import { Redirect, Route, Switch } from "react-router";
|
import { Redirect, Route, Switch } from "react-router";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { BottomBar } from "./bottom-bar";
|
import { BottomBar } from "./bottom-bar";
|
||||||
import { Catalog, catalogRoute } from "../+catalog";
|
import { Catalog, catalogRoute, catalogURL } from "../+catalog";
|
||||||
import { Preferences, preferencesRoute } from "../+preferences";
|
import { Preferences, preferencesRoute } from "../+preferences";
|
||||||
import { AddCluster, addClusterRoute } from "../+add-cluster";
|
import { AddCluster, addClusterRoute } from "../+add-cluster";
|
||||||
import { ClusterView } from "./cluster-view";
|
import { ClusterView } from "./cluster-view";
|
||||||
@ -35,13 +35,36 @@ import { Extensions, extensionsRoute } from "../+extensions";
|
|||||||
import { HotbarMenu } from "../hotbar/hotbar-menu";
|
import { HotbarMenu } from "../hotbar/hotbar-menu";
|
||||||
import { EntitySettings, entitySettingsRoute } from "../+entity-settings";
|
import { EntitySettings, entitySettingsRoute } from "../+entity-settings";
|
||||||
import { Welcome, welcomeRoute, welcomeURL } from "../+welcome";
|
import { Welcome, welcomeRoute, welcomeURL } from "../+welcome";
|
||||||
|
import { TopBar } from "../layout/topbar";
|
||||||
|
import { ClusterStore } from "../../../common/cluster-store";
|
||||||
|
import { hasLoadedView } from "./lens-views";
|
||||||
|
import { navigate } from "../../navigation";
|
||||||
|
import { Icon } from "../icon";
|
||||||
|
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClusterManager extends React.Component {
|
export class ClusterManager extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
|
const cluster = ClusterStore.getInstance().active;
|
||||||
|
const isClusterVisible = cluster?.available && cluster?.ready && hasLoadedView(cluster.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ClusterManager">
|
<div className="ClusterManager">
|
||||||
<main>
|
<main>
|
||||||
|
{ isClusterVisible && (
|
||||||
|
<TopBar label={(
|
||||||
|
<>
|
||||||
|
<Icon svg="kube"/>{" "}
|
||||||
|
{cluster.contextName}
|
||||||
|
</>)
|
||||||
|
}>
|
||||||
|
<div>
|
||||||
|
<MaterialTooltip title="Back to Catalog" placement="left">
|
||||||
|
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(catalogURL())}/>
|
||||||
|
</MaterialTooltip>
|
||||||
|
</div>
|
||||||
|
</TopBar>
|
||||||
|
)}
|
||||||
<div id="lens-views"/>
|
<div id="lens-views"/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route component={Welcome} {...welcomeRoute} />
|
<Route component={Welcome} {...welcomeRoute} />
|
||||||
@ -66,3 +89,19 @@ export class ClusterManager extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const ClusterTopBar = observer(() => {
|
||||||
|
// const cluster = ClusterStore.getInstance().activeCluster;
|
||||||
|
|
||||||
|
// // console.log(cluster)
|
||||||
|
|
||||||
|
// // if (!cluster) {
|
||||||
|
// // return null;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <TopBar sidebar={<div>Lens</div>}>
|
||||||
|
// {cluster}
|
||||||
|
// </TopBar>
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
|||||||
@ -65,6 +65,7 @@ export class ClusterView extends React.Component {
|
|||||||
initView(clusterId); // init cluster-view (iframe), requires parent container #lens-views to be in DOM
|
initView(clusterId); // init cluster-view (iframe), requires parent container #lens-views to be in DOM
|
||||||
requestMain(clusterActivateHandler, clusterId, false); // activate and fetch cluster's state from main
|
requestMain(clusterActivateHandler, clusterId, false); // activate and fetch cluster's state from main
|
||||||
catalogEntityRegistry.activeEntity = catalogEntityRegistry.getById(clusterId);
|
catalogEntityRegistry.activeEntity = catalogEntityRegistry.getById(clusterId);
|
||||||
|
ClusterStore.getInstance().setActive(clusterId);
|
||||||
}, {
|
}, {
|
||||||
fireImmediately: true,
|
fireImmediately: true,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { MaterialTooltip } from "../+catalog/material-tooltip/material-tooltip";
|
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
||||||
import { catalogURL } from "../+catalog";
|
import { catalogURL } from "../+catalog";
|
||||||
import { broadcastMessage } from "../../../common/ipc";
|
import { broadcastMessage } from "../../../common/ipc";
|
||||||
import { IpcRendererNavigationEvents } from "../../navigation/events";
|
import { IpcRendererNavigationEvents } from "../../navigation/events";
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
> .Tabs {
|
> .Tabs {
|
||||||
background: $layoutTabsBackground;
|
background: $layoutTabsBackground;
|
||||||
|
min-height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|||||||
@ -1,16 +1,24 @@
|
|||||||
.topBar {
|
.topBar {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: [sidebar] var(--sidebar-width) [contents] 1fr;
|
grid-template-columns: [title] 1fr [controls] auto;
|
||||||
grid-template-rows: var(--main-layout-header);
|
grid-template-rows: var(--main-layout-header);
|
||||||
grid-template-areas: "sidebar contents";
|
grid-template-areas: "title controls";
|
||||||
|
background-color: var(--layoutBackground);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.title {
|
||||||
width: var(--sidebar-width);
|
@apply font-bold;
|
||||||
background-color: var(--sidebarLogoBackground);
|
color: var(--textColorAccent);
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contents {
|
.controls {
|
||||||
background-color: var(--layoutBackground);
|
align-self: flex-end;
|
||||||
|
padding-right: 1.5rem;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
@ -20,22 +20,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import styles from "./topbar.module.css";
|
import styles from "./topbar.module.css";
|
||||||
import React, { HTMLAttributes, ReactNode } from "react";
|
import React from "react";
|
||||||
import { sidebarStorage } from "./sidebar-storage";
|
import { sidebarStorage } from "./sidebar-storage";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
|
|
||||||
interface Props extends HTMLAttributes<any> {
|
interface Props extends React.HTMLAttributes<any> {
|
||||||
sidebar: ReactNode;
|
label: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TopBar = observer((props: Props) => {
|
export const TopBar = observer(({ label, children, ...rest }: Props) => {
|
||||||
const { width } = sidebarStorage.get();
|
const { width } = sidebarStorage.get();
|
||||||
const style = { "--sidebar-width": `${width}px` } as React.CSSProperties;
|
const style = { "--sidebar-width": `${width}px` } as React.CSSProperties;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.topBar} style={style}>
|
<div className={styles.topBar} style={style} {...rest}>
|
||||||
<div className={styles.sidebar}>{props.sidebar}</div>
|
<div className={styles.title}>{label}</div>
|
||||||
<div className={styles.contents}>{props.children}</div>
|
<div className={styles.controls}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user