mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
48d8d985ae
commit
9b9bf47970
9 files changed
+35
-37
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Extensions-api -> Dynamic pages
|
||||
// Extensions-api -> Custom page registration
|
||||
|
||||
import type React from "react";
|
||||
import type { RouteProps } from "react-router";
|
||||
@@ -6,20 +6,14 @@ import type { IconProps } from "../../renderer/components/icon";
|
||||
import type { IClassName } from "../../renderer/utils";
|
||||
import type { TabRoute } from "../../renderer/components/layout/tab-layout";
|
||||
import { BaseRegistry } from "./base-registry";
|
||||
import { computed } from "mobx";
|
||||
|
||||
export enum PageRegistryType {
|
||||
GLOBAL = "lens-scope",
|
||||
CLUSTER = "cluster-view-scope",
|
||||
}
|
||||
|
||||
export interface PageRegistration extends RouteProps {
|
||||
type: PageRegistryType;
|
||||
components: PageComponents;
|
||||
className?: IClassName;
|
||||
url?: string; // initial url to be used for building menus and tabs, otherwise "path" applied by default
|
||||
title?: React.ReactNode; // used in sidebar's & tabs-layout if provided
|
||||
hideInMenu?: boolean; // hide element within app's navigation menu
|
||||
subPages?: (PageRegistration & TabRoute)[];
|
||||
components: PageComponents;
|
||||
}
|
||||
|
||||
export interface PageComponents {
|
||||
@@ -27,14 +21,11 @@ export interface PageComponents {
|
||||
MenuIcon?: React.ComponentType<IconProps>;
|
||||
}
|
||||
|
||||
export class PageRegistry extends BaseRegistry<PageRegistration> {
|
||||
@computed get globalPages() {
|
||||
return this.items.filter(page => page.type === PageRegistryType.GLOBAL);
|
||||
}
|
||||
|
||||
@computed get clusterPages() {
|
||||
return this.items.filter(page => page.type === PageRegistryType.CLUSTER);
|
||||
}
|
||||
export class GlobalPageRegistry extends BaseRegistry<PageRegistration> {
|
||||
}
|
||||
|
||||
export const pageRegistry = new PageRegistry();
|
||||
export class ClusterPageRegistry extends BaseRegistry<PageRegistration> {
|
||||
}
|
||||
|
||||
export const globalPageRegistry = new GlobalPageRegistry();
|
||||
export const clusterPageRegistry = new ClusterPageRegistry();
|
||||
Reference in new issue
Block a user