changesets: add changeset for v2 extensions

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-07-29 09:46:00 +02:00
parent 47bc4046c5
commit 3be9aeb1dd
2 changed files with 63 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/frontend-test-utils': patch
'@backstage/frontend-app-api': patch
---
Added support for v2 extensions, which declare their inputs and outputs without using a data map.
+57
View File
@@ -0,0 +1,57 @@
---
'@backstage/frontend-plugin-api': patch
---
Extensions have been changed to be declared with an array of inputs and outputs, rather than a map of named data refs. This change was made to reduce confusion around the role of the input and output names, as well as enable more powerful APIs for overriding extensions.
An extension that was previously declared like this:
```tsx
const exampleExtension = createExtension({
name: 'example',
inputs: {
items: createExtensionInput({
element: coreExtensionData.reactElement,
}),
},
output: {
element: coreExtensionData.reactElement,
},
factory({ inputs }) {
return {
element: (
<div>
Example
{inputs.items.map(item => {
return <div>{item.output.element}</div>;
})}
</div>
),
};
},
});
```
Should be migrated to the following:
```tsx
const exampleExtension = createExtension({
name: 'example',
inputs: {
items: createExtensionInput([coreExtensionData.reactElement]),
},
output: [coreExtensionData.reactElement],
factory({ inputs }) {
return [
coreExtensionData.reactElement(
<div>
Example
{inputs.items.map(item => {
return <div>{item.get(coreExtensionData.reactElement)}</div>;
})}
</div>,
),
];
},
});
```