mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Reimplement setup for application quit using runnables instead of non-OCP in index.ts
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
9b5bbb99f9
commit
00325229f4
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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 appEventBusInjectable from "../../../../common/app-event-bus/app-event-bus.injectable";
|
||||||
|
import { onApplicationCloseInjectionToken } from "../on-application-close-injection-token";
|
||||||
|
|
||||||
|
const emitCloseToCommandBusInjectable = getInjectable({
|
||||||
|
id: "emit-close-to-command-bus",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const appEventBus = di.inject(appEventBusInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
|
appEventBus.emit({ name: "app", action: "close" });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: onApplicationCloseInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default emitCloseToCommandBusInjectable;
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* 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 lensProtocolRouterMainInjectable from "../../../protocol-handler/lens-protocol-router-main/lens-protocol-router-main.injectable";
|
||||||
|
import { onApplicationCloseInjectionToken } from "../on-application-close-injection-token";
|
||||||
|
|
||||||
|
const makeProtocolRouterNotHaveLoadedRendererInjectable = getInjectable({
|
||||||
|
id: "make-protocol-router-not-have-loaded-renderer",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
|
// This is set to false here so that LPRM can wait to send future lens://
|
||||||
|
// requests until after it loads again
|
||||||
|
lensProtocolRouterMain.rendererLoaded = false;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: onApplicationCloseInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default makeProtocolRouterNotHaveLoadedRendererInjectable;
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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 { onApplicationQuitInjectionToken } from "../on-application-quit-injection-token";
|
||||||
|
import lensProtocolRouterMainInjectable from "../../../../../../protocol-handler/lens-protocol-router-main/lens-protocol-router-main.injectable";
|
||||||
|
|
||||||
|
const cleanUpProtocolRouterMainInjectable = getInjectable({
|
||||||
|
id: "clean-up-protocol-router-main",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
|
lensProtocolRouterMain.cleanup();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: onApplicationQuitInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default cleanUpProtocolRouterMainInjectable;
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* 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 { onApplicationQuitInjectionToken } from "../on-application-quit-injection-token";
|
||||||
|
import { ShellSession } from "../../../../../../shell-session/shell-session";
|
||||||
|
|
||||||
|
const cleanUpShellSessionsInjectable = getInjectable({
|
||||||
|
id: "clean-up-shell-sessions",
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
run: () => {
|
||||||
|
ShellSession.cleanup();
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: onApplicationQuitInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default cleanUpShellSessionsInjectable;
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* 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 { onApplicationQuitInjectionToken } from "./on-application-quit/on-application-quit-injection-token";
|
||||||
|
import { isIntegrationTesting } from "../../../../../common/vars";
|
||||||
|
import { runManyFor } from "../../../run-many-for";
|
||||||
|
import { onApplicationCloseInjectionToken } from "../../on-application-close-injection-token";
|
||||||
|
|
||||||
|
const quitApplicationInjectable = getInjectable({
|
||||||
|
id: "prevent-application-from-closing-involuntarily",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const runMany = runManyFor(di);
|
||||||
|
const runOnApplicationQuit = runMany(onApplicationQuitInjectionToken);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async ({ event }) => {
|
||||||
|
if (!isIntegrationTesting) {
|
||||||
|
// &&!autoUpdateIsRunning) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await runOnApplicationQuit({ event });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
causesSideEffects: true,
|
||||||
|
|
||||||
|
injectionToken: onApplicationCloseInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default quitApplicationInjectable;
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* 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 clusterManagerInjectable from "../../../cluster-manager.injectable";
|
||||||
|
import { onApplicationCloseInjectionToken } from "../on-application-close-injection-token";
|
||||||
|
|
||||||
|
const stopClusterManagerInjectable = getInjectable({
|
||||||
|
id: "stop-cluster-manager",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const clusterManager = di.inject(clusterManagerInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
|
clusterManager.stop(); // close cluster connections
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: onApplicationCloseInjectionToken,
|
||||||
|
|
||||||
|
causesSideEffects: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default stopClusterManagerInjectable;
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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 kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync-manager/kubeconfig-sync-manager.injectable";
|
||||||
|
import { onApplicationCloseInjectionToken } from "../on-application-close-injection-token";
|
||||||
|
|
||||||
|
const stopKubeConfigSyncInjectable = getInjectable({
|
||||||
|
id: "stop-kube-config-sync",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
|
kubeConfigSyncManager.stopSync();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: onApplicationCloseInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default stopKubeConfigSyncInjectable;
|
||||||
Loading…
Reference in New Issue
Block a user