UNPKG

@backstage/plugin-home-react

Version:

A Backstage plugin that contains react components helps you build a home page

57 lines (54 loc) 1.95 kB
import { jsx } from 'react/jsx-runtime'; import { lazy } from 'react'; import { createExtensionBlueprint, ExtensionBoundary } from '@backstage/frontend-plugin-api'; import { attachComponentData } from '@backstage/core-plugin-api'; import { CardExtension } from '../../extensions.esm.js'; import { homePageWidgetDataRef } from '../dataRefs.esm.js'; const DEFAULT_WIDGET_ATTACH_POINT = { id: "page:home", input: "widgets" }; const HomePageWidgetBlueprint = createExtensionBlueprint({ kind: "home-page-widget", attachTo: DEFAULT_WIDGET_ATTACH_POINT, dataRefs: { widget: homePageWidgetDataRef }, output: [homePageWidgetDataRef], *factory(params, { node }) { const isCustomizable = params.settings?.schema !== void 0; const widgetName = params.name ?? node.spec.id; const LazyCard = lazy( () => params.components().then((parts) => ({ default: (props) => /* @__PURE__ */ jsx( CardExtension, { ...props, ...parts, title: props.title || params.title, isCustomizable } ) })) ); const Widget = (props) => /* @__PURE__ */ jsx(ExtensionBoundary, { node, children: /* @__PURE__ */ jsx(LazyCard, { ...props }) }); attachComponentData(Widget, "core.extensionName", widgetName); attachComponentData(Widget, "title", params.title); attachComponentData(Widget, "description", params.description); attachComponentData(Widget, "home.widget.config", { layout: params.layout, settings: params.settings }); yield homePageWidgetDataRef({ node, component: /* @__PURE__ */ jsx(Widget, { ...params.componentProps ?? {} }), name: widgetName, title: params.title, description: params.description, layout: params.layout, settings: params.settings }); } }); export { HomePageWidgetBlueprint }; //# sourceMappingURL=HomePageWidgetBlueprint.esm.js.map