Merge pull request #19785 from backstage/mob/optional-data

frontend-plugin-api: optional extension data
This commit is contained in:
Patrik Oldsberg
2023-09-05 19:15:36 +02:00
committed by GitHub
21 changed files with 587 additions and 228 deletions
@@ -54,9 +54,17 @@ export function createExtensionInstance(options: {
extension.factory({
source,
config: parsedConfig,
bind: mapValues(extension.output, ref => {
return (value: unknown) => extensionData.set(ref.id, value);
}),
bind: namedOutputs => {
for (const [name, output] of Object.entries(namedOutputs)) {
const ref = extension.output[name];
if (!ref) {
throw new Error(
`Extension instance '${extension.id}' tried to bind unknown output '${name}'`,
);
}
extensionData.set(ref.id, output);
}
},
inputs: mapValues(
extension.inputs,
({ extensionData: pointData }, inputName) => {
@@ -47,10 +47,12 @@ export const CoreRouter = createExtension({
return element;
};
bind.component(() => (
<BrowserRouter>
<Routes />
</BrowserRouter>
));
bind({
component: () => (
<BrowserRouter>
<Routes />
</BrowserRouter>
),
});
},
});