mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move topbars to cluster manager
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
b8a99eafcd
commit
10d066844a
@ -27,7 +27,6 @@ import { ItemListLayout } from "../item-object-list";
|
|||||||
import { action, makeObservable, observable, reaction, when } from "mobx";
|
import { action, makeObservable, observable, reaction, when } from "mobx";
|
||||||
import { CatalogEntityItem, CatalogEntityStore } from "./catalog-entity.store";
|
import { CatalogEntityItem, CatalogEntityStore } from "./catalog-entity.store";
|
||||||
import { navigate } from "../../navigation";
|
import { navigate } from "../../navigation";
|
||||||
import { kebabCase } from "lodash";
|
|
||||||
import { MenuItem, MenuActions } from "../menu";
|
import { MenuItem, MenuActions } from "../menu";
|
||||||
import type { CatalogEntityContextMenu, CatalogEntityContextMenuContext } from "../../api/catalog-entity";
|
import type { CatalogEntityContextMenu, CatalogEntityContextMenuContext } from "../../api/catalog-entity";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
@ -42,10 +41,6 @@ import { Notifications } from "../notifications";
|
|||||||
import { Avatar } from "../avatar/avatar";
|
import { Avatar } from "../avatar/avatar";
|
||||||
import { MainLayout } from "../layout/main-layout";
|
import { MainLayout } from "../layout/main-layout";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { TopBar } from "../layout/topbar";
|
|
||||||
import { welcomeURL } from "../+welcome";
|
|
||||||
import { Icon } from "../icon";
|
|
||||||
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
|
||||||
import { CatalogEntityDetails } from "./catalog-entity-details";
|
import { CatalogEntityDetails } from "./catalog-entity-details";
|
||||||
|
|
||||||
enum sortBy {
|
enum sortBy {
|
||||||
@ -230,7 +225,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
item.name,
|
item.name,
|
||||||
item.source,
|
item.source,
|
||||||
item.labels.map((label) => <Badge key={label} label={label} title={label} />),
|
item.labels.map((label) => <Badge key={label} label={label} title={label} />),
|
||||||
{ title: item.phase, className: kebabCase(item.phase) }
|
{ title: item.phase, className: cssNames({ [styles.connected]: item.phase == "connected" }) }
|
||||||
]}
|
]}
|
||||||
onDetails={(item: CatalogEntityItem) => this.onDetails(item) }
|
onDetails={(item: CatalogEntityItem) => this.onDetails(item) }
|
||||||
renderItemMenu={this.renderItemMenu}
|
renderItemMenu={this.renderItemMenu}
|
||||||
@ -269,7 +264,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
item.kind,
|
item.kind,
|
||||||
item.source,
|
item.source,
|
||||||
item.labels.map((label) => <Badge key={label} label={label} title={label} />),
|
item.labels.map((label) => <Badge key={label} label={label} title={label} />),
|
||||||
{ title: item.phase, className: kebabCase(item.phase) }
|
{ title: item.phase, className: cssNames({ [styles.connected]: item.phase == "connected" }) }
|
||||||
]}
|
]}
|
||||||
detailsItem={this.selectedItem}
|
detailsItem={this.selectedItem}
|
||||||
onDetails={(item: CatalogEntityItem) => this.onDetails(item) }
|
onDetails={(item: CatalogEntityItem) => this.onDetails(item) }
|
||||||
@ -284,29 +279,20 @@ export class Catalog extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<MainLayout sidebar={this.renderNavigation()}>
|
||||||
<TopBar label="Catalog">
|
<div className="p-6 h-full">
|
||||||
<div>
|
{ this.catalogEntityStore.activeCategory ? this.renderSingleCategoryList() : this.renderAllCategoriesList() }
|
||||||
<MaterialTooltip title="Close Catalog" placement="left">
|
</div>
|
||||||
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(welcomeURL())}/>
|
{ !this.selectedItem && (
|
||||||
</MaterialTooltip>
|
<CatalogAddButton category={this.catalogEntityStore.activeCategory} />
|
||||||
</div>
|
)}
|
||||||
</TopBar>
|
{ this.selectedItem && (
|
||||||
<MainLayout sidebar={this.renderNavigation()}>
|
<CatalogEntityDetails
|
||||||
<div className="p-6 h-full">
|
entity={this.selectedItem.entity}
|
||||||
{ this.catalogEntityStore.activeCategory ? this.renderSingleCategoryList() : this.renderAllCategoriesList() }
|
hideDetails={() => this.selectedItem = null}
|
||||||
</div>
|
/>
|
||||||
{ !this.selectedItem && (
|
)}
|
||||||
<CatalogAddButton category={this.catalogEntityStore.activeCategory} />
|
</MainLayout>
|
||||||
)}
|
|
||||||
{ this.selectedItem && (
|
|
||||||
<CatalogEntityDetails
|
|
||||||
entity={this.selectedItem.entity}
|
|
||||||
hideDetails={() => this.selectedItem = null}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</MainLayout>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
39
src/renderer/components/cluster-manager/catalog-topbar.tsx
Normal file
39
src/renderer/components/cluster-manager/catalog-topbar.tsx
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 OpenLens Authors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
import { welcomeURL } from "../+welcome";
|
||||||
|
import { navigate } from "../../navigation";
|
||||||
|
import { Icon } from "../icon";
|
||||||
|
import { TopBar } from "../layout/topbar";
|
||||||
|
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
||||||
|
|
||||||
|
export function CatalogTopbar() {
|
||||||
|
return (
|
||||||
|
<TopBar label="Catalog">
|
||||||
|
<div>
|
||||||
|
<MaterialTooltip title="Close Catalog" placement="left">
|
||||||
|
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(welcomeURL())}/>
|
||||||
|
</MaterialTooltip>
|
||||||
|
</div>
|
||||||
|
</TopBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -23,10 +23,12 @@
|
|||||||
--bottom-bar-height: 22px;
|
--bottom-bar-height: 22px;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas: "menu main" "menu main" "bottom-bar bottom-bar";
|
grid-template-areas:
|
||||||
|
"menu topbar"
|
||||||
|
"menu main"
|
||||||
|
"bottom-bar bottom-bar";
|
||||||
grid-template-rows: auto 1fr min-content;
|
grid-template-rows: auto 1fr min-content;
|
||||||
grid-template-columns: min-content 1fr;
|
grid-template-columns: min-content 1fr;
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
grid-area: main;
|
grid-area: main;
|
||||||
@ -46,7 +48,7 @@
|
|||||||
#lens-views {
|
#lens-views {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: var(--main-layout-header); // Move below the TopBar
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@ -35,12 +35,16 @@ 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 { ClusterTopbar } from "./cluster-topbar";
|
||||||
|
import { CatalogTopbar } from "./catalog-topbar";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClusterManager extends React.Component {
|
export class ClusterManager extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="ClusterManager">
|
<div className="ClusterManager">
|
||||||
|
<Route component={CatalogTopbar} {...catalogRoute} />
|
||||||
|
<Route component={ClusterTopbar} {...clusterViewRoute} />
|
||||||
<main>
|
<main>
|
||||||
<div id="lens-views"/>
|
<div id="lens-views"/>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
|||||||
@ -19,21 +19,28 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { observer } from "mobx-react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import type { RouteComponentProps } from "react-router";
|
||||||
import { catalogURL } from "../+catalog";
|
import { catalogURL } from "../+catalog";
|
||||||
import type { Cluster } from "../../../main/cluster";
|
|
||||||
import { navigate } from "../../navigation";
|
import { navigate } from "../../navigation";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { TopBar } from "../layout/topbar";
|
import { TopBar } from "../layout/topbar";
|
||||||
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
import { MaterialTooltip } from "../material-tooltip/material-tooltip";
|
||||||
|
import type { IClusterViewRouteParams } from "./cluster-view.route";
|
||||||
|
import type { Cluster } from "../../../main/cluster";
|
||||||
|
import { ClusterStore } from "../../../common/cluster-store";
|
||||||
|
|
||||||
interface Props {
|
interface Props extends RouteComponentProps<IClusterViewRouteParams> {
|
||||||
cluster: Cluster
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ClusterTopbar({ cluster }: Props) {
|
export const ClusterTopbar = observer((props: Props) => {
|
||||||
|
const getCluster = (): Cluster | undefined => {
|
||||||
|
return ClusterStore.getInstance().getById(props.match.params.clusterId);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TopBar label={cluster.name}>
|
<TopBar label={getCluster()?.name}>
|
||||||
<div>
|
<div>
|
||||||
<MaterialTooltip title="Back to Catalog" placement="left">
|
<MaterialTooltip title="Back to Catalog" placement="left">
|
||||||
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(catalogURL())}/>
|
<Icon style={{ cursor: "default" }} material="close" onClick={() => navigate(catalogURL())}/>
|
||||||
@ -41,4 +48,4 @@ export function ClusterTopbar({ cluster }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</TopBar>
|
</TopBar>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import { clusterActivateHandler } from "../../../common/cluster-ipc";
|
|||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
import { navigate } from "../../navigation";
|
import { navigate } from "../../navigation";
|
||||||
import { catalogURL } from "../+catalog/catalog.route";
|
import { catalogURL } from "../+catalog/catalog.route";
|
||||||
import { ClusterTopbar } from "./cluster-topbar";
|
|
||||||
import type { RouteComponentProps } from "react-router-dom";
|
import type { RouteComponentProps } from "react-router-dom";
|
||||||
import type { IClusterViewRouteParams } from "./cluster-view.route";
|
import type { IClusterViewRouteParams } from "./cluster-view.route";
|
||||||
|
|
||||||
@ -104,7 +103,6 @@ export class ClusterView extends React.Component<Props> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="ClusterView flex column align-center">
|
<div className="ClusterView flex column align-center">
|
||||||
{this.cluster && <ClusterTopbar cluster={this.cluster}/>}
|
|
||||||
{this.renderStatus()}
|
{this.renderStatus()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
grid-template-columns: [sidebar] var(--sidebar-width) [contents] 1fr;
|
grid-template-columns: [sidebar] var(--sidebar-width) [contents] 1fr;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
height: calc(100% - var(--main-layout-header));
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
background-color: var(--layoutBackground);
|
background-color: var(--layoutBackground);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
grid-area: topbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user