use custom error page
Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder': patch
|
||||
'@backstage/plugin-techdocs': patch
|
||||
---
|
||||
|
||||
Use the custom error page if provided for displaying errors instead of the default error page
|
||||
@@ -42,7 +42,6 @@ import {
|
||||
selectedTemplateRouteRef,
|
||||
templateFormRouteRef,
|
||||
} from '../../routes';
|
||||
import { ErrorPage } from '@backstage/core-components';
|
||||
|
||||
import { ActionsPage } from '../../components/ActionsPage';
|
||||
import { ListTasksPage } from '../../components/ListTasksPage';
|
||||
@@ -64,6 +63,7 @@ import {
|
||||
taskReadPermission,
|
||||
templateManagementPermission,
|
||||
} from '@backstage/plugin-scaffolder-common/alpha';
|
||||
import { useApp } from '@backstage/core-plugin-api';
|
||||
|
||||
/**
|
||||
* The Props for the Scaffolder Router
|
||||
@@ -125,6 +125,8 @@ export const Router = (props: PropsWithChildren<RouterProps>) => {
|
||||
const outlet = useOutlet() || props.children;
|
||||
const customFieldExtensions =
|
||||
useCustomFieldExtensions<FieldExtensionOptions>(outlet);
|
||||
const app = useApp();
|
||||
const { NotFoundErrorPage } = app.getComponents();
|
||||
|
||||
const fieldExtensions = [
|
||||
...customFieldExtensions,
|
||||
@@ -237,10 +239,7 @@ export const Router = (props: PropsWithChildren<RouterProps>) => {
|
||||
</RequirePermission>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="*"
|
||||
element={<ErrorPage status="404" statusMessage="Page not found" />}
|
||||
/>
|
||||
<Route path="*" element={<NotFoundErrorPage />} />
|
||||
</Routes>
|
||||
);
|
||||
};
|
||||
|
||||
+5
-2
@@ -26,7 +26,7 @@ import {
|
||||
useTechDocsReaderPage,
|
||||
} from '@backstage/plugin-techdocs-react';
|
||||
import { CompoundEntityRef } from '@backstage/catalog-model';
|
||||
import { Content, ErrorPage, Progress } from '@backstage/core-components';
|
||||
import { Content, Progress } from '@backstage/core-components';
|
||||
|
||||
import { TechDocsSearch } from '../../../search';
|
||||
import { TechDocsStateIndicator } from '../TechDocsStateIndicator';
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
withTechDocsReaderProvider,
|
||||
} from '../TechDocsReaderProvider';
|
||||
import { TechDocsReaderPageContentAddons } from './TechDocsReaderPageContentAddons';
|
||||
import { useApp } from '@backstage/core-plugin-api';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
search: {
|
||||
@@ -97,6 +98,8 @@ export const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
||||
const hash = window.location.hash;
|
||||
const isStyleLoading = useShadowDomStylesLoading(dom);
|
||||
const [hashElement] = useShadowRootElements([`[id="${hash.slice(1)}"]`]);
|
||||
const app = useApp();
|
||||
const { NotFoundErrorPage } = app.getComponents();
|
||||
|
||||
useEffect(() => {
|
||||
if (isStyleLoading) return;
|
||||
@@ -122,7 +125,7 @@ export const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
||||
|
||||
// No entity metadata = 404. Don't render content at all.
|
||||
if (entityMetadataLoading === false && !entityMetadata)
|
||||
return <ErrorPage status="404" statusMessage="PAGE NOT FOUND" />;
|
||||
return <NotFoundErrorPage />;
|
||||
|
||||
// Do not return content until dom is ready; instead, render a state
|
||||
// indicator, which handles progress and content errors on our behalf.
|
||||
|
||||
Reference in New Issue
Block a user