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

Respond to review comments

- Remove options, always confirm, never auto prelease

- Changed "yes later" to "yes on quit"

- move register IpcHandlers

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-12-22 09:53:45 -05:00
parent cd154a8343
commit 96eb84e425
7 changed files with 9 additions and 55 deletions

View File

@ -27,8 +27,6 @@ export interface UserPreferences {
downloadKubectlBinaries?: boolean; downloadKubectlBinaries?: boolean;
downloadBinariesPath?: string; downloadBinariesPath?: string;
kubectlBinariesPath?: string; kubectlBinariesPath?: string;
allowAutoUpdates?: boolean;
allowPrereleaseVersions?: boolean;
} }
export class UserStore extends BaseStore<UserStoreModel> { export class UserStore extends BaseStore<UserStoreModel> {
@ -61,8 +59,6 @@ export class UserStore extends BaseStore<UserStoreModel> {
colorTheme: UserStore.defaultTheme, colorTheme: UserStore.defaultTheme,
downloadMirror: "default", downloadMirror: "default",
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
allowAutoUpdates: false,
allowPrereleaseVersions: false,
}; };
get isNewVersion() { get isNewVersion() {

View File

@ -1,6 +1,4 @@
import { autoUpdater, UpdateInfo } from "electron-updater"; import { autoUpdater, UpdateInfo } from "electron-updater";
import { autorun } from "mobx";
import { userStore } from "../common/user-store";
import logger from "./logger"; import logger from "./logger";
import dateFormat from "dateformat"; import dateFormat from "dateformat";
import { broadcastIpc, IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc"; import { broadcastIpc, IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc";
@ -91,7 +89,7 @@ async function autoUpdateCheck(args: UpdateInfo): Promise<void> {
} }
}, },
{ {
label: "Yes, later", label: "Yes, on quit",
backchannel: yesLaterChannel, backchannel: yesLaterChannel,
style: { style: {
background: "green", background: "green",
@ -120,16 +118,6 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
} }
autoUpdater.logger = logger; autoUpdater.logger = logger;
autoUpdater.autoInstallOnAppQuit = false;
/**
* GC saftey: This function's lifetime is the lifetime of the application.
* So no need to call the disposer.
*/
autorun(() => {
autoUpdater.autoDownload = userStore.preferences.allowAutoUpdates;
autoUpdater.allowPrerelease = userStore.preferences.allowPrereleaseVersions;
});
autoUpdater autoUpdater
.on("update-available", async (args: UpdateInfo) => { .on("update-available", async (args: UpdateInfo) => {
@ -146,21 +134,15 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
}] }]
}); });
const version = new SemVer(args.version);
if (userStore.preferences.allowAutoUpdates && version.prerelease !== null) {
// don't auto update to pre-release versions.
await autoUpdateNow();
} else {
await autoUpdateCheck(args); await autoUpdateCheck(args);
}
} catch (error) { } catch (error) {
logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) }) logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) })
} }
}) })
.on("update-not-available", () => { .on("update-not-available", (args: UpdateInfo) => {
try { try {
const stream = userStore.preferences.allowPrereleaseVersions ? "prerelease" : "stable"; const version = new SemVer(args.version);
const stream = version.prerelease !== null ? "prerelease" : "stable";
const body = `Lens is running the latest ${stream} version.`; const body = `Lens is running the latest ${stream} version.`;
broadcastIpc({ broadcastIpc({
channel: NotificationChannelAdd, channel: NotificationChannelAdd,

View File

@ -76,8 +76,7 @@ async function main() {
/** /**
* This depends on: * This depends on:
* 1. userStore: it reads the user's auto update settings * 1. windowManager: it will send IPC to the main window for notifications
* 2. windowManager: it will send IPC to the main window for notifications
*/ */
startUpdateChecking(); startUpdateChecking();
} }

View File

@ -73,10 +73,6 @@ export class WindowManager {
} }
} }
send(channel: string, ...data: any[]) {
this.mainView.webContents.send(channel, ...data);
}
async showMain() { async showMain() {
try { try {
await this.showSplash(); await this.showSplash();

View File

@ -31,10 +31,6 @@ export async function bootstrap(App: AppComponent) {
// Register additional store listeners // Register additional store listeners
clusterStore.registerIpcListener(); clusterStore.registerIpcListener();
if (process.isMainFrame) {
notificationsStore.registerIpcListener();
}
// init app's dependencies if any // init app's dependencies if any
if (App.init) { if (App.init) {
await App.init(); await App.init();

View File

@ -194,24 +194,6 @@ export class Preferences extends React.Component {
<small className="hint"> <small className="hint">
<Trans>Telemetry & usage data is collected to continuously improve the Lens experience.</Trans> <Trans>Telemetry & usage data is collected to continuously improve the Lens experience.</Trans>
</small> </small>
<h2><Trans>Updates</Trans></h2>
<Checkbox
label={<Trans>Allow auto updates</Trans>}
value={preferences.allowAutoUpdates}
onChange={v => preferences.allowAutoUpdates = v}
/>
<small className="hint">
<Trans>Allow Lens to auto update itself to the latest version. Lens checks on startup and then once a day.</Trans>
</small>
<Checkbox
label={<Trans>Allow pre-release versions of Lens</Trans>}
value={preferences.allowPrereleaseVersions}
onChange={v => preferences.allowPrereleaseVersions = v}
/>
<small className="hint">
<Trans>Allow upgrading Lens to pre-release versions. This means that the update checker will ask about pre release versions but won't auto upgrade to them.</Trans>
</small>
</WizardLayout> </WizardLayout>
</div> </div>
); );

View File

@ -12,6 +12,7 @@ import { ErrorBoundary } from "./components/error-boundary";
import { WhatsNew, whatsNewRoute } from "./components/+whats-new"; import { WhatsNew, whatsNewRoute } from "./components/+whats-new";
import { Notifications } from "./components/notifications"; import { Notifications } from "./components/notifications";
import { ConfirmDialog } from "./components/confirm-dialog"; import { ConfirmDialog } from "./components/confirm-dialog";
import { notificationsStore } from "./components/notifications/notifications.store";
@observer @observer
export class LensApp extends React.Component { export class LensApp extends React.Component {
@ -22,6 +23,8 @@ export class LensApp extends React.Component {
window.addEventListener("online", () => { window.addEventListener("online", () => {
ipcRenderer.send("network:online") ipcRenderer.send("network:online")
}) })
notificationsStore.registerIpcListener();
} }
render() { render() {