diff --git a/.changeset/real-grapes-sing.md b/.changeset/real-grapes-sing.md new file mode 100644 index 0000000000..484fc7969a --- /dev/null +++ b/.changeset/real-grapes-sing.md @@ -0,0 +1,8 @@ +--- +'@backstage/core-components': patch +'@backstage/app-defaults': minor +'@backstage/plugin-playlist': patch +'@backstage/plugin-scaffolder': minor +--- + +Added stack trace display to `ErrorPage` and updated existing refs diff --git a/packages/app-defaults/src/defaults/components.tsx b/packages/app-defaults/src/defaults/components.tsx index 1e2fddca07..9b58694f2b 100644 --- a/packages/app-defaults/src/defaults/components.tsx +++ b/packages/app-defaults/src/defaults/components.tsx @@ -49,7 +49,7 @@ const DefaultBootErrorPage = ({ step, error }: BootErrorPageProps) => { // TODO: figure out a nicer way to handle routing on the error page, when it can be done. return ( - + ); }; diff --git a/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx b/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx index 2efdc5da33..d7036d0a5b 100644 --- a/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx +++ b/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx @@ -99,4 +99,15 @@ describe('', () => { 'https://error-page-test-support-url.com', ); }); + + it('should render show details if stack is provided', async () => { + const { getByText } = await renderInTestApp( + , + ); + expect(getByText(/Show more details/i)).toBeInTheDocument(); + }); }); diff --git a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx index 4639e8de59..131df3da3a 100644 --- a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx @@ -22,12 +22,14 @@ import { useNavigate } from 'react-router-dom'; import { Link } from '../../components/Link'; import { useSupportConfig } from '../../hooks'; import { MicDrop } from './MicDrop'; +import { StackDetails } from './StackDetails'; interface IErrorPageProps { status?: string; statusMessage: string; additionalInfo?: React.ReactNode; supportUrl?: string; + stack?: string; } /** @public */ @@ -62,13 +64,13 @@ const useStyles = makeStyles( * */ export function ErrorPage(props: IErrorPageProps) { - const { status, statusMessage, additionalInfo, supportUrl } = props; + const { status, statusMessage, additionalInfo, supportUrl, stack } = props; const classes = useStyles(); const navigate = useNavigate(); const support = useSupportConfig(); return ( - + Looks like someone dropped the mic! - + navigate(-1)}> Go back @@ -91,6 +93,7 @@ export function ErrorPage(props: IErrorPageProps) { contact support if you think this is a bug. + {stack && } diff --git a/packages/core-components/src/layout/ErrorPage/StackDetails.tsx b/packages/core-components/src/layout/ErrorPage/StackDetails.tsx new file mode 100644 index 0000000000..b46a937485 --- /dev/null +++ b/packages/core-components/src/layout/ErrorPage/StackDetails.tsx @@ -0,0 +1,77 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Typography from '@material-ui/core/Typography'; +import React from 'react'; +import { useState } from 'react'; +import { Link } from '../../components/Link'; +import { CodeSnippet } from '../../components'; +import { makeStyles } from '@material-ui/core/styles'; + +interface IStackDetailsProps { + stack: string; +} + +const useStyles = makeStyles( + theme => ({ + title: { + paddingBottom: theme.spacing(5), + [theme.breakpoints.down('xs')]: { + paddingBottom: theme.spacing(4), + fontSize: theme.typography.h3.fontSize, + }, + }, + }), + { name: 'BackstageErrorPageStackDetails' }, +); + +/** + * Error page details with stack trace + * + * @public + * + */ +export function StackDetails(props: IStackDetailsProps) { + const { stack } = props; + const classes = useStyles(); + + const [detailsOpen, setDetailsOpen] = useState(false); + + if (!detailsOpen) { + return ( + + setDetailsOpen(true)}> + Show more details + + + ); + } + + return ( + <> + + setDetailsOpen(false)}> + Show less details + + + + + ); +} diff --git a/plugins/playlist/src/components/PlaylistPage/PlaylistPage.tsx b/plugins/playlist/src/components/PlaylistPage/PlaylistPage.tsx index 4c9a0edbb7..b17fbd2fb7 100644 --- a/plugins/playlist/src/components/PlaylistPage/PlaylistPage.tsx +++ b/plugins/playlist/src/components/PlaylistPage/PlaylistPage.tsx @@ -84,6 +84,7 @@ export const PlaylistPage = () => { ); } diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx index 9957d22456..9c0276fa28 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx @@ -142,6 +142,7 @@ export const ActionsPage = () => { ); }