1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/frames/cluster-frame/cluster-frame-component-registrator.injectable.ts
Alex Andreev c527014011
Expose a way to add cluster frame components in Extension API (#6385)
* Add cluster modals registrator

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Add ClusterModal components and injection token

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Add clusterModals tests

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Update snapshots and use css modules

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Linter fixes

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Setting 0 height as an inline style

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Update snapshots

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Do not export clusterModalsInjectionToken to extensions

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Testing changing visibility flag

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Linter fix

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Refactor cluster modals registrator and injectable

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Linter fixes

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Harder linter fix

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fix linter again

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Using clusterFrameChildComponentsInjectionToken

for specific extension elements

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Removing unused files

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Removing unused modal registration

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Improving tests

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fix linting

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Update snapshots

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Rename test suite for consistency

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
2022-11-04 09:15:16 +03:00

43 lines
1.6 KiB
TypeScript

/**
* 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 } from "@ogre-tools/injectable";
import { map } from "lodash/fp";
import { extensionRegistratorInjectionToken } from "../../../extensions/extension-loader/extension-registrator-injection-token";
import type { ExtensionRegistrator } from "../../../extensions/extension-loader/extension-registrator-injection-token";
import type { LensRendererExtension } from "../../../extensions/lens-renderer-extension";
import { clusterFrameChildComponentInjectionToken } from "./cluster-frame-child-component-injection-token";
const clusterFrameComponentRegistratorInjectable = getInjectable({
id: "cluster-frame-component-registrator",
instantiate: (): ExtensionRegistrator => {
return (ext) => {
const extension = ext as LensRendererExtension;
return pipeline(
extension.clusterFrameComponents,
map((clusterFrameComponentRegistration) => {
const id = `${extension.sanitizedExtensionId}-${clusterFrameComponentRegistration.id}`;
return getInjectable({
id,
injectionToken: clusterFrameChildComponentInjectionToken,
instantiate: () => ({
id,
shouldRender: clusterFrameComponentRegistration.shouldRender,
Component: clusterFrameComponentRegistration.Component,
}),
});
}),
);
};
},
injectionToken: extensionRegistratorInjectionToken,
});
export default clusterFrameComponentRegistratorInjectable;