From 39579f03b74972f17b505b96f20b7c61ca06522d Mon Sep 17 00:00:00 2001 From: Jithen Shriyan Date: Mon, 22 Jan 2024 16:18:24 -0500 Subject: [PATCH] [update] use code snippet component, remove warning panel Signed-off-by: Jithen Shriyan --- .changeset/real-grapes-sing.md | 5 +- .../src/layout/ErrorPage/ErrorPage.tsx | 50 ++---------- .../src/layout/ErrorPage/MicDrop.tsx | 2 +- .../src/layout/ErrorPage/StackDetails.tsx | 77 +++++++++++++++++++ 4 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 packages/core-components/src/layout/ErrorPage/StackDetails.tsx diff --git a/.changeset/real-grapes-sing.md b/.changeset/real-grapes-sing.md index 80fb9edab0..4656d57a2d 100644 --- a/.changeset/real-grapes-sing.md +++ b/.changeset/real-grapes-sing.md @@ -1,5 +1,8 @@ --- '@backstage/core-components': patch +'@backstage/app-defaults': minor +'@backstage/playlist': patch +'@backstage/scaffolder': minor --- -Included stack trace display option in ErrorPage component +Added stack trace display to `ErrorPage` and updated existing refs diff --git a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx index 9b10067fa6..131df3da3a 100644 --- a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx @@ -20,9 +20,9 @@ import Typography from '@material-ui/core/Typography'; import React from 'react'; import { useNavigate } from 'react-router-dom'; import { Link } from '../../components/Link'; -import { CopyTextButton, WarningPanel } from '../../components'; import { useSupportConfig } from '../../hooks'; import { MicDrop } from './MicDrop'; +import { StackDetails } from './StackDetails'; interface IErrorPageProps { status?: string; @@ -53,26 +53,6 @@ const useStyles = makeStyles( subtitle: { color: theme.palette.textSubtle, }, - goBackTitle: { - color: theme.palette.textSubtle, - marginBottom: theme.spacing(5), - [theme.breakpoints.down('xs')]: { - marginBottom: theme.spacing(4), - }, - }, - stackTraceText: { - maxHeight: '30vh', - overflow: 'scroll', - fontFamily: 'monospace', - whiteSpace: 'pre', - overflowX: 'auto', - marginRight: theme.spacing(2), - }, - copyTextContainer: { - display: 'flex', - justifyContent: 'flex-end', - alignItems: 'flex-start', - }, }), { name: 'BackstageErrorPage' }, ); @@ -91,7 +71,7 @@ export function ErrorPage(props: IErrorPageProps) { return ( - + Looks like someone dropped the mic! - + navigate(-1)}> Go back @@ -113,29 +93,9 @@ export function ErrorPage(props: IErrorPageProps) { contact support if you think this is a bug. - {stack && ( - - - - Stack Trace - - {stack} - - - - - - - - )} - - - + {stack && } + ); } diff --git a/packages/core-components/src/layout/ErrorPage/MicDrop.tsx b/packages/core-components/src/layout/ErrorPage/MicDrop.tsx index a16de3f5e6..d55c50bd29 100644 --- a/packages/core-components/src/layout/ErrorPage/MicDrop.tsx +++ b/packages/core-components/src/layout/ErrorPage/MicDrop.tsx @@ -21,7 +21,7 @@ import MicDropSvgUrl from './mic-drop.svg'; const useStyles = makeStyles( theme => ({ micDrop: { - maxWidth: '80%', + maxWidth: '60%', bottom: theme.spacing(2), right: theme.spacing(2), [theme.breakpoints.down('xs')]: { 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 + + + + + ); +}