added supoprt for a custom component when entity not found

Signed-off-by: shahar.shmaram <shahar.shmaram@appsflyer.com>
This commit is contained in:
shahar.shmaram
2022-04-21 12:55:16 +03:00
parent cd539a7ff3
commit 27032df2d1
@@ -152,6 +152,7 @@ export interface EntityLayoutProps {
UNSTABLE_extraContextMenuItems?: ExtraContextMenuItem[];
UNSTABLE_contextMenuOptions?: contextMenuOptions;
children?: React.ReactNode;
NotFoundComponent?: React.ReactNode;
}
/**
@@ -176,6 +177,7 @@ export const EntityLayout = (props: EntityLayoutProps) => {
UNSTABLE_extraContextMenuItems,
UNSTABLE_contextMenuOptions,
children,
NotFoundComponent,
} = props;
const { kind, namespace, name } = useRouteRefParams(entityRouteRef);
const { entity, loading, error } = useAsyncEntity();
@@ -259,7 +261,17 @@ export const EntityLayout = (props: EntityLayoutProps) => {
{error && (
<Content>
<Alert severity="error">{error.toString()}</Alert>
{NotFoundComponent ? (
NotFoundComponent
) : (
<WarningPanel title="Entity not found">
There is no {kind} with the requested{' '}
<Link to="https://backstage.io/docs/features/software-catalog/references">
kind, namespace, and name
</Link>
.
</WarningPanel>
)}
</Content>
)}