Merge pull request #6702 from backstage/blam/re-evaluate-if

bug: fix invalidation of entity and re-rendering of the EntityRoutes when Entity Changes
This commit is contained in:
Ben Lambert
2021-08-03 17:10:46 +02:00
committed by GitHub
2 changed files with 29 additions and 21 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog': patch
---
Fix bug with re-rendering the EntityRoutes when the entity changes but the route does not
@@ -174,28 +174,31 @@ export const EntityLayout = ({
}: EntityLayoutProps) => {
const { kind, namespace, name } = useEntityCompoundName();
const { entity, loading, error } = useContext(EntityContext);
const routes = useElementFilter(
children,
elements =>
elements
.selectByComponentData({
key: dataKey,
withStrictError:
'Child of EntityLayout must be an EntityLayout.Route',
})
.getElements<SubRoute>() // all nodes, element data, maintain structure or not?
.flatMap(({ props }) => {
if (props.if && entity && !props.if(entity)) {
return [];
}
const routes = useElementFilter(children, elements =>
elements
.selectByComponentData({
key: dataKey,
withStrictError: 'Child of EntityLayout must be an EntityLayout.Route',
})
.getElements<SubRoute>() // all nodes, element data, maintain structure or not?
.flatMap(({ props }) => {
if (props.if && entity && !props.if(entity)) {
return [];
}
return [
{
path: props.path,
title: props.title,
children: props.children,
tabProps: props.tabProps,
},
];
}),
return [
{
path: props.path,
title: props.title,
children: props.children,
tabProps: props.tabProps,
},
];
}),
[entity],
);
const { headerTitle, headerType } = headerProps(