diff --git a/.changeset/component-refs-app.md b/.changeset/component-refs-app.md new file mode 100644 index 0000000000..5a7b6723bf --- /dev/null +++ b/.changeset/component-refs-app.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-app': patch +--- + +Default implementations of core components are now provided by this package. diff --git a/.changeset/component-refs-breaking-app.md b/.changeset/component-refs-breaking-app.md new file mode 100644 index 0000000000..9ba6307f60 --- /dev/null +++ b/.changeset/component-refs-breaking-app.md @@ -0,0 +1,15 @@ +--- +'@backstage/plugin-app': minor +--- + +**BREAKING**: The `componentsApi` implementation has been removed from the plugin and replaced with the new `SwappableComponentsApi` instead. + +If you were overriding the `componentsApi` implementation, you can now use the new `SwappableComponentsApi` instead. + +```ts +// old +appPlugin.getExtension('api:app/components').override(...) + +// new +appPlugin.getExtension('api:app/swappable-components').override(...) +``` diff --git a/.changeset/component-refs-breaking-frontend-plugin-api.md b/.changeset/component-refs-breaking-frontend-plugin-api.md new file mode 100644 index 0000000000..6d43547d21 --- /dev/null +++ b/.changeset/component-refs-breaking-frontend-plugin-api.md @@ -0,0 +1,92 @@ +--- +'@backstage/frontend-plugin-api': minor +--- + +**BREAKING**: The component system has been overhauled to use `SwappableComponent` instead of `ComponentRef`. Several APIs have been removed and replaced: + +- Removed: `createComponentRef`, `createComponentExtension`, `ComponentRef`, `ComponentsApi`, `componentsApiRef`, `useComponentRef`, `coreComponentRefs` +- Added: `createSwappableComponent`, `SwappableComponentBlueprint`, `SwappableComponentRef`, `SwappableComponentsApi`, `swappableComponentsApiRef` + +**Migration for creating swappable components:** + +```tsx +// OLD: Using createComponentRef and createComponentExtension +import { + createComponentRef, + createComponentExtension, +} from '@backstage/frontend-plugin-api'; + +const myComponentRef = createComponentRef<{ title: string }>({ + id: 'my-plugin.my-component', +}); + +const myComponentExtension = createComponentExtension({ + ref: myComponentRef, + loader: { + lazy: () => import('./MyComponent').then(m => m.MyComponent), + }, +}); + +// NEW: Using createSwappableComponent and SwappableComponentBlueprint +import { + createSwappableComponent, + SwappableComponentBlueprint, +} from '@backstage/frontend-plugin-api'; + +const MySwappableComponent = createSwappableComponent({ + id: 'my-plugin.my-component', + loader: () => import('./MyComponent').then(m => m.MyComponent), +}); + +const myComponentExtension = SwappableComponentBlueprint.make({ + name: 'my-component', + params: { + component: MySwappableComponent, + loader: () => import('./MyComponent').then(m => m.MyComponent), + }, +}); +``` + +**Migration for using components:** + +```tsx +// OLD: Using ComponentsApi and useComponentRef +import { + useComponentRef, + componentsApiRef, + useApi, + coreComponentRefs, +} from '@backstage/frontend-plugin-api'; + +const MyComponent = useComponentRef(myComponentRef); +const ProgressComponent = useComponentRef(coreComponentRefs.progress); + + +// NEW: Direct component usage +import { Progress } from '@backstage/frontend-plugin-api'; + +// Use directly as React Component + + +``` + +**Migration for core component references:** + +```tsx +// OLD: Core component refs +import { coreComponentRefs } from '@backstage/frontend-plugin-api'; + +coreComponentRefs.progress +coreComponentRefs.notFoundErrorPage +coreComponentRefs.errorBoundaryFallback + +// NEW: Direct swappable component imports +import { Progress, NotFoundErrorPage, ErrorDisplay } from '@backstage/frontend-plugin-api'; + +// Use directly as React components + + + +``` + +**BREAKING**: The `errorBoundaryFallback` component and `CoreErrorBoundaryFallbackProps` type have been replaced with `ErrorDisplay` swappable component and `CoreErrorDisplayProps` respectively. diff --git a/.changeset/fuzzy-ducks-jump.md b/.changeset/fuzzy-ducks-jump.md new file mode 100644 index 0000000000..5f5930a8dc --- /dev/null +++ b/.changeset/fuzzy-ducks-jump.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-compat-api': patch +--- + +This is primarily an internal change that ensures legacy plugins continue to work with the new component system without requiring immediate migration. diff --git a/.changeset/strong-dogs-raise.md b/.changeset/strong-dogs-raise.md new file mode 100644 index 0000000000..76220474a9 --- /dev/null +++ b/.changeset/strong-dogs-raise.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-app-api': patch +--- + +Added a default implementation of the `SwappableComponentsApi` and removing the legacy `ComponentsApi` implementation diff --git a/packages/frontend-plugin-api/report.api.md b/packages/frontend-plugin-api/report.api.md index d60ce91cb7..7a17e38f92 100644 --- a/packages/frontend-plugin-api/report.api.md +++ b/packages/frontend-plugin-api/report.api.md @@ -1862,7 +1862,7 @@ export const SwappableComponentBlueprint: ExtensionBlueprint<{ | (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>); }, - 'core.component.component', + 'core.swappableComponent', {} >; inputs: {}; @@ -1876,7 +1876,7 @@ export const SwappableComponentBlueprint: ExtensionBlueprint<{ | (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>); }, - 'core.component.component', + 'core.swappableComponent', {} >; }; diff --git a/plugins/app/report.api.md b/plugins/app/report.api.md index c203990916..423da8ec89 100644 --- a/plugins/app/report.api.md +++ b/plugins/app/report.api.md @@ -597,7 +597,7 @@ const appPlugin: FrontendPlugin< | (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>); }, - 'core.component.component', + 'core.swappableComponent', {} >, { @@ -740,7 +740,7 @@ const appPlugin: FrontendPlugin< | (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>); }, - 'core.component.component', + 'core.swappableComponent', {} >; inputs: {}; @@ -796,7 +796,7 @@ const appPlugin: FrontendPlugin< | (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>); }, - 'core.component.component', + 'core.swappableComponent', {} >; inputs: {}; @@ -852,7 +852,7 @@ const appPlugin: FrontendPlugin< | (() => (props: {}) => JSX.Element | null) | (() => Promise<(props: {}) => JSX.Element | null>); }, - 'core.component.component', + 'core.swappableComponent', {} >; inputs: {};