From ebe7c4df7ca64a7fb6efed074e2e1ad2bb2d6f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 16 Aug 2024 14:27:15 +0200 Subject: [PATCH] apply in more places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../src/blueprints/PageBlueprint.tsx | 1 - plugins/catalog-react/api-report-alpha.md | 6 +++--- ...ntityCardBlueprint.tsx => EntityCardBlueprint.ts} | 12 ++---------- ...ontentBlueprint.tsx => EntityContentBlueprint.ts} | 12 ++---------- plugins/catalog/api-report-alpha.md | 3 +-- ...FilterBlueprint.tsx => CatalogFilterBlueprint.ts} | 8 +------- 6 files changed, 9 insertions(+), 33 deletions(-) rename plugins/catalog-react/src/alpha/blueprints/{EntityCardBlueprint.tsx => EntityCardBlueprint.ts} (87%) rename plugins/catalog-react/src/alpha/blueprints/{EntityContentBlueprint.tsx => EntityContentBlueprint.ts} (90%) rename plugins/catalog/src/alpha/blueprints/{CatalogFilterBlueprint.tsx => CatalogFilterBlueprint.ts} (81%) diff --git a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx index bdfb0141c8..303e99daaa 100644 --- a/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx +++ b/packages/frontend-plugin-api/src/blueprints/PageBlueprint.tsx @@ -50,7 +50,6 @@ export const PageBlueprint = createExtensionBlueprint({ ) { yield coreExtensionData.routePath(config.path ?? defaultPath); yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader)); - if (routeRef) { yield coreExtensionData.routeRef(routeRef); } diff --git a/plugins/catalog-react/api-report-alpha.md b/plugins/catalog-react/api-report-alpha.md index 6f801ed45f..f5828993e7 100644 --- a/plugins/catalog-react/api-report-alpha.md +++ b/plugins/catalog-react/api-report-alpha.md @@ -11,8 +11,8 @@ import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { ExtensionBlueprint } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; +import { JSX as JSX_2 } from 'react'; import { PortableSchema } from '@backstage/frontend-plugin-api'; -import { default as React_2 } from 'react'; import { ResolvedExtensionInputs } from '@backstage/frontend-plugin-api'; import { ResourcePermission } from '@backstage/plugin-permission-common'; import { RouteRef } from '@backstage/frontend-plugin-api'; @@ -182,7 +182,7 @@ export const EntityCardBlueprint: ExtensionBlueprint< loader: () => Promise; filter?: string | ((entity: Entity) => boolean) | undefined; }, - | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef | ConfigurableExtensionDataRef< (entity: Entity) => boolean, 'catalog.entity-filter-function', @@ -232,7 +232,7 @@ export const EntityContentBlueprint: ExtensionBlueprint< routeRef?: RouteRef | undefined; filter?: string | ((entity: Entity) => boolean) | undefined; }, - | ConfigurableExtensionDataRef + | ConfigurableExtensionDataRef | ConfigurableExtensionDataRef | ConfigurableExtensionDataRef< RouteRef, diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.ts similarity index 87% rename from plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx rename to plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.ts index c3153b6059..d13fd2f2c0 100644 --- a/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.tsx +++ b/plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { lazy } from 'react'; + import { ExtensionBoundary, coreExtensionData, @@ -54,15 +54,7 @@ export const EntityCardBlueprint = createExtensionBlueprint({ }, { node, config }, ) { - const ExtensionComponent = lazy(() => - loader().then(element => ({ default: () => element })), - ); - - yield coreExtensionData.reactElement( - - - , - ); + yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader)); if (config.filter) { yield catalogExtensionData.entityFilterExpression(config.filter); diff --git a/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.ts similarity index 90% rename from plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx rename to plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.ts index 7c7a6c43b7..36bca99ecc 100644 --- a/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.tsx +++ b/plugins/catalog-react/src/alpha/blueprints/EntityContentBlueprint.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { lazy } from 'react'; + import { coreExtensionData, createExtensionBlueprint, @@ -70,15 +70,7 @@ export const EntityContentBlueprint = createExtensionBlueprint({ const path = config.path ?? defaultPath; const title = config.title ?? defaultTitle; - const ExtensionComponent = lazy(() => - loader().then(element => ({ default: () => element })), - ); - - yield coreExtensionData.reactElement( - - - , - ); + yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader)); yield coreExtensionData.routePath(path); diff --git a/plugins/catalog/api-report-alpha.md b/plugins/catalog/api-report-alpha.md index 560f179efa..806fad5754 100644 --- a/plugins/catalog/api-report-alpha.md +++ b/plugins/catalog/api-report-alpha.md @@ -19,7 +19,6 @@ import { ExternalRouteRef } from '@backstage/frontend-plugin-api'; import { IconComponent } from '@backstage/core-plugin-api'; import { JSX as JSX_2 } from 'react'; import { PortableSchema } from '@backstage/frontend-plugin-api'; -import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/frontend-plugin-api'; import { SearchResultItemExtensionComponent } from '@backstage/plugin-search-react/alpha'; import { SearchResultItemExtensionPredicate } from '@backstage/plugin-search-react/alpha'; @@ -35,7 +34,7 @@ export const CatalogFilterBlueprint: ExtensionBlueprint< { loader: () => Promise; }, - ConfigurableExtensionDataRef, + ConfigurableExtensionDataRef, {}, {}, {}, diff --git a/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.ts similarity index 81% rename from plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx rename to plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.ts index e8d6df55d2..a1063b2526 100644 --- a/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.tsx +++ b/plugins/catalog/src/alpha/blueprints/CatalogFilterBlueprint.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import React, { lazy } from 'react'; import { ExtensionBoundary, coreExtensionData, @@ -30,14 +29,9 @@ export const CatalogFilterBlueprint = createExtensionBlueprint({ attachTo: { id: 'page:catalog', input: 'filters' }, output: [coreExtensionData.reactElement], factory(params: { loader: () => Promise }, { node }) { - const ExtensionComponent = lazy(() => - params.loader().then(element => ({ default: () => element })), - ); return [ coreExtensionData.reactElement( - - - , + ExtensionBoundary.lazy(node, params.loader), ), ]; },