mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Send LensMainExtension.nagivate calls to renderer before navigating (#3082)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
dc2d7a08d3
commit
c3c944cd30
12 files changed
+100
-51
No files matched your search
@@ -26,23 +26,20 @@ import type { PageTarget, RegisteredPage } from "./page-registry";
|
||||
import type { LensExtension } from "../lens-extension";
|
||||
import { BaseRegistry } from "./base-registry";
|
||||
|
||||
export interface PageMenuRegistration {
|
||||
target?: PageTarget;
|
||||
title: React.ReactNode;
|
||||
components: PageMenuComponents;
|
||||
}
|
||||
|
||||
export interface ClusterPageMenuRegistration extends PageMenuRegistration {
|
||||
export interface ClusterPageMenuRegistration {
|
||||
id?: string;
|
||||
parentId?: string;
|
||||
target?: PageTarget;
|
||||
title: React.ReactNode;
|
||||
components: ClusterPageMenuComponents;
|
||||
}
|
||||
|
||||
export interface PageMenuComponents {
|
||||
export interface ClusterPageMenuComponents {
|
||||
Icon: React.ComponentType<IconProps>;
|
||||
}
|
||||
|
||||
export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> {
|
||||
add(items: T[], ext: LensExtension) {
|
||||
export class ClusterPageMenuRegistry extends BaseRegistry<ClusterPageMenuRegistration> {
|
||||
add(items: ClusterPageMenuRegistration[], ext: LensExtension) {
|
||||
const normalizedItems = items.map(menuItem => {
|
||||
menuItem.target = {
|
||||
extensionId: ext.name,
|
||||
@@ -54,9 +51,7 @@ export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegist
|
||||
|
||||
return super.add(normalizedItems);
|
||||
}
|
||||
}
|
||||
|
||||
export class ClusterPageMenuRegistry extends PageMenuRegistry<ClusterPageMenuRegistration> {
|
||||
getRootItems() {
|
||||
return this.getItems().filter((item) => !item.parentId);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user