Merge pull request #23262 from backstage/rugvip/entity404

catalog: fix alpha entity 404
This commit is contained in:
Patrik Oldsberg
2024-02-26 17:02:15 +01:00
committed by GitHub
2 changed files with 21 additions and 15 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog': patch
---
The entity page extension provided by the `/alpha` plugin now correctly renders the entity 404 page.
+16 -15
View File
@@ -65,22 +65,23 @@ export const catalogEntityPage = createPageExtension({
loader: async ({ inputs }) => {
const { EntityLayout } = await import('../components/EntityLayout');
const Component = () => {
const { entity, ...rest } = useEntityFromUrl();
return (
<AsyncEntityProvider entity={entity} {...rest}>
{entity ? (
<EntityLayout>
{inputs.contents
.filter(({ output: { filterFunction, filterExpression } }) =>
buildFilterFn(filterFunction, filterExpression)(entity),
)
.map(({ output: { path, title, element } }) => (
<EntityLayout.Route key={path} path={path} title={title}>
{element}
</EntityLayout.Route>
))}
</EntityLayout>
) : null}
<AsyncEntityProvider {...useEntityFromUrl()}>
<EntityLayout>
{inputs.contents.map(({ output }) => (
<EntityLayout.Route
key={output.path}
path={output.path}
title={output.title}
if={buildFilterFn(
output.filterFunction,
output.filterExpression,
)}
>
{output.element}
</EntityLayout.Route>
))}
</EntityLayout>
</AsyncEntityProvider>
);
};