mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Rename exitApp to forceAppExit
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
8ee65f841e
commit
802cbdb096
@ -6,7 +6,7 @@
|
|||||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||||
import type { ClusterManager } from "../../main/cluster/manager";
|
import type { ClusterManager } from "../../main/cluster/manager";
|
||||||
import exitAppInjectable from "../../main/electron-app/features/exit-app.injectable";
|
import forceAppExitInjectable from "../../main/electron-app/features/force-app-exit.injectable";
|
||||||
import clusterManagerInjectable from "../../main/cluster/manager.injectable";
|
import clusterManagerInjectable from "../../main/cluster/manager.injectable";
|
||||||
import stopServicesAndExitAppInjectable from "../../main/stop-services-and-exit-app.injectable";
|
import stopServicesAndExitAppInjectable from "../../main/stop-services-and-exit-app.injectable";
|
||||||
import { testUsingFakeTime, advanceFakeTime } from "../../test-utils/use-fake-time";
|
import { testUsingFakeTime, advanceFakeTime } from "../../test-utils/use-fake-time";
|
||||||
@ -15,7 +15,7 @@ describe("quitting the app using application menu", () => {
|
|||||||
describe("given application has started", () => {
|
describe("given application has started", () => {
|
||||||
let builder: ApplicationBuilder;
|
let builder: ApplicationBuilder;
|
||||||
let clusterManagerStub: ClusterManager;
|
let clusterManagerStub: ClusterManager;
|
||||||
let exitAppMock: jest.Mock;
|
let forceAppExitMock: jest.Mock;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
testUsingFakeTime("2015-10-21T07:28:00Z");
|
testUsingFakeTime("2015-10-21T07:28:00Z");
|
||||||
@ -28,8 +28,8 @@ describe("quitting the app using application menu", () => {
|
|||||||
clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager;
|
clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager;
|
||||||
mainDi.override(clusterManagerInjectable, () => clusterManagerStub);
|
mainDi.override(clusterManagerInjectable, () => clusterManagerStub);
|
||||||
|
|
||||||
exitAppMock = jest.fn();
|
forceAppExitMock = jest.fn();
|
||||||
mainDi.override(exitAppInjectable, () => exitAppMock);
|
mainDi.override(forceAppExitInjectable, () => forceAppExitMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
await builder.render();
|
await builder.render();
|
||||||
@ -59,7 +59,7 @@ describe("quitting the app using application menu", () => {
|
|||||||
it("after insufficient time passes, does not terminate application yet", () => {
|
it("after insufficient time passes, does not terminate application yet", () => {
|
||||||
advanceFakeTime(999);
|
advanceFakeTime(999);
|
||||||
|
|
||||||
expect(exitAppMock).not.toHaveBeenCalled();
|
expect(forceAppExitMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("after sufficient time passes", () => {
|
describe("after sufficient time passes", () => {
|
||||||
@ -68,7 +68,7 @@ describe("quitting the app using application menu", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("terminates application", () => {
|
it("terminates application", () => {
|
||||||
expect(exitAppMock).toHaveBeenCalled();
|
expect(forceAppExitMock).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import electronAppInjectable from "../electron-app.injectable";
|
import electronAppInjectable from "../electron-app.injectable";
|
||||||
|
|
||||||
const exitAppInjectable = getInjectable({
|
const forceAppExitInjectable = getInjectable({
|
||||||
id: "exit-app",
|
id: "force-app-exit",
|
||||||
|
|
||||||
instantiate: (di) => () => {
|
instantiate: (di) => () => {
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
@ -15,4 +15,4 @@ const exitAppInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default exitAppInjectable;
|
export default forceAppExitInjectable;
|
||||||
@ -5,7 +5,7 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
import requestSingleInstanceLockInjectable from "../features/request-single-instance-lock.injectable";
|
import requestSingleInstanceLockInjectable from "../features/request-single-instance-lock.injectable";
|
||||||
import exitAppInjectable from "../features/exit-app.injectable";
|
import forceAppExitInjectable from "../features/force-app-exit.injectable";
|
||||||
|
|
||||||
const enforceSingleApplicationInstanceInjectable = getInjectable({
|
const enforceSingleApplicationInstanceInjectable = getInjectable({
|
||||||
id: "enforce-single-application-instance",
|
id: "enforce-single-application-instance",
|
||||||
@ -13,10 +13,10 @@ const enforceSingleApplicationInstanceInjectable = getInjectable({
|
|||||||
instantiate: (di) => ({
|
instantiate: (di) => ({
|
||||||
run: () => {
|
run: () => {
|
||||||
const requestSingleInstanceLock = di.inject(requestSingleInstanceLockInjectable);
|
const requestSingleInstanceLock = di.inject(requestSingleInstanceLockInjectable);
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const forceAppExit = di.inject(forceAppExitInjectable);
|
||||||
|
|
||||||
if (!requestSingleInstanceLock()) {
|
if (!requestSingleInstanceLock()) {
|
||||||
exitApp();
|
forceAppExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import powerMonitorInjectable from "../features/power-monitor.injectable";
|
import powerMonitorInjectable from "../features/power-monitor.injectable";
|
||||||
import exitAppInjectable from "../features/exit-app.injectable";
|
import forceAppExitInjectable from "../features/force-app-exit.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const setupDeviceShutdownInjectable = getInjectable({
|
const setupDeviceShutdownInjectable = getInjectable({
|
||||||
@ -13,9 +13,9 @@ const setupDeviceShutdownInjectable = getInjectable({
|
|||||||
instantiate: (di) => ({
|
instantiate: (di) => ({
|
||||||
run: () => {
|
run: () => {
|
||||||
const powerMonitor = di.inject(powerMonitorInjectable);
|
const powerMonitor = di.inject(powerMonitorInjectable);
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const forceAppExit = di.inject(forceAppExitInjectable);
|
||||||
|
|
||||||
powerMonitor.on("shutdown", exitApp);
|
powerMonitor.on("shutdown", forceAppExit);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import exitAppInjectable from "../../electron-app/features/exit-app.injectable";
|
import forceAppExitInjectable from "../../electron-app/features/force-app-exit.injectable";
|
||||||
import lensProxyInjectable from "../../lens-proxy/lens-proxy.injectable";
|
import lensProxyInjectable from "../../lens-proxy/lens-proxy.injectable";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
import lensProxyPortInjectable from "../../lens-proxy/lens-proxy-port.injectable";
|
import lensProxyPortInjectable from "../../lens-proxy/lens-proxy-port.injectable";
|
||||||
@ -22,7 +22,7 @@ const setupLensProxyInjectable = getInjectable({
|
|||||||
instantiate: (di) => ({
|
instantiate: (di) => ({
|
||||||
run: async () => {
|
run: async () => {
|
||||||
const lensProxy = di.inject(lensProxyInjectable);
|
const lensProxy = di.inject(lensProxyInjectable);
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const forceAppExit = di.inject(forceAppExitInjectable);
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const lensProxyPort = di.inject(lensProxyPortInjectable);
|
const lensProxyPort = di.inject(lensProxyPortInjectable);
|
||||||
const isWindows = di.inject(isWindowsInjectable);
|
const isWindows = di.inject(isWindowsInjectable);
|
||||||
@ -37,7 +37,7 @@ const setupLensProxyInjectable = getInjectable({
|
|||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
showErrorPopup("Lens Error", `Could not start proxy: ${error?.message || "unknown error"}`);
|
showErrorPopup("Lens Error", `Could not start proxy: ${error?.message || "unknown error"}`);
|
||||||
|
|
||||||
return exitApp();
|
return forceAppExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test proxy connection
|
// test proxy connection
|
||||||
@ -54,7 +54,7 @@ const setupLensProxyInjectable = getInjectable({
|
|||||||
if (buildVersion.get() !== versionFromProxy) {
|
if (buildVersion.get() !== versionFromProxy) {
|
||||||
logger.error("Proxy server responded with invalid response");
|
logger.error("Proxy server responded with invalid response");
|
||||||
|
|
||||||
return exitApp();
|
return forceAppExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("⚡ LensProxy connection OK");
|
logger.info("⚡ LensProxy connection OK");
|
||||||
@ -73,7 +73,7 @@ const setupLensProxyInjectable = getInjectable({
|
|||||||
|
|
||||||
showErrorPopup("Lens Proxy Error", message.join("\n\n"));
|
showErrorPopup("Lens Proxy Error", message.join("\n\n"));
|
||||||
|
|
||||||
return exitApp();
|
return forceAppExit();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
runAfter: initializeBuildVersionInjectable,
|
runAfter: initializeBuildVersionInjectable,
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import exitAppInjectable from "./electron-app/features/exit-app.injectable";
|
import forceAppExitInjectable from "./electron-app/features/force-app-exit.injectable";
|
||||||
import clusterManagerInjectable from "./cluster/manager.injectable";
|
import clusterManagerInjectable from "./cluster/manager.injectable";
|
||||||
import loggerInjectable from "../common/logger.injectable";
|
import loggerInjectable from "../common/logger.injectable";
|
||||||
import closeAllWindowsInjectable from "./start-main-application/lens-window/hide-all-windows/close-all-windows.injectable";
|
import closeAllWindowsInjectable from "./start-main-application/lens-window/hide-all-windows/close-all-windows.injectable";
|
||||||
@ -14,7 +14,7 @@ const stopServicesAndExitAppInjectable = getInjectable({
|
|||||||
id: "stop-services-and-exit-app",
|
id: "stop-services-and-exit-app",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const forceAppExit = di.inject(forceAppExitInjectable);
|
||||||
const clusterManager = di.inject(clusterManagerInjectable);
|
const clusterManager = di.inject(clusterManagerInjectable);
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const closeAllWindows = di.inject(closeAllWindowsInjectable);
|
const closeAllWindows = di.inject(closeAllWindowsInjectable);
|
||||||
@ -27,7 +27,7 @@ const stopServicesAndExitAppInjectable = getInjectable({
|
|||||||
clusterManager.stop();
|
clusterManager.stop();
|
||||||
await stopAllExtensions();
|
await stopAllExtensions();
|
||||||
logger.info("SERVICE:QUIT");
|
logger.info("SERVICE:QUIT");
|
||||||
setTimeout(exitApp, 1000);
|
setTimeout(forceAppExit, 1000);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user