mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Relocate stuff related to "show about" under behaviours
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
d904f6999b
commit
54bce04a9c
@ -3,13 +3,13 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import productNameInjectable from "../app-paths/app-name/product-name.injectable";
|
import productNameInjectable from "../../../main/app-paths/app-name/product-name.injectable";
|
||||||
import showApplicationWindowInjectable from "../start-main-application/lens-window/show-application-window.injectable";
|
import showApplicationWindowInjectable from "../../../main/start-main-application/lens-window/show-application-window.injectable";
|
||||||
import showAboutInjectable from "../menu/show-about.injectable";
|
import showAboutInjectable from "./show-about.injectable";
|
||||||
import { trayMenuItemInjectionToken } from "../../behaviours/tray/main/tray-menu-item/tray-menu-item-injection-token";
|
import { trayMenuItemInjectionToken } from "../../tray/main/tray-menu-item/tray-menu-item-injection-token";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import withErrorLoggingInjectable from "../../common/utils/with-error-logging/with-error-logging.injectable";
|
import withErrorLoggingInjectable from "../../../common/utils/with-error-logging/with-error-logging.injectable";
|
||||||
import { withErrorSuppression } from "../../common/utils/with-error-suppression/with-error-suppression";
|
import { withErrorSuppression } from "../../../common/utils/with-error-suppression/with-error-suppression";
|
||||||
import { pipeline } from "@ogre-tools/fp";
|
import { pipeline } from "@ogre-tools/fp";
|
||||||
|
|
||||||
const aboutAppTrayItemInjectable = getInjectable({
|
const aboutAppTrayItemInjectable = getInjectable({
|
||||||
43
src/behaviours/show-about/main/show-about.injectable.ts
Normal file
43
src/behaviours/show-about/main/show-about.injectable.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* 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 showMessagePopupInjectable from "../../../main/electron-app/features/show-message-popup.injectable";
|
||||||
|
import packageJson from "../../../../package.json";
|
||||||
|
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
|
||||||
|
import appNameInjectable from "../../../main/app-paths/app-name/app-name.injectable";
|
||||||
|
import electronAppInjectable from "../../../main/electron-app/electron-app.injectable";
|
||||||
|
import productNameInjectable from "../../../main/app-paths/app-name/product-name.injectable";
|
||||||
|
|
||||||
|
const showAboutInjectable = getInjectable({
|
||||||
|
id: "show-about",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const showMessagePopup = di.inject(showMessagePopupInjectable);
|
||||||
|
const isWindows = di.inject(isWindowsInjectable);
|
||||||
|
const appName = di.inject(appNameInjectable);
|
||||||
|
const app = di.inject(electronAppInjectable);
|
||||||
|
const productName = di.inject(productNameInjectable);
|
||||||
|
|
||||||
|
return async () => {
|
||||||
|
const appInfo = [
|
||||||
|
`${appName}: ${app.getVersion()}`,
|
||||||
|
`Electron: ${process.versions.electron}`,
|
||||||
|
`Chrome: ${process.versions.chrome}`,
|
||||||
|
`Node: ${process.versions.node}`,
|
||||||
|
packageJson.copyright,
|
||||||
|
];
|
||||||
|
|
||||||
|
await showMessagePopup(
|
||||||
|
`${isWindows ? " ".repeat(2) : ""}${appName}`,
|
||||||
|
productName,
|
||||||
|
appInfo.join("\r\n"),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
causesSideEffects: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default showAboutInjectable;
|
||||||
@ -2,34 +2,11 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { app, Menu } from "electron";
|
import { Menu } from "electron";
|
||||||
import { appName, isWindows, productName } from "../../common/vars";
|
|
||||||
import packageJson from "../../../package.json";
|
|
||||||
import type { MenuItemOpts } from "./application-menu-items.injectable";
|
import type { MenuItemOpts } from "./application-menu-items.injectable";
|
||||||
import type { ShowMessagePopup } from "../electron-app/features/show-message-popup.injectable";
|
|
||||||
|
|
||||||
export type MenuTopId = "mac" | "file" | "edit" | "view" | "help";
|
export type MenuTopId = "mac" | "file" | "edit" | "view" | "help";
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
showMessagePopup: ShowMessagePopup;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const showAbout = ({ showMessagePopup }: Dependencies) => async () => {
|
|
||||||
const appInfo = [
|
|
||||||
`${appName}: ${app.getVersion()}`,
|
|
||||||
`Electron: ${process.versions.electron}`,
|
|
||||||
`Chrome: ${process.versions.chrome}`,
|
|
||||||
`Node: ${process.versions.node}`,
|
|
||||||
packageJson.copyright,
|
|
||||||
];
|
|
||||||
|
|
||||||
await showMessagePopup(
|
|
||||||
`${isWindows ? " ".repeat(2) : ""}${appName}`,
|
|
||||||
productName,
|
|
||||||
appInfo.join("\r\n"),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export function buildMenu(applicationMenuItems: MenuItemOpts[]) {
|
export function buildMenu(applicationMenuItems: MenuItemOpts[]) {
|
||||||
Menu.setApplicationMenu(
|
Menu.setApplicationMenu(
|
||||||
Menu.buildFromTemplate(applicationMenuItems),
|
Menu.buildFromTemplate(applicationMenuItems),
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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 { showAbout } from "./menu";
|
|
||||||
import showMessagePopupInjectable from "../electron-app/features/show-message-popup.injectable";
|
|
||||||
|
|
||||||
const showAboutInjectable = getInjectable({
|
|
||||||
id: "show-about",
|
|
||||||
|
|
||||||
instantiate: (di) =>
|
|
||||||
showAbout({ showMessagePopup: di.inject(showMessagePopupInjectable) }),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default showAboutInjectable;
|
|
||||||
Loading…
Reference in New Issue
Block a user