mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch to using messaging from the Feature
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
106 files changed
+266
-270
No files matched your search
@@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable";
|
||||
import { beforeFrameStartsFirstInjectionToken } from "../before-frame-starts/tokens";
|
||||
import { appPathsChannel } from "../../common/app-paths/app-paths-channel";
|
||||
import { requestFromChannelInjectionToken } from "../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
const setupAppPathsInjectable = getInjectable({
|
||||
id: "setup-app-paths",
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { reaction } from "mobx";
|
||||
import { currentClusterMessageChannel } from "../../../common/cluster/current-cluster-channel";
|
||||
import { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import matchedClusterIdInjectable from "../../navigation/matched-cluster-id.injectable";
|
||||
import { beforeMainFrameStartsFirstInjectionToken } from "../tokens";
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { lensProxyCertificateChannel } from "../../common/certificate/lens-proxy-certificate-channel";
|
||||
import requestFromChannelInjectable from "../utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
const requestLensProxyCertificateInjectable = getInjectable({
|
||||
id: "request-lens-proxy-certificate",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return () => requestFromChannel(lensProxyCertificateChannel);
|
||||
},
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ export interface ExtensionInfo {
|
||||
requireConfirmation?: boolean;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
interface NpmPackageVersionDescriptor extends PackageJson {
|
||||
dist: {
|
||||
integrity: string;
|
||||
|
||||
@@ -10,7 +10,6 @@ import { onceDefined } from "@k8slens/utilities";
|
||||
import assert from "assert";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
import type { GetClusterById } from "../../../common/cluster-store/get-by-id.injectable";
|
||||
import type { EmitClusterVisibility } from "./emit-cluster-visibility.injectable";
|
||||
import { getClusterFrameUrl } from "../../../common/utils";
|
||||
|
||||
export interface LensView {
|
||||
@@ -21,7 +20,7 @@ export interface LensView {
|
||||
interface Dependencies {
|
||||
readonly logger: Logger;
|
||||
getClusterById: GetClusterById;
|
||||
emitClusterVisibility: EmitClusterVisibility;
|
||||
emitClusterVisibility: (clusterId: ClusterId | null) => void;
|
||||
}
|
||||
|
||||
export class ClusterFrameHandler {
|
||||
|
||||
+4
-6
@@ -3,18 +3,16 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { MessageChannelHandler } from "../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { clusterVisibilityChannel } from "../../../common/cluster/visibility-channel";
|
||||
|
||||
export type EmitClusterVisibility = MessageChannelHandler<typeof clusterVisibilityChannel>;
|
||||
import type { ClusterId } from "../../../common/cluster-types";
|
||||
|
||||
const emitClusterVisibilityInjectable = getInjectable({
|
||||
id: "emit-cluster-visibility",
|
||||
instantiate: (di): EmitClusterVisibility => {
|
||||
instantiate: (di) => {
|
||||
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return (id) => sendMessageToChannel(clusterVisibilityChannel, id);
|
||||
return (id: ClusterId | null) => sendMessageToChannel(clusterVisibilityChannel, id);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import type { MinimalTrayMenuItem } from "../../../main/tray/electron-tray/elect
|
||||
import electronTrayInjectable from "../../../main/tray/electron-tray/electron-tray.injectable";
|
||||
import { getDiForUnitTesting as getRendererDi } from "../../getDiForUnitTesting";
|
||||
import { getDiForUnitTesting as getMainDi } from "../../../main/getDiForUnitTesting";
|
||||
import { overrideChannels } from "../../../test-utils/channel-fakes/override-channels";
|
||||
import assert from "assert";
|
||||
import { openMenu } from "react-select-event";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
@@ -40,7 +39,7 @@ import { navigateToRouteInjectionToken } from "../../../common/front-end-routing
|
||||
import type { LensMainExtension } from "../../../extensions/lens-main-extension";
|
||||
import type { LensExtension } from "../../../extensions/lens-extension";
|
||||
import extensionInjectable from "../../../extensions/extension-loader/extension/extension.injectable";
|
||||
import { renderFor } from "./renderFor";
|
||||
import { renderFor } from "@k8slens/test-utils";
|
||||
import { RootFrame } from "../../frames/root-frame/root-frame";
|
||||
import { ClusterFrame } from "../../frames/cluster-frame/cluster-frame";
|
||||
import hostedClusterIdInjectable from "../../cluster-frame-context/hosted-cluster-id.injectable";
|
||||
@@ -71,6 +70,7 @@ import { registerFeature } from "@k8slens/feature-core";
|
||||
import { applicationFeatureForElectronMain, testUtils as applicationForElectronTestUtils } from "@k8slens/application-for-electron-main";
|
||||
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
||||
import { testUsingFakeTime } from "../../../test-utils/use-fake-time";
|
||||
import { sendMessageToChannelInjectionToken, testUtils as messagingTestUtils } from "@k8slens/messaging";
|
||||
|
||||
type MainDiCallback = (container: { mainDi: DiContainer }) => void | Promise<void>;
|
||||
type WindowDiCallback = (container: { windowDi: DiContainer }) => void | Promise<void>;
|
||||
@@ -179,7 +179,9 @@ export const getApplicationBuilder = () => {
|
||||
|
||||
testUsingFakeTime();
|
||||
|
||||
const { overrideForWindow, sendToWindow } = overrideChannels(mainDi);
|
||||
const messageBridgeFake = messagingTestUtils.getMessageBridgeFake();
|
||||
|
||||
messageBridgeFake.involve(mainDi);
|
||||
|
||||
const beforeApplicationStartCallbacks: MainDiCallback[] = [];
|
||||
const afterApplicationStartCallbacks: MainDiCallback[] = [];
|
||||
@@ -229,7 +231,8 @@ export const getApplicationBuilder = () => {
|
||||
|
||||
const windowDi = getRendererDi();
|
||||
|
||||
overrideForWindow(windowDi, windowId);
|
||||
messageBridgeFake.involve(windowDi);
|
||||
|
||||
overrideFsWithFakes(windowDi);
|
||||
|
||||
runInAction(() => {
|
||||
@@ -284,8 +287,10 @@ export const getApplicationBuilder = () => {
|
||||
);
|
||||
},
|
||||
|
||||
send: (arg) => {
|
||||
sendToWindow(windowId, arg);
|
||||
send: ({ channel: channelId, data }) => {
|
||||
const sendMessageToChannel = mainDi.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
sendMessageToChannel({ id: channelId }, data);
|
||||
},
|
||||
|
||||
reload: () => {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { rootFrameHasRenderedChannel } from "../../../common/root-frame/root-frame-rendered-channel";
|
||||
|
||||
const broadcastThatRootFrameIsRenderedInjectable = getInjectable({
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import { noop, chunk } from "lodash/fp";
|
||||
import { createContainer, isInjectable } from "@ogre-tools/injectable";
|
||||
import requestFromChannelInjectable from "./utils/channel/request-from-channel.injectable";
|
||||
import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes";
|
||||
import terminalSpawningPoolInjectable from "./components/dock/terminal/terminal-spawning-pool.injectable";
|
||||
import hostedClusterIdInjectable from "./cluster-frame-context/hosted-cluster-id.injectable";
|
||||
@@ -18,6 +17,8 @@ import type { GlobalOverride } from "@k8slens/test-utils";
|
||||
import { setLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { registerInjectableReact } from "@ogre-tools/injectable-react";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { messagingFeature, testUtils as messagingTestUtils } from "@k8slens/messaging";
|
||||
|
||||
export const getDiForUnitTesting = () => {
|
||||
const environment = "renderer";
|
||||
@@ -27,6 +28,10 @@ export const getDiForUnitTesting = () => {
|
||||
registerInjectableReact(di);
|
||||
setLegacyGlobalDiForExtensionApi(di, environment);
|
||||
|
||||
runInAction(() => {
|
||||
registerFeature(di, messagingFeature, messagingTestUtils.messagingFeatureForUnitTesting);
|
||||
});
|
||||
|
||||
di.preventSideEffects();
|
||||
|
||||
runInAction(() => {
|
||||
@@ -63,8 +68,6 @@ export const getDiForUnitTesting = () => {
|
||||
di.override(requestAnimationFrameInjectable, () => (callback) => callback());
|
||||
di.override(watchHistoryStateInjectable, () => () => () => {});
|
||||
|
||||
di.override(requestFromChannelInjectable, () => () => Promise.resolve(undefined as never));
|
||||
|
||||
getOverrideFsWithFakes()(di);
|
||||
|
||||
return di;
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { kubectlApplyAllChannel, kubectlApplyAllInjectionToken } from "../../common/kube-helpers/channels";
|
||||
import requestFromChannelInjectable from "../utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
const kubectlApplyAllInjectable = getInjectable({
|
||||
id: "kubectl-apply-all",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (req) => requestFromChannel(kubectlApplyAllChannel, req);
|
||||
},
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { kubectlDeleteAllChannel, kubectlDeleteAllInjectionToken } from "../../common/kube-helpers/channels";
|
||||
import requestFromChannelInjectable from "../utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
const kubectlDeleteAllInjectable = getInjectable({
|
||||
id: "kubectl-delete-all",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (req) => requestFromChannel(kubectlDeleteAllChannel, req);
|
||||
},
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { InjectionToken } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import currentlyInClusterFrameInjectable from "../routes/currently-in-cluster-frame.injectable";
|
||||
import { appNavigationChannel } from "../../common/front-end-routing/app-navigation-channel";
|
||||
import { clusterFrameNavigationChannel } from "../../common/front-end-routing/cluster-frame-navigation-channel";
|
||||
import focusWindowInjectable from "./focus-window.injectable";
|
||||
import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token";
|
||||
import type { MessageChannel, MessageChannelListener } from "../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { messageChannelListenerInjectionToken } from "../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { MessageChannel, MessageChannelListener } from "@k8slens/messaging";
|
||||
import { messageChannelListenerInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
const navigationChannelListenerInjectable = getInjectable({
|
||||
id: "navigation-channel-listener",
|
||||
|
||||
instantiate: (di) => {
|
||||
instantiate: (di): MessageChannelListener<MessageChannel<string>> => {
|
||||
const currentlyInClusterFrame = di.inject(currentlyInClusterFrameInjectable);
|
||||
const focusWindow = di.inject(focusWindowInjectable);
|
||||
const navigateToUrl = di.inject(navigateToUrlInjectionToken);
|
||||
|
||||
return {
|
||||
id: 'navigation-channel-listener',
|
||||
channel: currentlyInClusterFrame
|
||||
? clusterFrameNavigationChannel
|
||||
: appNavigationChannel,
|
||||
@@ -34,7 +34,8 @@ const navigationChannelListenerInjectable = getInjectable({
|
||||
},
|
||||
};
|
||||
},
|
||||
injectionToken: messageChannelListenerInjectionToken as InjectionToken<MessageChannelListener<MessageChannel<string>>, void>,
|
||||
|
||||
injectionToken: messageChannelListenerInjectionToken
|
||||
});
|
||||
|
||||
export default navigationChannelListenerInjectable;
|
||||
@@ -4,14 +4,14 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { resolveSystemProxyInjectionToken } from "../../../common/utils/resolve-system-proxy/resolve-system-proxy-injection-token";
|
||||
import requestFromChannelInjectable from "../channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { resolveSystemProxyChannel } from "../../../common/utils/resolve-system-proxy/resolve-system-proxy-channel";
|
||||
|
||||
const resolveSystemProxyInjectable = getInjectable({
|
||||
id: "resolve-system-proxy-for-renderer",
|
||||
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return async (url) => requestFromChannel(resolveSystemProxyChannel, url);
|
||||
},
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens";
|
||||
import { syncBoxInitialValueChannel } from "../../../common/utils/sync-box/channels";
|
||||
import createSyncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { runInAction } from "mobx";
|
||||
import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token";
|
||||
import assert from "assert";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { createInitializableState } from "../../../common/initializable-state/create";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { buildVersionChannel, buildVersionInjectionToken } from "../../../common/vars/build-semantic-version.injectable";
|
||||
|
||||
const buildVersionInjectable = createInitializableState({
|
||||
|
||||
Reference in new issue
Block a user