From 11e03910a4506b19da9e587c0769884abbd0c08c Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 4 May 2022 16:54:40 +0300 Subject: [PATCH] Add appPreferenceTabs registration Signed-off-by: Alex Andreev --- src/extensions/lens-renderer-extension.ts | 2 ++ .../app-preference-tab-registration.ts | 11 +++++++++++ .../app-preference-tab.injectable.ts | 19 +++++++++++++++++++ .../get-app-preference-tab.ts | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 src/renderer/components/+preferences/app-preference-tab/app-preference-tab-registration.ts create mode 100644 src/renderer/components/+preferences/app-preference-tab/app-preference-tab.injectable.ts create mode 100644 src/renderer/components/+preferences/app-preference-tab/get-app-preference-tab.ts diff --git a/src/extensions/lens-renderer-extension.ts b/src/extensions/lens-renderer-extension.ts index 9c897431dc..15215795e7 100644 --- a/src/extensions/lens-renderer-extension.ts +++ b/src/extensions/lens-renderer-extension.ts @@ -30,6 +30,7 @@ import extensionPageParametersInjectable from "../renderer/routes/extension-page import { pipeline } from "@ogre-tools/fp"; import { getExtensionRoutePath } from "../renderer/routes/get-extension-route-path"; import { navigateToRouteInjectionToken } from "../common/front-end-routing/navigate-to-route-injection-token"; +import type { AppPreferenceTabRegistration } from "../renderer/components/+preferences/app-preference-tab/app-preference-tab-registration"; export class LensRendererExtension extends LensExtension { globalPages: registries.PageRegistration[] = []; @@ -37,6 +38,7 @@ export class LensRendererExtension extends LensExtension { clusterPageMenus: registries.ClusterPageMenuRegistration[] = []; kubeObjectStatusTexts: KubeObjectStatusRegistration[] = []; appPreferences: AppPreferenceRegistration[] = []; + appPreferenceTabs: AppPreferenceTabRegistration[] = []; entitySettings: registries.EntitySettingRegistration[] = []; statusBarItems: StatusBarRegistration[] = []; kubeObjectDetailItems: registries.KubeObjectDetailRegistration[] = []; diff --git a/src/renderer/components/+preferences/app-preference-tab/app-preference-tab-registration.ts b/src/renderer/components/+preferences/app-preference-tab/app-preference-tab-registration.ts new file mode 100644 index 0000000000..2fed65d79e --- /dev/null +++ b/src/renderer/components/+preferences/app-preference-tab/app-preference-tab-registration.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +export interface AppPreferenceTabRegistration { + title: string; + id: string; + orderNumber?: number; +} + diff --git a/src/renderer/components/+preferences/app-preference-tab/app-preference-tab.injectable.ts b/src/renderer/components/+preferences/app-preference-tab/app-preference-tab.injectable.ts new file mode 100644 index 0000000000..2d33f01f55 --- /dev/null +++ b/src/renderer/components/+preferences/app-preference-tab/app-preference-tab.injectable.ts @@ -0,0 +1,19 @@ +/** + * 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 rendererExtensionsInjectable from "../../../../extensions/renderer-extensions.injectable"; +import { getAppPreferenceTabs } from "./get-app-preference-tab"; + +const appPreferenceTabInjectable = getInjectable({ + id: "app-preference-tabs", + + instantiate: (di) => + getAppPreferenceTabs({ + extensions: di.inject(rendererExtensionsInjectable), + }), +}); + +export default appPreferenceTabInjectable; diff --git a/src/renderer/components/+preferences/app-preference-tab/get-app-preference-tab.ts b/src/renderer/components/+preferences/app-preference-tab/get-app-preference-tab.ts new file mode 100644 index 0000000000..a78fce4727 --- /dev/null +++ b/src/renderer/components/+preferences/app-preference-tab/get-app-preference-tab.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import type { IComputedValue } from "mobx"; +import { computed } from "mobx"; +import type { LensRendererExtension } from "../../../../extensions/lens-renderer-extension"; + +interface Dependencies { + extensions: IComputedValue; +} + +export const getAppPreferenceTabs = ({ extensions }: Dependencies) => { + return computed(() => ( + extensions.get().flatMap((extension) => extension.appPreferenceTabs) + )); +};