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

Add copy button on 'About Lens' dialog

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-04-04 13:49:00 -04:00
parent 8ada3c7505
commit c08c50501c
2 changed files with 16 additions and 8 deletions

View File

@ -70,7 +70,8 @@ const applicationMenuItemsInjectable = getInjectable({
label: `About ${productName}`,
id: "about",
click(menuItem: MenuItem, browserWindow: BrowserWindow) {
showAbout(browserWindow);
showAbout(browserWindow)
.catch(error => logger.error(`[MENU]: Failed to show Lens About view`, { error }));
},
},
...ignoreIf(autoUpdateDisabled, [
@ -287,7 +288,8 @@ const applicationMenuItemsInjectable = getInjectable({
label: `About ${productName}`,
id: "about",
click(menuItem: MenuItem, browserWindow: BrowserWindow) {
showAbout(browserWindow);
showAbout(browserWindow)
.catch(error => logger.error(`[MENU]: Failed to show Lens About view`, { error }));
},
},
...ignoreIf(autoUpdateDisabled, [

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { BrowserWindow } from "electron";
import { app, dialog, Menu } from "electron";
import { app, clipboard, dialog, Menu } from "electron";
import type { IComputedValue } from "mobx";
import { autorun } from "mobx";
import { appName, isWindows, productName } from "../../common/vars";
@ -20,22 +20,28 @@ export function initMenu(
});
}
export function showAbout(browserWindow: BrowserWindow) {
export async function showAbout(browserWindow: BrowserWindow) {
const appInfo = [
`${appName}: ${app.getVersion()}`,
`Electron: ${process.versions.electron}`,
`Chrome: ${process.versions.chrome}`,
`Node: ${process.versions.node}`,
packageJson.copyright,
];
].join("\n");
dialog.showMessageBoxSync(browserWindow, {
const result = await dialog.showMessageBox(browserWindow, {
title: `${isWindows ? " ".repeat(2) : ""}${appName}`,
type: "info",
buttons: ["Close"],
buttons: ["Close", "Copy"],
message: productName,
detail: appInfo.join("\r\n"),
detail: appInfo,
cancelId: 0,
defaultId: 0,
});
if (result.response === 0) {
clipboard.writeText(appInfo);
}
}
export function buildMenu(