mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Implement a lot of technical requirements for behavioural unit tests
Note: the crux of this was to make routing env-agnostic, and not based on URLs as magic strings, but instead something type-enforced. Note: extension-based routes comply to same exact interface by "late-registering" their routes when installed. Routes are just injectables. Note: another chunk of global shared state is no more. Note: a lot of explicit side effects have been cornered to injectables. Note: a lot of stuff has become reactive as part if this. Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
086604630a
commit
5c8ca2c038
523 files changed
+11727
-5541
No files matched your search
@@ -3,16 +3,15 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import electronMenuItemsInjectable from "../../menu/electron-menu-items.injectable";
|
||||
import directoryForLensLocalStorageInjectable
|
||||
from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
|
||||
import directoryForLensLocalStorageInjectable from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
|
||||
import { initIpcMainHandlers } from "./init-ipc-main-handlers";
|
||||
import getAppMenuItemsInjectable from "../../menu/get-app-menu-items.injectable";
|
||||
|
||||
const initIpcMainHandlersInjectable = getInjectable({
|
||||
id: "init-ipc-main-handlers",
|
||||
|
||||
instantiate: (di) => initIpcMainHandlers({
|
||||
electronMenuItems: di.inject(electronMenuItemsInjectable),
|
||||
getAppMenuItems: () => di.inject(getAppMenuItemsInjectable)(),
|
||||
directoryForLensLocalStorage: di.inject(directoryForLensLocalStorageInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -14,25 +14,22 @@ import { catalogEntityRegistry } from "../../catalog";
|
||||
import { pushCatalogToRenderer } from "../../catalog-pusher";
|
||||
import { ClusterManager } from "../../cluster-manager";
|
||||
import { ResourceApplier } from "../../resource-applier";
|
||||
import { WindowManager } from "../../window-manager";
|
||||
import path from "path";
|
||||
import { remove } from "fs-extra";
|
||||
import { getAppMenu } from "../../menu/menu";
|
||||
import type { MenuRegistration } from "../../menu/menu-registration";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import { onLocationChange, handleWindowAction } from "../../ipc/window";
|
||||
import { openFilePickingDialogChannel } from "../../../common/ipc/dialog";
|
||||
import { showOpenDialog } from "../../ipc/dialog";
|
||||
import { windowActionHandleChannel, windowLocationChangedChannel, windowOpenAppMenuAsContextMenuChannel } from "../../../common/ipc/window";
|
||||
import { getNativeColorTheme } from "../../native-theme";
|
||||
import { getNativeThemeChannel } from "../../../common/ipc/native-theme";
|
||||
import type { MenuItemsOpts } from "../../menu/get-app-menu-items.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
electronMenuItems: IComputedValue<MenuRegistration[]>;
|
||||
getAppMenuItems: () => MenuItemsOpts[];
|
||||
directoryForLensLocalStorage: string;
|
||||
}
|
||||
|
||||
export const initIpcMainHandlers = ({ electronMenuItems, directoryForLensLocalStorage }: Dependencies) => () => {
|
||||
export const initIpcMainHandlers = ({ getAppMenuItems, directoryForLensLocalStorage }: Dependencies) => () => {
|
||||
ipcMainHandle(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
|
||||
return ClusterStore.getInstance()
|
||||
.getById(clusterId)
|
||||
@@ -151,7 +148,9 @@ export const initIpcMainHandlers = ({ electronMenuItems, directoryForLensLocalSt
|
||||
ipcMainHandle(broadcastMainChannel, (event, channel, ...args) => broadcastMessage(channel, ...args));
|
||||
|
||||
ipcMainOn(windowOpenAppMenuAsContextMenuChannel, async (event) => {
|
||||
const menu = Menu.buildFromTemplate(getAppMenu(WindowManager.getInstance(), electronMenuItems.get()));
|
||||
const appMenu = getAppMenuItems();
|
||||
|
||||
const menu = Menu.buildFromTemplate(appMenu);
|
||||
|
||||
menu.popup({
|
||||
...BrowserWindow.fromWebContents(event.sender),
|
||||
|
||||
Reference in new issue
Block a user