mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'feature/tray' into fix-integration-tests
This commit is contained in:
commit
ab2acefcf4
@ -28,6 +28,7 @@ export interface UserPreferences {
|
|||||||
downloadBinariesPath?: string;
|
downloadBinariesPath?: string;
|
||||||
kubectlBinariesPath?: string;
|
kubectlBinariesPath?: string;
|
||||||
trayEnabled?: boolean;
|
trayEnabled?: boolean;
|
||||||
|
openAtLogin?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UserStore extends BaseStore<UserStoreModel> {
|
export class UserStore extends BaseStore<UserStoreModel> {
|
||||||
@ -39,14 +40,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
|||||||
migrations: migrations,
|
migrations: migrations,
|
||||||
});
|
});
|
||||||
|
|
||||||
// track telemetry availability
|
this.handleOnLoad();
|
||||||
reaction(() => this.preferences.allowTelemetry, allowed => {
|
|
||||||
tracker.event("telemetry", allowed ? "enabled" : "disabled");
|
|
||||||
});
|
|
||||||
|
|
||||||
// refresh new contexts
|
|
||||||
this.whenLoaded.then(this.refreshNewContexts);
|
|
||||||
reaction(() => this.kubeConfigPath, this.refreshNewContexts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable lastSeenAppVersion = "0.0.0"
|
@observable lastSeenAppVersion = "0.0.0"
|
||||||
@ -61,8 +55,31 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
|||||||
downloadMirror: "default",
|
downloadMirror: "default",
|
||||||
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
||||||
trayEnabled: true,
|
trayEnabled: true,
|
||||||
|
openAtLogin: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected async handleOnLoad() {
|
||||||
|
await this.whenLoaded;
|
||||||
|
|
||||||
|
// refresh new contexts
|
||||||
|
this.refreshNewContexts();
|
||||||
|
reaction(() => this.kubeConfigPath, this.refreshNewContexts);
|
||||||
|
|
||||||
|
if (app) {
|
||||||
|
// track telemetry availability
|
||||||
|
reaction(() => this.preferences.allowTelemetry, allowed => {
|
||||||
|
tracker.event("telemetry", allowed ? "enabled" : "disabled");
|
||||||
|
});
|
||||||
|
|
||||||
|
// open at system start-up
|
||||||
|
reaction(() => this.preferences.openAtLogin, open => {
|
||||||
|
app.setLoginItemSettings({ openAtLogin: open });
|
||||||
|
}, {
|
||||||
|
fireImmediately: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get isNewVersion() {
|
get isNewVersion() {
|
||||||
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,12 +87,10 @@ app.on("activate", (event, hasVisibleWindows) => {
|
|||||||
app.on("will-quit", (event) => {
|
app.on("will-quit", (event) => {
|
||||||
logger.info('APP:QUIT');
|
logger.info('APP:QUIT');
|
||||||
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
|
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
|
||||||
clusterManager?.stop();
|
clusterManager?.stop(); // close cluster connections
|
||||||
if (userStore.preferences.trayEnabled) {
|
if (userStore.preferences.trayEnabled) {
|
||||||
return; // with tray the app remains open
|
return; // with tray the app remains open
|
||||||
} else {
|
} else {
|
||||||
windowManager?.destroy();
|
|
||||||
proxyServer?.close();
|
|
||||||
app.exit(); // forced app.quit()
|
app.exit(); // forced app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -78,14 +78,12 @@ export function buildMenu(windowManager: WindowManager) {
|
|||||||
{ role: 'unhide' },
|
{ role: 'unhide' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: 'Force Quit',
|
label: 'Quit',
|
||||||
accelerator: 'Cmd+Shift+Q',
|
accelerator: 'Cmd+Q',
|
||||||
click() {
|
click() {
|
||||||
app.exit(0); // force quit since might be blocked within app.on("will-quit")
|
app.exit(); // force quit since might be blocked within app.on("will-quit")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{ type: 'separator' },
|
|
||||||
{ role: 'quit' },
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import path from "path"
|
|||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import jsdom from "jsdom"
|
import jsdom from "jsdom"
|
||||||
import packageInfo from "../../package.json"
|
import packageInfo from "../../package.json"
|
||||||
import { dialog, Menu, NativeImage, nativeImage, nativeTheme, Tray } from "electron"
|
import { app, dialog, Menu, NativeImage, nativeImage, nativeTheme, Tray } from "electron"
|
||||||
import { isDevelopment, isMac } from "../common/vars";
|
import { isDevelopment, isMac } from "../common/vars";
|
||||||
import { autorun } from "mobx";
|
import { autorun } from "mobx";
|
||||||
import { showAbout } from "./menu";
|
import { showAbout } from "./menu";
|
||||||
@ -131,5 +131,12 @@ export function createTrayMenu(windowManager: WindowManager): Menu {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ type: 'separator' },
|
||||||
|
{
|
||||||
|
label: 'Quit App',
|
||||||
|
click() {
|
||||||
|
app.exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import type { ClusterId } from "../common/cluster-store";
|
|||||||
import { clusterStore } from "../common/cluster-store";
|
import { clusterStore } from "../common/cluster-store";
|
||||||
import { userStore } from "../common/user-store";
|
import { userStore } from "../common/user-store";
|
||||||
import { observable, reaction } from "mobx";
|
import { observable, reaction } from "mobx";
|
||||||
import { BrowserWindow, dialog, ipcMain, shell, webContents } from "electron"
|
import { app, BrowserWindow, dialog, ipcMain, shell, webContents } from "electron"
|
||||||
import windowStateKeeper from "electron-window-state"
|
import windowStateKeeper from "electron-window-state"
|
||||||
import { initMenu } from "./menu";
|
import { initMenu } from "./menu";
|
||||||
import { initTray } from "./tray";
|
import { initTray } from "./tray";
|
||||||
@ -35,6 +35,8 @@ export class WindowManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!this.mainWindow) {
|
if (!this.mainWindow) {
|
||||||
|
app.dock?.show(); // show icon in dock (mac-os only)
|
||||||
|
|
||||||
const { width, height, x, y } = this.windowState;
|
const { width, height, x, y } = this.windowState;
|
||||||
this.mainWindow = new BrowserWindow({
|
this.mainWindow = new BrowserWindow({
|
||||||
x, y, width, height,
|
x, y, width, height,
|
||||||
@ -62,6 +64,7 @@ export class WindowManager {
|
|||||||
this.windowState.unmanage();
|
this.windowState.unmanage();
|
||||||
this.mainWindow = null;
|
this.mainWindow = null;
|
||||||
this.splashWindow = null;
|
this.splashWindow = null;
|
||||||
|
app.dock?.hide(); // hide icon in dock (mac-os)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -57,4 +57,8 @@
|
|||||||
box-shadow: 0 0 0 1px $borderFaintColor;
|
box-shadow: 0 0 0 1px $borderFaintColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Checkbox {
|
||||||
|
align-self: start; // limit clickable area to checkbox + text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -173,6 +173,26 @@ export class Preferences extends React.Component {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h2><Trans>Auto start-up</Trans></h2>
|
||||||
|
<Checkbox
|
||||||
|
label={<Trans>Open on start-up</Trans>}
|
||||||
|
value={preferences.openAtLogin}
|
||||||
|
onChange={v => preferences.openAtLogin = v}
|
||||||
|
/>
|
||||||
|
<small className="hint">
|
||||||
|
<Trans>Opens Lens app on operation system login</Trans>
|
||||||
|
</small>
|
||||||
|
|
||||||
|
<h2><Trans>Tray icon</Trans></h2>
|
||||||
|
<Checkbox
|
||||||
|
label={<Trans>Enable tray icon</Trans>}
|
||||||
|
value={preferences.trayEnabled}
|
||||||
|
onChange={v => preferences.trayEnabled = v}
|
||||||
|
/>
|
||||||
|
<small className="hint">
|
||||||
|
<Trans>Adds OS-level tray icon and menu to get quick access to Lens</Trans>
|
||||||
|
</small>
|
||||||
|
|
||||||
<h2><Trans>Certificate Trust</Trans></h2>
|
<h2><Trans>Certificate Trust</Trans></h2>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label={<Trans>Allow untrusted Certificate Authorities</Trans>}
|
label={<Trans>Allow untrusted Certificate Authorities</Trans>}
|
||||||
@ -194,16 +214,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>Tray icon</Trans></h2>
|
|
||||||
<Checkbox
|
|
||||||
label={<Trans>Enable tray icon</Trans>}
|
|
||||||
value={preferences.trayEnabled}
|
|
||||||
onChange={v => preferences.trayEnabled = v}
|
|
||||||
/>
|
|
||||||
<small className="hint">
|
|
||||||
<Trans>Adds OS-level tray icon and menu to get quick access to Lens</Trans>
|
|
||||||
</small>
|
|
||||||
</WizardLayout>
|
</WizardLayout>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user