mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add ability to configure lens release channel (#3971)
This commit is contained in:
parent
b9cee0cbc7
commit
9c94c19a4f
@ -260,6 +260,32 @@ const editorConfiguration: PreferenceDescription<EditorConfiguration, EditorConf
|
||||
},
|
||||
};
|
||||
|
||||
const defaultUpdateChannel = "latest";
|
||||
const updateChannels = new Map([
|
||||
[defaultUpdateChannel, {
|
||||
label: "Stable"
|
||||
}],
|
||||
["beta", {
|
||||
label: "Beta"
|
||||
}],
|
||||
["alpha", {
|
||||
label: "Alpha"
|
||||
}],
|
||||
]);
|
||||
|
||||
const updateChannel: PreferenceDescription<string> = {
|
||||
fromStore(val) {
|
||||
return updateChannels.has(val) ? val : defaultUpdateChannel;
|
||||
},
|
||||
toStore(val) {
|
||||
if (!updateChannels.has(val) || val === defaultUpdateChannel) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
type PreferencesModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<infer T, any> ? T : never;
|
||||
type UserStoreModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<any, infer T> ? T : never;
|
||||
|
||||
@ -288,4 +314,10 @@ export const DESCRIPTORS = {
|
||||
syncKubeconfigEntries,
|
||||
editorConfiguration,
|
||||
terminalCopyOnSelect,
|
||||
updateChannel,
|
||||
};
|
||||
|
||||
export const CONSTANTS = {
|
||||
defaultUpdateChannel,
|
||||
updateChannels,
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ import { appEventBus } from "../event-bus";
|
||||
import path from "path";
|
||||
import { fileNameMigration } from "../../migrations/user-store";
|
||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
||||
import { DESCRIPTORS, KubeconfigSyncValue, UserPreferencesModel, EditorConfiguration } from "./preferences-helpers";
|
||||
import { DESCRIPTORS, KubeconfigSyncValue, UserPreferencesModel, EditorConfiguration, CONSTANTS } from "./preferences-helpers";
|
||||
import logger from "../../main/logger";
|
||||
import type { monaco } from "react-monaco-editor";
|
||||
import { getPath } from "../utils/getPath";
|
||||
@ -75,6 +75,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
@observable downloadBinariesPath?: string;
|
||||
@observable kubectlBinariesPath?: string;
|
||||
@observable terminalCopyOnSelect: boolean;
|
||||
@observable updateChannel?: string;
|
||||
|
||||
/**
|
||||
* Download kubectl binaries matching cluster version
|
||||
@ -106,6 +107,10 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
return this.shell || process.env.SHELL || process.env.PTYSHELL;
|
||||
}
|
||||
|
||||
@computed get isAllowedToDowngrade(): boolean {
|
||||
return this.updateChannel !== CONSTANTS.defaultUpdateChannel;
|
||||
}
|
||||
|
||||
startMainReactions() {
|
||||
// track telemetry availability
|
||||
reaction(() => this.allowTelemetry, allowed => {
|
||||
@ -218,6 +223,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
this.syncKubeconfigEntries.replace(DESCRIPTORS.syncKubeconfigEntries.fromStore(preferences?.syncKubeconfigEntries));
|
||||
this.editorConfiguration = DESCRIPTORS.editorConfiguration.fromStore(preferences?.editorConfiguration);
|
||||
this.terminalCopyOnSelect = DESCRIPTORS.terminalCopyOnSelect.fromStore(preferences?.terminalCopyOnSelect);
|
||||
this.updateChannel = DESCRIPTORS.updateChannel.fromStore(preferences?.updateChannel);
|
||||
}
|
||||
|
||||
toJSON(): UserStoreModel {
|
||||
@ -240,6 +246,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
syncKubeconfigEntries: DESCRIPTORS.syncKubeconfigEntries.toStore(this.syncKubeconfigEntries),
|
||||
editorConfiguration: DESCRIPTORS.editorConfiguration.toStore(this.editorConfiguration),
|
||||
terminalCopyOnSelect: DESCRIPTORS.terminalCopyOnSelect.toStore(this.terminalCopyOnSelect),
|
||||
updateChannel: DESCRIPTORS.updateChannel.toStore(this.updateChannel),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import { areArgsUpdateAvailableToBackchannel, AutoUpdateLogPrefix, broadcastMess
|
||||
import { once } from "lodash";
|
||||
import { ipcMain } from "electron";
|
||||
import { nextUpdateChannel } from "./utils/update-channel";
|
||||
import { UserStore } from "../common/user-store";
|
||||
|
||||
const updateChannel = autoUpdater.channel;
|
||||
let installVersion: null | string = null;
|
||||
@ -58,9 +59,13 @@ export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24
|
||||
return;
|
||||
}
|
||||
|
||||
const us = UserStore.getInstance();
|
||||
|
||||
autoUpdater.logger = logger;
|
||||
autoUpdater.autoDownload = false;
|
||||
autoUpdater.autoInstallOnAppQuit = false;
|
||||
autoUpdater.channel = us.updateChannel;
|
||||
autoUpdater.allowDowngrade = us.isAllowedToDowngrade;
|
||||
|
||||
autoUpdater
|
||||
.on("update-available", (info: UpdateInfo) => {
|
||||
|
||||
@ -29,11 +29,16 @@ import { Input } from "../input";
|
||||
import { isWindows } from "../../../common/vars";
|
||||
import { FormSwitch, Switcher } from "../switch";
|
||||
import moment from "moment-timezone";
|
||||
import { CONSTANTS } from "../../../common/user-store/preferences-helpers";
|
||||
|
||||
const timezoneOptions: SelectOption<string>[] = moment.tz.names().map(zone => ({
|
||||
label: zone,
|
||||
value: zone,
|
||||
}));
|
||||
const updateChannelOptions: SelectOption<string>[] = Array.from(
|
||||
CONSTANTS.updateChannels.entries(),
|
||||
([value, { label }]) => ({ value, label }),
|
||||
);
|
||||
|
||||
export const Application = observer(() => {
|
||||
const defaultShell = process.env.SHELL
|
||||
@ -104,6 +109,18 @@ export const Application = observer(() => {
|
||||
|
||||
<hr />
|
||||
|
||||
<section id="update-channel">
|
||||
<SubTitle title="Update Channel"/>
|
||||
<Select
|
||||
options={updateChannelOptions}
|
||||
value={UserStore.getInstance().updateChannel}
|
||||
onChange={({ value }: SelectOption) => UserStore.getInstance().updateChannel = value}
|
||||
themeName="lens"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<hr />
|
||||
|
||||
<section id="locale">
|
||||
<SubTitle title="Locale Timezone" />
|
||||
<Select
|
||||
|
||||
Loading…
Reference in New Issue
Block a user