diff --git a/src/common/front-end-routing/routes/preferences/navigate-to-preferences.injectable.ts b/src/common/front-end-routing/routes/preferences/navigate-to-preferences.injectable.ts index 7dfb7f3d5c..69599e32c5 100644 --- a/src/common/front-end-routing/routes/preferences/navigate-to-preferences.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/navigate-to-preferences.injectable.ts @@ -13,7 +13,10 @@ const navigateToPreferencesInjectable = getInjectable({ const navigateToRoute = di.inject(navigateToRouteInjectionToken); const preferencesRoute = di.inject(preferencesRouteInjectable); - return () => navigateToRoute(preferencesRoute); + return (tabId?: string) => + navigateToRoute(preferencesRoute, { + parameters: tabId ? { preferenceTabId: tabId } : {}, + }); }, }); diff --git a/src/features/preferences/common/navigate-to-application-preferences.injectable.ts b/src/features/preferences/common/navigate-to-application-preferences.injectable.ts index 15f8d563a4..930f565504 100644 --- a/src/features/preferences/common/navigate-to-application-preferences.injectable.ts +++ b/src/features/preferences/common/navigate-to-application-preferences.injectable.ts @@ -3,17 +3,15 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import preferencesRouteInjectable from "./preferences-route.injectable"; -import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const navigateToApplicationPreferencesInjectable = getInjectable({ id: "navigate-to-application-preferences", instantiate: (di) => { - const navigateToRoute = di.inject(navigateToRouteInjectionToken); - const route = di.inject(preferencesRouteInjectable); + const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - return () => navigateToRoute(route, { parameters: { preferenceTabId: "app" }}); + return () => navigateToPreferences("app"); }, }); diff --git a/src/features/preferences/common/navigate-to-editor-preferences.injectable.ts b/src/features/preferences/common/navigate-to-editor-preferences.injectable.ts index 9c18cf968a..4d266bb5dc 100644 --- a/src/features/preferences/common/navigate-to-editor-preferences.injectable.ts +++ b/src/features/preferences/common/navigate-to-editor-preferences.injectable.ts @@ -3,17 +3,15 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import preferencesRouteInjectable from "./preferences-route.injectable"; -import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const navigateToEditorPreferencesInjectable = getInjectable({ id: "navigate-to-editor-preferences", instantiate: (di) => { - const navigateToRoute = di.inject(navigateToRouteInjectionToken); - const route = di.inject(preferencesRouteInjectable); + const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - return () => navigateToRoute(route, { parameters: { preferenceTabId: "editor" }}); + return () => navigateToPreferences("editor"); }, }); diff --git a/src/features/preferences/common/navigate-to-kubernetes-preferences.injectable.ts b/src/features/preferences/common/navigate-to-kubernetes-preferences.injectable.ts index c4409e8963..01ad109247 100644 --- a/src/features/preferences/common/navigate-to-kubernetes-preferences.injectable.ts +++ b/src/features/preferences/common/navigate-to-kubernetes-preferences.injectable.ts @@ -3,17 +3,15 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import preferencesRouteInjectable from "./preferences-route.injectable"; -import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const navigateToKubernetesPreferencesInjectable = getInjectable({ id: "navigate-to-kubernetes-preferences", instantiate: (di) => { - const navigateToRoute = di.inject(navigateToRouteInjectionToken); - const route = di.inject(preferencesRouteInjectable); + const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - return () => navigateToRoute(route, { parameters: { preferenceTabId: "kubernetes" }}); + return () => navigateToPreferences("kubernetes"); }, }); diff --git a/src/features/preferences/common/navigate-to-proxy-preferences.injectable.ts b/src/features/preferences/common/navigate-to-proxy-preferences.injectable.ts index 173f1de3c0..2c88aa25f6 100644 --- a/src/features/preferences/common/navigate-to-proxy-preferences.injectable.ts +++ b/src/features/preferences/common/navigate-to-proxy-preferences.injectable.ts @@ -3,17 +3,15 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token"; -import preferencesRouteInjectable from "./preferences-route.injectable"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const navigateToProxyPreferencesInjectable = getInjectable({ id: "navigate-to-proxy-preferences", instantiate: (di) => { - const navigateToRoute = di.inject(navigateToRouteInjectionToken); - const route = di.inject(preferencesRouteInjectable); + const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - return () => navigateToRoute(route, { parameters: { preferenceTabId: "proxy" }}); + return () => navigateToPreferences("proxy"); }, }); diff --git a/src/features/preferences/common/navigate-to-telemetry-preferences.injectable.ts b/src/features/preferences/common/navigate-to-telemetry-preferences.injectable.ts index 9ade36a296..392ce5bb4f 100644 --- a/src/features/preferences/common/navigate-to-telemetry-preferences.injectable.ts +++ b/src/features/preferences/common/navigate-to-telemetry-preferences.injectable.ts @@ -3,17 +3,15 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token"; -import preferencesRouteInjectable from "./preferences-route.injectable"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const navigateToTelemetryPreferencesInjectable = getInjectable({ id: "navigate-to-telemetry-preferences", instantiate: (di) => { - const navigateToRoute = di.inject(navigateToRouteInjectionToken); - const route = di.inject(preferencesRouteInjectable); + const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - return () => navigateToRoute(route, { parameters: { preferenceTabId: "telemetry" }}); + return () => navigateToPreferences("telemetry"); }, }); diff --git a/src/features/preferences/common/navigate-to-terminal-preferences.injectable.ts b/src/features/preferences/common/navigate-to-terminal-preferences.injectable.ts index bcc8770f41..079772ab95 100644 --- a/src/features/preferences/common/navigate-to-terminal-preferences.injectable.ts +++ b/src/features/preferences/common/navigate-to-terminal-preferences.injectable.ts @@ -3,17 +3,15 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token"; -import preferencesRouteInjectable from "./preferences-route.injectable"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const navigateToTerminalPreferencesInjectable = getInjectable({ id: "navigate-to-terminal-preferences", instantiate: (di) => { - const navigateToRoute = di.inject(navigateToRouteInjectionToken); - const route = di.inject(preferencesRouteInjectable); + const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - return () => navigateToRoute(route, { parameters: { preferenceTabId: "terminal" }}); + return () => navigateToPreferences("terminal"); }, }); diff --git a/src/renderer/components/+preferences/preferences-navigation/preference-navigation-items.injectable.ts b/src/renderer/components/+preferences/preferences-navigation/preference-navigation-items.injectable.ts deleted file mode 100644 index 8340ff003e..0000000000 --- a/src/renderer/components/+preferences/preferences-navigation/preference-navigation-items.injectable.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { pipeline } from "@ogre-tools/fp"; -import { getInjectable, getInjectionToken } from "@ogre-tools/injectable"; -import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx"; -import { filter, orderBy } from "lodash/fp"; -import type { IComputedValue } from "mobx"; -import { computed } from "mobx"; - -export const preferenceNavigationItemInjectionToken = - getInjectionToken({ - id: "preference-navigation-item-injection-token", - }); - -export interface PreferenceNavigationItem { - id: string; - label: string; - isActive: IComputedValue; - isVisible: IComputedValue; - navigate: () => void; - orderNumber: number; - parent: string; -} - -const preferenceNavigationItemsInjectable = getInjectable({ - id: "preference-navigation-items", - - instantiate: (di) => { - const computedInjectMany = di.inject(computedInjectManyInjectable); - const navigationItems = computedInjectMany(preferenceNavigationItemInjectionToken); - - return computed((): PreferenceNavigationItem[] => - pipeline( - navigationItems.get(), - filter((item) => !!item.isVisible.get()), - (items) => orderBy([(item) => item.orderNumber], ["asc"], items), - ), - ); - }, -}); - -export default preferenceNavigationItemsInjectable; diff --git a/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.injectable.ts b/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.injectable.ts index 8c6e70f8c2..36c87d0393 100644 --- a/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.injectable.ts +++ b/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.injectable.ts @@ -11,8 +11,8 @@ import navigateToAddClusterInjectable from "../../../common/front-end-routing/ro import navigateToExtensionsInjectable from "../../../common/front-end-routing/routes/extensions/navigate-to-extensions.injectable"; import navigateToEntitySettingsInjectable from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable"; import navigateToClusterViewInjectable from "../../../common/front-end-routing/routes/cluster-view/navigate-to-cluster-view.injectable"; -import navigateToPreferenceTabIdInjectable from "./navigate-to-preference-tab-id.injectable"; import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable"; +import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; const bindProtocolAddRouteHandlersInjectable = getInjectable({ id: "bind-protocol-add-route-handlers", @@ -25,7 +25,7 @@ const bindProtocolAddRouteHandlersInjectable = getInjectable({ navigateToExtensions: di.inject(navigateToExtensionsInjectable), navigateToEntitySettings: di.inject(navigateToEntitySettingsInjectable), navigateToClusterView: di.inject(navigateToClusterViewInjectable), - navigateToPreferenceTabId: di.inject(navigateToPreferenceTabIdInjectable), + navigateToPreferences: di.inject(navigateToPreferencesInjectable), entityRegistry: di.inject(catalogEntityRegistryInjectable), }), }); diff --git a/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.tsx b/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.tsx index 40ab3b502c..ad8b0e007f 100644 --- a/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.tsx +++ b/src/renderer/protocol-handler/bind-protocol-add-route-handlers/bind-protocol-add-route-handlers.tsx @@ -28,7 +28,7 @@ interface Dependencies { navigateToExtensions: () => void; navigateToEntitySettings: NavigateToEntitySettings; navigateToClusterView: NavigateToClusterView; - navigateToPreferenceTabId: (tabId: string) => void; + navigateToPreferences: (tabId: string) => void; entityRegistry: CatalogEntityRegistry; } @@ -40,13 +40,13 @@ export const bindProtocolAddRouteHandlers = ({ navigateToExtensions, navigateToEntitySettings, navigateToClusterView, - navigateToPreferenceTabId, + navigateToPreferences, entityRegistry, }: Dependencies) => () => { lensProtocolRouterRenderer .addInternalHandler("/preferences", ({ search: { highlight: tabId }}) => { if (tabId) { - navigateToPreferenceTabId(tabId); + navigateToPreferences(tabId); } }) .addInternalHandler("/", ({ tail }) => { diff --git a/src/renderer/protocol-handler/bind-protocol-add-route-handlers/navigate-to-preference-tab-id.injectable.ts b/src/renderer/protocol-handler/bind-protocol-add-route-handlers/navigate-to-preference-tab-id.injectable.ts deleted file mode 100644 index 5c6aa2177e..0000000000 --- a/src/renderer/protocol-handler/bind-protocol-add-route-handlers/navigate-to-preference-tab-id.injectable.ts +++ /dev/null @@ -1,30 +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 preferenceNavigationItemsInjectable from "../../components/+preferences/preferences-navigation/preference-navigation-items.injectable"; -import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; - -const navigateToPreferenceTabIdInjectable = getInjectable({ - id: "navigate-to-preference-tab-id", - - instantiate: (di) => { - const preferenceNavigationItems = di.inject(preferenceNavigationItemsInjectable); - const navigateToPreferences = di.inject(navigateToPreferencesInjectable); - - return (tabId: string) => { - const targetTab = preferenceNavigationItems.get().find(item => item.id === tabId); - - if (targetTab) { - targetTab.navigate(); - - return; - } - - navigateToPreferences(); - }; - }, -}); - -export default navigateToPreferenceTabIdInjectable;