1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add cluster modals registrator

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-10-10 10:16:48 +03:00
parent 032e6d968c
commit a12f5d7872
5 changed files with 54 additions and 0 deletions

View File

@ -33,6 +33,7 @@ export class LensRendererExtension extends LensExtension<LensRendererExtensionDe
globalPages: registries.PageRegistration[] = [];
clusterPages: registries.PageRegistration[] = [];
clusterPageMenus: registries.ClusterPageMenuRegistration[] = [];
clusterModals: registries.ClusterModalRegistration[] = [];
kubeObjectStatusTexts: KubeObjectStatusRegistration[] = [];
appPreferences: AppPreferenceRegistration[] = [];
appPreferenceTabs: AppPreferenceTabRegistration[] = [];

View File

@ -10,3 +10,4 @@ export * from "./page-menu-registry";
export * from "./entity-setting-registry";
export * from "./catalog-entity-detail-registry";
export * from "./protocol-handler";
export * from "./modal-registry";

View File

@ -0,0 +1,10 @@
// Extensions-api -> Cluster frame custom modal registration
import type { IComputedValue } from "mobx";
export interface ClusterModalRegistration {
id: string;
component: React.ComponentType;
visible?: IComputedValue<boolean>;
}

View File

@ -0,0 +1,17 @@
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import { clusterFrameChildComponentInjectionToken } from "../frames/cluster-frame/cluster-frame-child-component-injection-token";
const clusterModalsClusterFrameChildComponentInjectable = getInjectable({
id: "cluster-modals-cluster-frame-child-component",
instantiate: () => ({
id: "cluster-modals",
shouldRender: computed(() => true),
Component: ClusterModals,
}),
injectionToken: clusterFrameChildComponentInjectionToken,
});
export default clusterModalsClusterFrameChildComponentInjectable;

View File

@ -0,0 +1,25 @@
import { getInjectable } from "@ogre-tools/injectable";
import { extensionRegistratorInjectionToken } from "../../extensions/extension-loader/extension-registrator-injection-token";
import type { LensRendererExtension } from "../../extensions/lens-renderer-extension";
const clusterModalsRegistratorInjectable = getInjectable({
id: "cluster-modals-registrator",
instantiate: (): ExtensionRegistrator => {
return (ext) => {
const extension = ext as LensRendererExtension;
return extension.clusterModals.map((registration) => {
return {
id: registration.id,
Component: registration.component,
visible: registration.visible,
}
})
};
},
injectionToken: extensionRegistratorInjectionToken,
});
export default clusterModalsRegistratorInjectable;