refactor to forward node to ExtensionBoundary
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -34,15 +34,11 @@ const wrapInBoundaryExtension = (element: JSX.Element) => {
|
||||
path: coreExtensionData.routePath,
|
||||
routeRef: coreExtensionData.routeRef.optional(),
|
||||
},
|
||||
factory({ source }) {
|
||||
factory({ node }) {
|
||||
return {
|
||||
routeRef,
|
||||
path: '/',
|
||||
element: (
|
||||
<ExtensionBoundary id={id} source={source}>
|
||||
{element}
|
||||
</ExtensionBoundary>
|
||||
),
|
||||
element: <ExtensionBoundary node={node}>{element}</ExtensionBoundary>,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -15,16 +15,12 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
|
||||
import { useAnalytics } from '@backstage/core-plugin-api';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
import { PortableSchema } from '../schema';
|
||||
import {
|
||||
coreExtensionData,
|
||||
createExtensionInput,
|
||||
createPlugin,
|
||||
} from '../wiring';
|
||||
import { coreExtensionData, createExtensionInput } from '../wiring';
|
||||
import { createPageExtension } from './createPageExtension';
|
||||
import { createExtensionTester } from '@backstage/frontend-test-utils';
|
||||
|
||||
jest.mock('@backstage/core-plugin-api', () => ({
|
||||
...jest.requireActual('@backstage/core-plugin-api'),
|
||||
@@ -120,19 +116,13 @@ describe('createPageExtension', () => {
|
||||
captureEvent,
|
||||
});
|
||||
|
||||
const extension = createPageExtension({
|
||||
id: 'plugin.page',
|
||||
defaultPath: '/',
|
||||
loader: async () => <div>Component</div>,
|
||||
});
|
||||
|
||||
const output = extension.factory({
|
||||
source: createPlugin({ id: 'plugin ' }),
|
||||
config: { path: '/' },
|
||||
inputs: {},
|
||||
});
|
||||
|
||||
renderWithEffects(wrapInTestApp(output.element as unknown as JSX.Element));
|
||||
createExtensionTester(
|
||||
createPageExtension({
|
||||
id: 'plugin.page',
|
||||
defaultPath: '/',
|
||||
loader: async () => <div>Component</div>,
|
||||
}),
|
||||
).render();
|
||||
|
||||
await waitFor(() =>
|
||||
expect(captureEvent).toHaveBeenCalledWith(
|
||||
|
||||
@@ -75,7 +75,7 @@ export function createPageExtension<
|
||||
path: coreExtensionData.routePath,
|
||||
routeRef: coreExtensionData.routeRef.optional(),
|
||||
},
|
||||
factory({ config, inputs, source }) {
|
||||
factory({ config, inputs, node }) {
|
||||
const ExtensionComponent = lazy(() =>
|
||||
options
|
||||
.loader({ config, inputs })
|
||||
@@ -86,7 +86,7 @@ export function createPageExtension<
|
||||
path: config.path,
|
||||
routeRef: options.routeRef,
|
||||
element: (
|
||||
<ExtensionBoundary id={id} source={source} routable>
|
||||
<ExtensionBoundary node={node} routable>
|
||||
<ExtensionComponent />
|
||||
</ExtensionBoundary>
|
||||
),
|
||||
|
||||
@@ -113,7 +113,7 @@ export function createEntityCardExtension<
|
||||
.optional(),
|
||||
}),
|
||||
),
|
||||
factory({ config, inputs, source }) {
|
||||
factory({ config, inputs, node }) {
|
||||
const ExtensionComponent = lazy(() =>
|
||||
options
|
||||
.loader({ inputs })
|
||||
@@ -122,7 +122,7 @@ export function createEntityCardExtension<
|
||||
|
||||
return {
|
||||
element: (
|
||||
<ExtensionBoundary id={id} source={source}>
|
||||
<ExtensionBoundary node={node}>
|
||||
<ExtensionComponent />
|
||||
</ExtensionBoundary>
|
||||
),
|
||||
@@ -179,7 +179,7 @@ export function createEntityContentExtension<
|
||||
.optional(),
|
||||
}),
|
||||
),
|
||||
factory({ config, inputs, source }) {
|
||||
factory({ config, inputs, node }) {
|
||||
const ExtensionComponent = lazy(() =>
|
||||
options
|
||||
.loader({ inputs })
|
||||
@@ -191,7 +191,7 @@ export function createEntityContentExtension<
|
||||
title: config.title,
|
||||
routeRef: options.routeRef,
|
||||
element: (
|
||||
<ExtensionBoundary id={id} source={source} routable>
|
||||
<ExtensionBoundary node={node} routable>
|
||||
<ExtensionComponent />
|
||||
</ExtensionBoundary>
|
||||
),
|
||||
|
||||
@@ -43,7 +43,7 @@ export function createCatalogFilterExtension<
|
||||
output: {
|
||||
element: coreExtensionData.reactElement,
|
||||
},
|
||||
factory({ config, source }) {
|
||||
factory({ config, node }) {
|
||||
const ExtensionComponent = lazy(() =>
|
||||
options
|
||||
.loader({ config })
|
||||
@@ -52,7 +52,7 @@ export function createCatalogFilterExtension<
|
||||
|
||||
return {
|
||||
element: (
|
||||
<ExtensionBoundary id={id} source={source}>
|
||||
<ExtensionBoundary node={node}>
|
||||
<ExtensionComponent />
|
||||
</ExtensionBoundary>
|
||||
),
|
||||
|
||||
@@ -107,7 +107,7 @@ export function createSearchResultListItemExtension<
|
||||
output: {
|
||||
item: searchResultItemExtensionData,
|
||||
},
|
||||
factory({ config, source }) {
|
||||
factory({ config, node }) {
|
||||
const ExtensionComponent = lazy(() =>
|
||||
options
|
||||
.component({ config })
|
||||
@@ -118,7 +118,7 @@ export function createSearchResultListItemExtension<
|
||||
item: {
|
||||
predicate: options.predicate,
|
||||
component: props => (
|
||||
<ExtensionBoundary id={id} source={source}>
|
||||
<ExtensionBoundary node={node}>
|
||||
<SearchResultListItemExtension
|
||||
rank={props.rank}
|
||||
result={props.result}
|
||||
|
||||
Reference in New Issue
Block a user