mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Extract some operation system actions from application menu as injectables
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
2446f62da1
commit
0b39cc1044
@ -25,8 +25,6 @@ import processCheckingForUpdatesInjectable from "../../application-update/main/p
|
|||||||
import openLinkInBrowserInjectable from "../../../common/utils/open-link-in-browser.injectable";
|
import openLinkInBrowserInjectable from "../../../common/utils/open-link-in-browser.injectable";
|
||||||
import appNameInjectable from "../../../common/vars/app-name.injectable";
|
import appNameInjectable from "../../../common/vars/app-name.injectable";
|
||||||
import productNameInjectable from "../../../common/vars/product-name.injectable";
|
import productNameInjectable from "../../../common/vars/product-name.injectable";
|
||||||
|
|
||||||
|
|
||||||
import applicationMenuItemInjectionToken from "./menu-items/application-menu-item-injection-token";
|
import applicationMenuItemInjectionToken from "./menu-items/application-menu-item-injection-token";
|
||||||
|
|
||||||
function ignoreIf(check: boolean, menuItems: MenuItemOpts[]) {
|
function ignoreIf(check: boolean, menuItems: MenuItemOpts[]) {
|
||||||
@ -78,12 +76,6 @@ const applicationMenuItemsInjectable = getInjectable({
|
|||||||
label: appName,
|
label: appName,
|
||||||
id: "root",
|
id: "root",
|
||||||
submenu: [
|
submenu: [
|
||||||
{ role: "services" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "hide" },
|
|
||||||
{ role: "hideOthers" },
|
|
||||||
{ role: "unhide" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{
|
{
|
||||||
label: "Quit",
|
label: "Quit",
|
||||||
accelerator: "Cmd+Q",
|
accelerator: "Cmd+Q",
|
||||||
|
|||||||
@ -21,7 +21,13 @@ export interface Separator extends Shared {
|
|||||||
type: "separator";
|
type: "separator";
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationMenuItemInjectionToken = getInjectionToken<ApplicationMenuItem | Separator>({
|
export interface OperationSystemAction extends Shared {
|
||||||
|
role: "services" | "hide" | "hideOthers" | "unhide";
|
||||||
|
}
|
||||||
|
|
||||||
|
const applicationMenuItemInjectionToken = getInjectionToken<
|
||||||
|
ApplicationMenuItem | Separator | OperationSystemAction
|
||||||
|
>({
|
||||||
id: "application-menu-item-injection-token",
|
id: "application-menu-item-injection-token",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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 type { OperationSystemAction } from "./application-menu-item-injection-token";
|
||||||
|
import applicationMenuItemInjectionToken from "./application-menu-item-injection-token";
|
||||||
|
|
||||||
|
const getApplicationMenuOperationSystemActionInjectable = ({
|
||||||
|
id,
|
||||||
|
role,
|
||||||
|
...rest
|
||||||
|
}: { id: string } & OperationSystemAction) =>
|
||||||
|
getInjectable({
|
||||||
|
id: `application-menu-operation-system-action/${id}`,
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
...rest,
|
||||||
|
role,
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: applicationMenuItemInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export { getApplicationMenuOperationSystemActionInjectable };
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
getApplicationMenuOperationSystemActionInjectable,
|
||||||
|
} from "../../get-application-menu-operation-system-action-injectable";
|
||||||
|
|
||||||
|
export const actionForServices = getApplicationMenuOperationSystemActionInjectable({
|
||||||
|
id: "services",
|
||||||
|
parentId: "primary-for-mac",
|
||||||
|
orderNumber: 80,
|
||||||
|
role: "services",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const actionForHide = getApplicationMenuOperationSystemActionInjectable({
|
||||||
|
id: "hide",
|
||||||
|
parentId: "primary-for-mac",
|
||||||
|
orderNumber: 100,
|
||||||
|
role: "hide",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const actionForHideOthers = getApplicationMenuOperationSystemActionInjectable({
|
||||||
|
id: "hide-others",
|
||||||
|
parentId: "primary-for-mac",
|
||||||
|
orderNumber: 110,
|
||||||
|
role: "hideOthers",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const actionForUnhide = getApplicationMenuOperationSystemActionInjectable({
|
||||||
|
id: "unhide",
|
||||||
|
parentId: "primary-for-mac",
|
||||||
|
orderNumber: 120,
|
||||||
|
role: "unhide",
|
||||||
|
});
|
||||||
@ -18,3 +18,15 @@ export const separator2 = getApplicationMenuSeparatorInjectable({
|
|||||||
parentId: "primary-for-mac",
|
parentId: "primary-for-mac",
|
||||||
orderNumber: 70,
|
orderNumber: 70,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const separator3 = getApplicationMenuSeparatorInjectable({
|
||||||
|
id: "separator-3",
|
||||||
|
parentId: "primary-for-mac",
|
||||||
|
orderNumber: 90,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const separator4 = getApplicationMenuSeparatorInjectable({
|
||||||
|
id: "separator-4",
|
||||||
|
parentId: "primary-for-mac",
|
||||||
|
orderNumber: 130,
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user