mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move shared stuff under common
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
12 files changed
+66
-47
No files matched your search
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import createSyncBoxInjectable from "../../sync-box/create-sync-box.injectable";
|
||||
import type { UpdateChannel } from "../../../main/update-app/update-channels";
|
||||
import type { UpdateChannel } from "../update-channels";
|
||||
|
||||
const discoveredUpdateVersionInjectable = getInjectable({
|
||||
id: "discovered-update-version",
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 type { IComputedValue } from "mobx";
|
||||
import { action, computed, observable } from "mobx";
|
||||
import type { UpdateChannel, UpdateChannelId } from "../update-channels";
|
||||
import { updateChannels } from "../update-channels";
|
||||
|
||||
export interface SelectedUpdateChannel {
|
||||
value: IComputedValue<UpdateChannel>;
|
||||
setValue: (channelId?: UpdateChannelId) => void;
|
||||
}
|
||||
|
||||
// export const defaultUpdateChannel = new SemVer(getAppVersion()).prerelease[0]?.toString() || "latest";
|
||||
|
||||
// const updateChannel: PreferenceDescription<string> = {
|
||||
// fromStore(val) {
|
||||
// return !val || !updateChannels.has(val)
|
||||
// ? defaultUpdateChannel
|
||||
// : val;
|
||||
// },
|
||||
// toStore(val) {
|
||||
// if (!updateChannels.has(val) || val === defaultUpdateChannel) {
|
||||
// return undefined;
|
||||
// }
|
||||
//
|
||||
// return val;
|
||||
// },
|
||||
// };
|
||||
|
||||
const selectedUpdateChannelInjectable = getInjectable({
|
||||
id: "selected-update-channel",
|
||||
|
||||
instantiate: (): SelectedUpdateChannel => {
|
||||
const state = observable.box(updateChannels.latest);
|
||||
|
||||
return {
|
||||
value: computed(() => state.get()),
|
||||
|
||||
setValue: action((channelId) => {
|
||||
const targetUpdateChannel = channelId ? updateChannels[channelId] : updateChannels.latest;
|
||||
|
||||
state.set(targetUpdateChannel);
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default selectedUpdateChannelInjectable;
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export type UpdateChannelId = "alpha" | "beta" | "latest";
|
||||
|
||||
const latestChannel: UpdateChannel = {
|
||||
id: "latest",
|
||||
label: "Stable",
|
||||
moreStableUpdateChannel: null,
|
||||
};
|
||||
|
||||
const betaChannel: UpdateChannel = {
|
||||
id: "beta",
|
||||
label: "Beta",
|
||||
moreStableUpdateChannel: latestChannel,
|
||||
};
|
||||
|
||||
const alphaChannel: UpdateChannel = {
|
||||
id: "alpha",
|
||||
label: "Alpha",
|
||||
moreStableUpdateChannel: betaChannel,
|
||||
};
|
||||
|
||||
export const updateChannels: Record<UpdateChannelId, UpdateChannel> = {
|
||||
latest: latestChannel,
|
||||
beta: betaChannel,
|
||||
alpha: alphaChannel,
|
||||
};
|
||||
|
||||
export interface UpdateChannel {
|
||||
readonly id: UpdateChannelId;
|
||||
readonly label: string;
|
||||
readonly moreStableUpdateChannel: UpdateChannel | null;
|
||||
}
|
||||
Reference in new issue
Block a user