mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Migrate more application menu items to injectables
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
eba75af764
commit
159f2bb9c1
26 files changed
+667
-289
No files matched your search
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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 applicationMenuItemInjectionToken from "../application-menu-item-injection-token";
|
||||
|
||||
const helpMenuItemInjectable = getInjectable({
|
||||
id: "help-application-menu-item",
|
||||
|
||||
instantiate: () => ({
|
||||
parentId: null,
|
||||
id: "help",
|
||||
orderNumber: 50,
|
||||
label: "Help",
|
||||
}),
|
||||
|
||||
injectionToken: applicationMenuItemInjectionToken,
|
||||
});
|
||||
|
||||
export default helpMenuItemInjectable;
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 applicationMenuItemInjectionToken from "../../application-menu-item-injection-token";
|
||||
import navigateToWelcomeInjectable from "../../../../../../common/front-end-routing/routes/welcome/navigate-to-welcome.injectable";
|
||||
|
||||
const navigateToWelcomeMenuItem = getInjectable({
|
||||
id: "navigate-to-welcome-menu-item",
|
||||
|
||||
instantiate: (di) => {
|
||||
const navigateToWelcome = di.inject(navigateToWelcomeInjectable);
|
||||
|
||||
return {
|
||||
parentId: "help",
|
||||
id: "navigate-to-welcome",
|
||||
orderNumber: 10,
|
||||
label: "Welcome",
|
||||
|
||||
click: () => {
|
||||
navigateToWelcome();
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: applicationMenuItemInjectionToken,
|
||||
});
|
||||
|
||||
export default navigateToWelcomeMenuItem;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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 applicationMenuItemInjectionToken from "../../application-menu-item-injection-token";
|
||||
import { docsUrl } from "../../../../../../common/vars";
|
||||
import openLinkInBrowserInjectable from "../../../../../../common/utils/open-link-in-browser.injectable";
|
||||
import loggerInjectable from "../../../../../../common/logger.injectable";
|
||||
|
||||
const openDocumentationMenuItemInjectable = getInjectable({
|
||||
id: "open-documentation-menu-item",
|
||||
|
||||
instantiate: (di) => {
|
||||
const openLinkInBrowser = di.inject(openLinkInBrowserInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return {
|
||||
parentId: "help",
|
||||
id: "open-documentation",
|
||||
orderNumber: 20,
|
||||
label: "Documentation",
|
||||
|
||||
// TODO: Convert to async/await
|
||||
click: () => {
|
||||
openLinkInBrowser(docsUrl).catch((error) => {
|
||||
logger.error("[MENU]: failed to open browser", { error });
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: applicationMenuItemInjectionToken,
|
||||
});
|
||||
|
||||
export default openDocumentationMenuItemInjectable;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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 applicationMenuItemInjectionToken from "../../application-menu-item-injection-token";
|
||||
import { supportUrl } from "../../../../../../common/vars";
|
||||
import openLinkInBrowserInjectable from "../../../../../../common/utils/open-link-in-browser.injectable";
|
||||
import loggerInjectable from "../../../../../../common/logger.injectable";
|
||||
|
||||
const openSupportItemInjectable = getInjectable({
|
||||
id: "open-support-menu-item",
|
||||
|
||||
instantiate: (di) => {
|
||||
const openLinkInBrowser = di.inject(openLinkInBrowserInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return {
|
||||
parentId: "help",
|
||||
id: "open-support",
|
||||
orderNumber: 30,
|
||||
label: "Support",
|
||||
|
||||
// TODO: Convert to async/await
|
||||
click: () => {
|
||||
openLinkInBrowser(supportUrl).catch((error) => {
|
||||
logger.error("[MENU]: failed to open browser", { error });
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: applicationMenuItemInjectionToken,
|
||||
});
|
||||
|
||||
export default openSupportItemInjectable;
|
||||
Reference in new issue
Block a user