mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Reorganize stuff to prevent circular dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Install injectable extension to allow injecting reactively many implementations Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Switch to using computedInjectMany over filtering injectMany based on enabled extensions for simplicity Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove await for not being needed Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Sort dependencies alphabetically Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
/**
|
|
* 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 { filter, map } from "lodash/fp";
|
|
import { extensionRegistratorInjectionToken } from "../../../extensions/extension-loader/extension-registrator-injection-token";
|
|
import type { LensRendererExtension } from "../../../extensions/lens-renderer-extension";
|
|
import { pipeline } from "@ogre-tools/fp";
|
|
import { telemetryPreferenceItemInjectionToken } from "./telemetry-preference-items.injectable";
|
|
|
|
const extensionTelemetryPreferenceItemRegistratorInjectable = getInjectable({
|
|
id: "extension-telemetry-preference-item-registrator",
|
|
|
|
instantiate:
|
|
() =>
|
|
(ext) => {
|
|
const extension = ext as LensRendererExtension;
|
|
|
|
return pipeline(
|
|
extension.appPreferences,
|
|
|
|
filter(
|
|
(registration) => registration.showInPreferencesTab === "telemetry",
|
|
),
|
|
|
|
map((registration) => {
|
|
const id = `telemetry-preferences-item-${registration.id}-for-extension-${extension.sanitizedExtensionId}`;
|
|
|
|
return getInjectable({
|
|
id,
|
|
injectionToken: telemetryPreferenceItemInjectionToken,
|
|
|
|
instantiate: () => ({
|
|
id: registration.id || id,
|
|
title: registration.title,
|
|
|
|
components: {
|
|
Hint: registration.components.Hint,
|
|
Input: registration.components.Input,
|
|
},
|
|
}),
|
|
});
|
|
}),
|
|
);
|
|
},
|
|
|
|
injectionToken: extensionRegistratorInjectionToken,
|
|
});
|
|
|
|
export default extensionTelemetryPreferenceItemRegistratorInjectable;
|