mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace CatalogEntityDetailRegistry with an injectable solution (#6605)
* Replace EntityDetailRegistry with an injectable solution - Add some behavioural tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update snapshots Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix import error Signed-off-by: Sebastian Malton <sebastian@malton.name> * Simplify loading extensions Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update snapshot Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove the last reminents of BaseRegistry Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix import errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix TypeError when loading extensions Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update snapshots Signed-off-by: Sebastian Malton <sebastian@malton.name> * Cleanup LensExtensions Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove bad comment Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
1acacbb7ef
commit
9ba92cb072
78 files changed
+15151
-573
No files matched your search
+2
-2
@@ -4,13 +4,13 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { initClusterFrame } from "./init-cluster-frame";
|
||||
import extensionLoaderInjectable from "../../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../../api/catalog/entity/registry.injectable";
|
||||
import frameRoutingIdInjectable from "./frame-routing-id/frame-routing-id.injectable";
|
||||
import hostedClusterInjectable from "../../../cluster-frame-context/hosted-cluster.injectable";
|
||||
import clusterFrameContextInjectable from "../../../cluster-frame-context/cluster-frame-context.injectable";
|
||||
import assert from "assert";
|
||||
import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
|
||||
import loadExtensionsInjectable from "../../load-extensions.injectable";
|
||||
|
||||
const initClusterFrameInjectable = getInjectable({
|
||||
id: "init-cluster-frame",
|
||||
@@ -22,7 +22,7 @@ const initClusterFrameInjectable = getInjectable({
|
||||
|
||||
return initClusterFrame({
|
||||
hostedCluster,
|
||||
loadExtensions: di.inject(extensionLoaderInjectable).loadOnClusterRenderer,
|
||||
loadExtensions: di.inject(loadExtensionsInjectable),
|
||||
catalogEntityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||
frameRoutingId: di.inject(frameRoutingIdInjectable),
|
||||
emitAppEvent: di.inject(emitAppEventInjectable),
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import type { CatalogEntityRegistry } from "../../../api/catalog/entity/registry";
|
||||
import logger from "../../../../main/logger";
|
||||
import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { Notifications } from "../../../components/notifications";
|
||||
import type { CatalogEntity } from "../../../../common/catalog";
|
||||
import { when } from "mobx";
|
||||
import type { ClusterFrameContext } from "../../../cluster-frame-context/cluster-frame-context";
|
||||
import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
|
||||
@@ -16,7 +14,7 @@ import type { EmitAppEvent } from "../../../../common/app-event-bus/emit-event.i
|
||||
|
||||
interface Dependencies {
|
||||
hostedCluster: Cluster;
|
||||
loadExtensions: (getCluster: () => CatalogEntity) => void;
|
||||
loadExtensions: () => void;
|
||||
catalogEntityRegistry: CatalogEntityRegistry;
|
||||
frameRoutingId: number;
|
||||
emitAppEvent: EmitAppEvent;
|
||||
@@ -53,7 +51,7 @@ export const initClusterFrame = ({
|
||||
when(
|
||||
() => catalogEntityRegistry.items.get().length > 0,
|
||||
() =>
|
||||
loadExtensions(() => catalogEntityRegistry.activeEntity as KubernetesCluster),
|
||||
loadExtensions(),
|
||||
{
|
||||
timeout: 15_000,
|
||||
onError: (error) => {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import extensionLoaderInjectable from "../../extensions/extension-loader/extension-loader.injectable";
|
||||
|
||||
const loadExtensionsInjectable = getInjectable({
|
||||
id: "load-extensions",
|
||||
instantiate: (di) => {
|
||||
const extensionLoader = di.inject(extensionLoaderInjectable);
|
||||
|
||||
return () => extensionLoader.autoInitExtensions();
|
||||
},
|
||||
});
|
||||
|
||||
export default loadExtensionsInjectable;
|
||||
@@ -4,17 +4,17 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { initRootFrame } from "./init-root-frame";
|
||||
import extensionLoaderInjectable from "../../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import ipcRendererInjectable from "../../../utils/channel/ipc-renderer.injectable";
|
||||
import bindProtocolAddRouteHandlersInjectable from "../../../protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.injectable";
|
||||
import lensProtocolRouterRendererInjectable from "../../../protocol-handler/lens-protocol-router-renderer/lens-protocol-router-renderer.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../../api/catalog/entity/registry.injectable";
|
||||
import registerIpcListenersInjectable from "../../../ipc/register-ipc-listeners.injectable";
|
||||
import loadExtensionsInjectable from "../../load-extensions.injectable";
|
||||
|
||||
const initRootFrameInjectable = getInjectable({
|
||||
id: "init-root-frame",
|
||||
instantiate: (di) => initRootFrame({
|
||||
loadExtensions: di.inject(extensionLoaderInjectable).loadOnClusterManagerRenderer,
|
||||
loadExtensions: di.inject(loadExtensionsInjectable),
|
||||
registerIpcListeners: di.inject(registerIpcListenersInjectable),
|
||||
ipcRenderer: di.inject(ipcRendererInjectable),
|
||||
bindProtocolAddRouteHandlers: di.inject(bindProtocolAddRouteHandlersInjectable),
|
||||
|
||||
Reference in new issue
Block a user