mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Complete cherry-pick of current cluster injcetablization
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
41a9957ede
commit
ff54c042b6
11
src/common/cluster/current-cluster-channel.ts
Normal file
11
src/common/cluster/current-cluster-channel.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { ClusterId } from "../cluster-types";
|
||||||
|
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token";
|
||||||
|
|
||||||
|
export const currentClusterMessageChannel: MessageChannel<ClusterId> = {
|
||||||
|
id: "current-visible-cluster",
|
||||||
|
};
|
||||||
@ -40,7 +40,6 @@ import clusterFramesInjectable from "../common/cluster-frames.injectable";
|
|||||||
import type { ClusterFrameInfo } from "../common/cluster-frames";
|
import type { ClusterFrameInfo } from "../common/cluster-frames";
|
||||||
import { observable, runInAction } from "mobx";
|
import { observable, runInAction } from "mobx";
|
||||||
import waitForElectronToBeReadyInjectable from "./electron-app/features/wait-for-electron-to-be-ready.injectable";
|
import waitForElectronToBeReadyInjectable from "./electron-app/features/wait-for-electron-to-be-ready.injectable";
|
||||||
import setupListenerForCurrentClusterFrameInjectable from "./start-main-application/lens-window/current-cluster-frame/setup-listener-for-current-cluster-frame.injectable";
|
|
||||||
import setupRunnablesAfterWindowIsOpenedInjectable from "./electron-app/runnables/setup-runnables-after-window-is-opened.injectable";
|
import setupRunnablesAfterWindowIsOpenedInjectable from "./electron-app/runnables/setup-runnables-after-window-is-opened.injectable";
|
||||||
import broadcastMessageInjectable from "../common/ipc/broadcast-message.injectable";
|
import broadcastMessageInjectable from "../common/ipc/broadcast-message.injectable";
|
||||||
import getElectronThemeInjectable from "./electron-app/features/get-electron-theme.injectable";
|
import getElectronThemeInjectable from "./electron-app/features/get-electron-theme.injectable";
|
||||||
@ -178,7 +177,6 @@ const overrideRunnablesHavingSideEffects = (di: DiContainer) => {
|
|||||||
setupShellInjectable,
|
setupShellInjectable,
|
||||||
setupSyncingOfWeblinksInjectable,
|
setupSyncingOfWeblinksInjectable,
|
||||||
setupSystemCaInjectable,
|
setupSystemCaInjectable,
|
||||||
setupListenerForCurrentClusterFrameInjectable,
|
|
||||||
setupRunnablesAfterWindowIsOpenedInjectable,
|
setupRunnablesAfterWindowIsOpenedInjectable,
|
||||||
startCatalogSyncInjectable,
|
startCatalogSyncInjectable,
|
||||||
startKubeConfigSyncInjectable,
|
startKubeConfigSyncInjectable,
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { currentClusterMessageChannel } from "../../../../common/cluster/current-cluster-channel";
|
||||||
|
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||||
|
import currentClusterFrameClusterIdStateInjectable from "./current-cluster-frame-cluster-id-state.injectable";
|
||||||
|
|
||||||
|
const currentVisibileClusterListenerInjectable = getMessageChannelListenerInjectable({
|
||||||
|
id: "current-visibile-cluster",
|
||||||
|
channel: currentClusterMessageChannel,
|
||||||
|
handler: (di) => {
|
||||||
|
const currentClusterFrameState = di.inject(currentClusterFrameClusterIdStateInjectable);
|
||||||
|
|
||||||
|
return clusterId => currentClusterFrameState.set(clusterId);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default currentVisibileClusterListenerInjectable;
|
||||||
@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { ipcMainOn } from "../../../../common/ipc";
|
|
||||||
import { IpcRendererNavigationEvents } from "../../../../renderer/navigation/events";
|
|
||||||
import type { ClusterId } from "../../../../common/cluster-types";
|
|
||||||
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../runnable-tokens/on-load-of-application-injection-token";
|
|
||||||
import currentClusterFrameClusterIdStateInjectable from "./current-cluster-frame-cluster-id-state.injectable";
|
|
||||||
|
|
||||||
const setupListenerForCurrentClusterFrameInjectable = getInjectable({
|
|
||||||
id: "setup-listener-for-current-cluster-frame",
|
|
||||||
|
|
||||||
instantiate: (di) => ({
|
|
||||||
id: "setup-listener-for-current-cluster-frame",
|
|
||||||
run: () => {
|
|
||||||
const currentClusterFrameState = di.inject(currentClusterFrameClusterIdStateInjectable);
|
|
||||||
|
|
||||||
ipcMainOn(
|
|
||||||
IpcRendererNavigationEvents.CLUSTER_VIEW_CURRENT_ID,
|
|
||||||
(event, clusterId: ClusterId) => {
|
|
||||||
currentClusterFrameState.set(clusterId);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
causesSideEffects: true,
|
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default setupListenerForCurrentClusterFrameInjectable;
|
|
||||||
Loading…
Reference in New Issue
Block a user