diff --git a/src/behaviours/application-update/installing-update-using-topbar-button.test.tsx b/src/behaviours/application-update/installing-update-using-topbar-button.test.tsx index 6e236aee61..a2f1d9be5e 100644 --- a/src/behaviours/application-update/installing-update-using-topbar-button.test.tsx +++ b/src/behaviours/application-update/installing-update-using-topbar-button.test.tsx @@ -1,6 +1,11 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ import type { AsyncFnMock } from "@async-fn/jest"; import asyncFn from "@async-fn/jest"; -import { act, RenderResult } from "@testing-library/react"; +import type { RenderResult } from "@testing-library/react"; +import { act } from "@testing-library/react"; import type { CheckForPlatformUpdates } from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable"; @@ -67,7 +72,7 @@ describe("encourage user to update when sufficient time passed since update was rendererDi.permitSideEffects(closeWindowInjectable); rendererDi.permitSideEffects(maximizeWindowInjectable); rendererDi.permitSideEffects(toggleMaximizeWindowInjectable); - }) + }); }); describe("when started", () => { @@ -109,13 +114,13 @@ describe("encourage user to update when sufficient time passed since update was const button = rendered.queryByTestId("update-button"); expect(button).toBeInTheDocument(); - }) + }); it("has soft emotional indication in the button", () => { const button = rendered.getByTestId("update-button"); - expect(button).toHaveAttribute("data-warning-level", "light") - }) + expect(button).toHaveAttribute("data-warning-level", "light"); + }); describe("when button is clicked", () => { it("shows dropdown with update item", () => { @@ -124,7 +129,7 @@ describe("encourage user to update when sufficient time passed since update was act(() => button?.click()); expect(rendered.getByTestId("update-lens-menu-item")).toBeInTheDocument(); - }) + }); it("when selected update now, restarts the application to update", () => { const button = rendered.queryByTestId("update-button"); @@ -136,7 +141,7 @@ describe("encourage user to update when sufficient time passed since update was act(() => updateMenuItem?.click()); expect(restartAndInstallUpdate).toBeCalled(); - }) + }); describe("when dropdown closed without clicking update item", () => { it("does not restart the application to update", async () => { @@ -147,46 +152,46 @@ describe("encourage user to update when sufficient time passed since update was act(() => button?.click()); expect(restartAndInstallUpdate).not.toBeCalled(); - }) - }) - }) + }); + }); + }); describe("given just enough time passes for medium update encouragement", () => { beforeAll(() => { jest.useFakeTimers(); - }) + }); it("has medium emotional indication in the button", () => { const button = rendered.getByTestId("update-button"); jest.advanceTimersByTime(daysToMilliseconds(22)); - expect(button).toHaveAttribute("data-warning-level", "medium") - }) + expect(button).toHaveAttribute("data-warning-level", "medium"); + }); afterAll(() => { jest.useRealTimers(); - }) - }) + }); + }); describe("given just enough time passes for severe update encouragement", () => { beforeAll(() => { jest.useFakeTimers(); - }) + }); it("has severe emotional indication in the button", () => { const button = rendered.getByTestId("update-button"); jest.advanceTimersByTime(daysToMilliseconds(26)); - expect(button).toHaveAttribute("data-warning-level", "high") - }) + expect(button).toHaveAttribute("data-warning-level", "high"); + }); afterAll(() => { jest.useRealTimers(); - }) - }) + }); + }); }); }); }); -}); \ No newline at end of file +}); diff --git a/src/common/application-update/update-warning-level/restart-and-install-update-channel.injectable.ts b/src/common/application-update/update-warning-level/restart-and-install-update-channel.injectable.ts index 9ee9f89ee0..b6d811e101 100644 --- a/src/common/application-update/update-warning-level/restart-and-install-update-channel.injectable.ts +++ b/src/common/application-update/update-warning-level/restart-and-install-update-channel.injectable.ts @@ -3,7 +3,8 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { MessageChannel, messageChannelInjectionToken } from "../../utils/channel/message-channel-injection-token"; +import type { MessageChannel } from "../../utils/channel/message-channel-injection-token"; +import { messageChannelInjectionToken } from "../../utils/channel/message-channel-injection-token"; export type RestartAndInstallUpdateChannel = MessageChannel; diff --git a/src/common/application-update/update-warning-level/update-warning-level.injectable.ts b/src/common/application-update/update-warning-level/update-warning-level.injectable.ts index 694fff6842..11a94326ba 100644 --- a/src/common/application-update/update-warning-level/update-warning-level.injectable.ts +++ b/src/common/application-update/update-warning-level/update-warning-level.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 createSyncBoxInjectable from "../../utils/sync-box/create-sync-box.injectable"; import { syncBoxInjectionToken } from "../../utils/sync-box/sync-box-injection-token"; @@ -9,12 +13,12 @@ const updateWarningLevelInjectable = getInjectable({ const createSyncBox = di.inject(createSyncBoxInjectable); return createSyncBox<"light" | "medium" | "high" | "">( - "update-warning-level", - "", - ); + "update-warning-level", + "", + ); }, injectionToken: syncBoxInjectionToken, }); -export default updateWarningLevelInjectable; \ No newline at end of file +export default updateWarningLevelInjectable; diff --git a/src/main/application-update/update-warning-level/periodical-check-for-update-warning.injectable.ts b/src/main/application-update/update-warning-level/periodical-check-for-update-warning.injectable.ts index 8c1dc144bc..f907f32318 100644 --- a/src/main/application-update/update-warning-level/periodical-check-for-update-warning.injectable.ts +++ b/src/main/application-update/update-warning-level/periodical-check-for-update-warning.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 { getStartableStoppable } from "../../../common/utils/get-startable-stoppable"; import setUpdateWarningLevelInjectable from "./set-update-warning-level.injectable"; @@ -26,4 +30,4 @@ const periodicalCheckForUpdateWarningInjectable = getInjectable({ causesSideEffects: true, }); -export default periodicalCheckForUpdateWarningInjectable; \ No newline at end of file +export default periodicalCheckForUpdateWarningInjectable; diff --git a/src/main/application-update/update-warning-level/set-update-downloaded-date.injectable.ts b/src/main/application-update/update-warning-level/set-update-downloaded-date.injectable.ts index c7fea2b665..3cbd94dea7 100644 --- a/src/main/application-update/update-warning-level/set-update-downloaded-date.injectable.ts +++ b/src/main/application-update/update-warning-level/set-update-downloaded-date.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 updateDownloadedDateInjectable from "./update-downloaded-date.injectable"; @@ -9,8 +13,8 @@ const setUpdateDownloadedDateInjectable = getInjectable({ return (date: Date) => { downloadedDate.set(date); - } - } + }; + }, }); -export default setUpdateDownloadedDateInjectable; \ No newline at end of file +export default setUpdateDownloadedDateInjectable; diff --git a/src/main/application-update/update-warning-level/set-update-warning-level.injectable.ts b/src/main/application-update/update-warning-level/set-update-warning-level.injectable.ts index 5b6db73d71..23248bab90 100644 --- a/src/main/application-update/update-warning-level/set-update-warning-level.injectable.ts +++ b/src/main/application-update/update-warning-level/set-update-warning-level.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 updateDownloadedDateInjectable from "./update-downloaded-date.injectable"; import { UpdateWarningLevelCalculator } from "./update-warning-level-calculator"; @@ -12,9 +16,10 @@ const setUpdateWarningLevelInjectable = getInjectable({ return () => { const newLevel = new UpdateWarningLevelCalculator(updateDownloadedDate.value.get()).get(); + updateWarningLevel.set(newLevel); - } - } + }; + }, }); -export default setUpdateWarningLevelInjectable; \ No newline at end of file +export default setUpdateWarningLevelInjectable; diff --git a/src/main/application-update/update-warning-level/start-checking-for-update-warning.injectable.ts b/src/main/application-update/update-warning-level/start-checking-for-update-warning.injectable.ts index b5b21f96a0..3282095371 100644 --- a/src/main/application-update/update-warning-level/start-checking-for-update-warning.injectable.ts +++ b/src/main/application-update/update-warning-level/start-checking-for-update-warning.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token"; import downloadUpdateInjectable from "../download-update/download-update.injectable"; diff --git a/src/main/application-update/update-warning-level/update-downloaded-date.injectable.ts b/src/main/application-update/update-warning-level/update-downloaded-date.injectable.ts index b5712eaa07..3d02dd6862 100644 --- a/src/main/application-update/update-warning-level/update-downloaded-date.injectable.ts +++ b/src/main/application-update/update-warning-level/update-downloaded-date.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 createSyncBoxInjectable from "../../../common/utils/sync-box/create-sync-box.injectable"; import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token"; @@ -9,12 +13,12 @@ const updateDownloadedDateInjectable = getInjectable({ const createSyncBox = di.inject(createSyncBoxInjectable); return createSyncBox( - "update-downloaded-date", - null, - ); + "update-downloaded-date", + null, + ); }, injectionToken: syncBoxInjectionToken, }); -export default updateDownloadedDateInjectable; \ No newline at end of file +export default updateDownloadedDateInjectable; diff --git a/src/main/application-update/update-warning-level/update-warning-level-calculator.ts b/src/main/application-update/update-warning-level/update-warning-level-calculator.ts index 86efda568b..613cd45bb0 100644 --- a/src/main/application-update/update-warning-level/update-warning-level-calculator.ts +++ b/src/main/application-update/update-warning-level/update-warning-level-calculator.ts @@ -1,12 +1,14 @@ - - +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ type WarningLevel = "high" | "medium" | "light" | ""; export class UpdateWarningLevelCalculator { private onceADay = 1000 * 60 * 60 * 24; private level: WarningLevel = ""; - constructor (private updateDownloadedDate: Date | null) { + constructor(private updateDownloadedDate: Date | null) { } get(): WarningLevel { @@ -48,4 +50,4 @@ export class UpdateWarningLevelCalculator { this.level = "light"; } } -} \ No newline at end of file +} diff --git a/src/renderer/components/update-button/restart-and-install-update.injectable.ts b/src/renderer/components/update-button/restart-and-install-update.injectable.ts index fe1f7d2a27..5aecaafe2a 100644 --- a/src/renderer/components/update-button/restart-and-install-update.injectable.ts +++ b/src/renderer/components/update-button/restart-and-install-update.injectable.ts @@ -1,3 +1,7 @@ +/** + * 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 restartAndInstallUpdateChannel from "../../../common/application-update/update-warning-level/restart-and-install-update-channel.injectable"; import messageToChannelInjectable from "../../utils/channel/message-to-channel.injectable"; @@ -15,4 +19,4 @@ const restartAndInstallUpdateInjectable = getInjectable({ }, }); -export default restartAndInstallUpdateInjectable; \ No newline at end of file +export default restartAndInstallUpdateInjectable; diff --git a/src/renderer/components/update-button/update-button.tsx b/src/renderer/components/update-button/update-button.tsx index 5654eaabf3..7d0e030d06 100644 --- a/src/renderer/components/update-button/update-button.tsx +++ b/src/renderer/components/update-button/update-button.tsx @@ -14,7 +14,8 @@ import { Icon } from "../icon"; import { withInjectables } from "@ogre-tools/injectable-react"; import { observer } from "mobx-react"; import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level/update-warning-level.injectable"; -import { computed, IComputedValue } from "mobx"; +import type { IComputedValue } from "mobx"; +import { computed } from "mobx"; import restartAndInstallUpdateInjectable from "./restart-and-install-update.injectable"; interface UpdateButtonProps extends HTMLAttributes {