1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: Switch releaseChannel to not use Initializable at all

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-04-17 16:37:02 -04:00
parent 6fa9e2cde6
commit fc18c61d36
8 changed files with 14 additions and 64 deletions

View File

@ -8,7 +8,6 @@ import { defaultThemeId } from "../vars";
import writeFileInjectable from "../fs/write-file.injectable"; import writeFileInjectable from "../fs/write-file.injectable";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting"; import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import storeMigrationVersionInjectable from "../vars/store-migration-version.injectable"; import storeMigrationVersionInjectable from "../vars/store-migration-version.injectable";
import releaseChannelInjectable from "../vars/release-channel.injectable";
import defaultUpdateChannelInjectable from "../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; import defaultUpdateChannelInjectable from "../../features/application-update/common/selected-update-channel/default-update-channel.injectable";
import writeJsonSyncInjectable from "../fs/write-json-sync.injectable"; import writeJsonSyncInjectable from "../fs/write-json-sync.injectable";
import writeFileSyncInjectable from "../fs/write-file-sync.injectable"; import writeFileSyncInjectable from "../fs/write-file-sync.injectable";
@ -18,6 +17,7 @@ import userPreferencesPersistentStorageInjectable from "../../features/user-pref
import type { ResetTheme } from "../../features/user-preferences/common/reset-theme.injectable"; import type { ResetTheme } from "../../features/user-preferences/common/reset-theme.injectable";
import resetThemeInjectable from "../../features/user-preferences/common/reset-theme.injectable"; import resetThemeInjectable from "../../features/user-preferences/common/reset-theme.injectable";
import type { ClusterStoreModel } from "../../features/cluster/storage/common/storage.injectable"; import type { ClusterStoreModel } from "../../features/cluster/storage/common/storage.injectable";
import releaseChannelInjectable from "../../features/vars/common/release-channel.injectable";
describe("user store tests", () => { describe("user store tests", () => {
let state: UserPreferencesState; let state: UserPreferencesState;
@ -30,10 +30,7 @@ describe("user store tests", () => {
di.override(writeFileInjectable, () => () => Promise.resolve()); di.override(writeFileInjectable, () => () => Promise.resolve());
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data"); di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(releaseChannelInjectable, () => ({ di.override(releaseChannelInjectable, () => "latest");
get: () => "latest" as const,
init: async () => {},
}));
await di.inject(defaultUpdateChannelInjectable).init(); await di.inject(defaultUpdateChannelInjectable).init();

View File

@ -2,13 +2,13 @@
* Copyright (c) OpenLens Authors. All rights reserved. * Copyright (c) OpenLens Authors. All rights reserved.
* 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 releaseChannelInjectable from "../../../../common/vars/release-channel.injectable";
import { updateChannels } from "../update-channels"; import { updateChannels } from "../update-channels";
import { createInitializableState } from "../../../../common/initializable-state/create"; import { createInitializableState } from "../../../../common/initializable-state/create";
import releaseChannelInjectable from "../../../vars/common/release-channel.injectable";
const defaultUpdateChannelInjectable = createInitializableState({ const defaultUpdateChannelInjectable = createInitializableState({
id: "default-update-channel", id: "default-update-channel",
init: (di) => updateChannels[di.inject(releaseChannelInjectable).get()], init: (di) => updateChannels[di.inject(releaseChannelInjectable)],
}); });
export default defaultUpdateChannelInjectable; export default defaultUpdateChannelInjectable;

View File

@ -4,8 +4,8 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx"; import { computed } from "mobx";
import releaseChannelInjectable from "../../../vars/common/release-channel.injectable";
import selectedUpdateChannelInjectable from "../../common/selected-update-channel/selected-update-channel.injectable"; import selectedUpdateChannelInjectable from "../../common/selected-update-channel/selected-update-channel.injectable";
import releaseChannelInjectable from "../../../../common/vars/release-channel.injectable";
const updateCanBeDowngradedInjectable = getInjectable({ const updateCanBeDowngradedInjectable = getInjectable({
id: "update-can-be-downgraded", id: "update-can-be-downgraded",
@ -16,7 +16,7 @@ const updateCanBeDowngradedInjectable = getInjectable({
return computed(() => ( return computed(() => (
selectedUpdateChannel.value.get().id === "latest" selectedUpdateChannel.value.get().id === "latest"
&& releaseChannel.get() !== "latest" && releaseChannel !== "latest"
)); ));
}, },
}); });

View File

@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved. * Copyright (c) OpenLens Authors. All rights reserved.
* 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 { createInitializableState } from "../initializable-state/create"; import { getInjectable } from "@ogre-tools/injectable";
import type { ReleaseChannel } from "../../features/application-update/common/update-channels"; import { semanticBuildVersionInitializable } from "../semantic-build-version/common/token";
import { semanticBuildVersionInitializable } from "../../features/vars/semantic-build-version/common/token";
const releaseChannelInjectable = createInitializableState({ const releaseChannelInjectable = getInjectable({
id: "release-channel", id: "release-channel",
init: (di): ReleaseChannel => { instantiate: (di) => {
const buildSemanticVersion = di.inject(semanticBuildVersionInitializable.stateToken); const buildSemanticVersion = di.inject(semanticBuildVersionInitializable.stateToken);
const currentReleaseChannel = buildSemanticVersion.prerelease[0]; const currentReleaseChannel = buildSemanticVersion.prerelease[0];

View File

@ -4,8 +4,8 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application"; import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
import initReleaseChannelInjectable from "../release-channel/init.injectable";
import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable";
import { semanticBuildVersionInitializationInjectable } from "../../../features/vars/semantic-build-version/main/init.injectable";
const initDefaultUpdateChannelInjectable = getInjectable({ const initDefaultUpdateChannelInjectable = getInjectable({
id: "init-default-update-channel", id: "init-default-update-channel",
@ -15,7 +15,7 @@ const initDefaultUpdateChannelInjectable = getInjectable({
await defaultUpdateChannel.init(); await defaultUpdateChannel.init();
}, },
runAfter: initReleaseChannelInjectable, runAfter: semanticBuildVersionInitializationInjectable,
}), }),
injectionToken: beforeApplicationIsLoadingInjectionToken, injectionToken: beforeApplicationIsLoadingInjectionToken,
}); });

View File

@ -1,23 +0,0 @@
/**
* 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 releaseChannelInjectable from "../../../common/vars/release-channel.injectable";
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
import { semanticBuildVersionInitializationInjectable } from "../../../features/vars/semantic-build-version/main/init.injectable";
const initReleaseChannelInjectable = getInjectable({
id: "init-release-channel",
instantiate: (di) => ({
run: async () => {
const releaseChannel = di.inject(releaseChannelInjectable);
await releaseChannel.init();
},
runAfter: semanticBuildVersionInitializationInjectable,
}),
injectionToken: beforeApplicationIsLoadingInjectionToken,
});
export default initReleaseChannelInjectable;

View File

@ -4,8 +4,8 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens"; import { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens";
import initReleaseChannelInjectable from "../release-channel/init.injectable";
import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable";
import { semanticBuildVersionInitializationInjectable } from "../../../features/vars/semantic-build-version/renderer/init.injectable";
const initDefaultUpdateChannelInjectable = getInjectable({ const initDefaultUpdateChannelInjectable = getInjectable({
id: "init-default-update-channel", id: "init-default-update-channel",
@ -15,7 +15,7 @@ const initDefaultUpdateChannelInjectable = getInjectable({
await defaultUpdateChannel.init(); await defaultUpdateChannel.init();
}, },
runAfter: initReleaseChannelInjectable, runAfter: semanticBuildVersionInitializationInjectable,
}), }),
injectionToken: beforeFrameStartsSecondInjectionToken, injectionToken: beforeFrameStartsSecondInjectionToken,
}); });

View File

@ -1,23 +0,0 @@
/**
* 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 releaseChannelInjectable from "../../../common/vars/release-channel.injectable";
import { semanticBuildVersionInitializationInjectable } from "../../../features/vars/semantic-build-version/renderer/init.injectable";
import { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens";
const initReleaseChannelInjectable = getInjectable({
id: "init-release-channel",
instantiate: (di) => ({
run: async () => {
const releaseChannel = di.inject(releaseChannelInjectable);
await releaseChannel.init();
},
runAfter: semanticBuildVersionInitializationInjectable,
}),
injectionToken: beforeFrameStartsSecondInjectionToken,
});
export default initReleaseChannelInjectable;