diff --git a/.changeset/gorgeous-ties-doubt.md b/.changeset/gorgeous-ties-doubt.md new file mode 100644 index 0000000000..c046e71572 --- /dev/null +++ b/.changeset/gorgeous-ties-doubt.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Show a Not Found message when navigating to a nonexistent entity diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx index e040c6a67f..f9faa3f90f 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx @@ -61,6 +61,30 @@ describe('EntityLayout', () => { expect(rendered.getByText('tabbed-test-content')).toBeInTheDocument(); }); + it('renders error message when entity is not found', async () => { + const noEntityData = { + ...mockEntityData, + entity: undefined, + }; + + const rendered = await renderInTestApp( + + + + +
tabbed-test-content
+
+
+
+
, + ); + + expect(rendered.getByText('Warning: Entity not found')).toBeInTheDocument(); + expect(rendered.queryByText('my-entity')).not.toBeInTheDocument(); + expect(rendered.queryByText('tabbed-test-title')).not.toBeInTheDocument(); + expect(rendered.queryByText('tabbed-test-content')).not.toBeInTheDocument(); + }); + it('navigates when user clicks different tab', async () => { const rendered = await renderInTestApp( diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx index a139fbaa1e..eabcbe4993 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx @@ -23,9 +23,11 @@ import { Content, Header, HeaderLabel, + Link, Page, Progress, RoutedTabs, + WarningPanel, } from '@backstage/core-components'; import { attachComponentData, @@ -245,6 +247,19 @@ export const EntityLayout = ({ {error.toString()} )} + + {!loading && !error && !entity && ( + + + There is no {kind} with the requested{' '} + + kind, namespace, and name + + . + + + )} +