From a412f3d70efcb9bf6c420e2aca2febc28ecf1209 Mon Sep 17 00:00:00 2001 From: Rebeka Date: Thu, 1 Jun 2023 21:58:21 +0200 Subject: [PATCH] Add error boundary to the project dashboard list GitOrigin-RevId: 0f4cc3b4db62efe25ceeff202f305d08ddd73968 --- .../components/project-list-root.tsx | 4 ++- .../js/shared/components/default-message.tsx | 17 ++++++++++ .../components/error-boundary-fallback.tsx | 10 ++---- .../generic-error-boundary-fallback.tsx | 33 +++++++++++++++++++ .../app/editor/error-boundary.less | 33 +++++++++++++++++++ .../stylesheets/app/project-list-react.less | 1 + 6 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 services/web/frontend/js/shared/components/default-message.tsx create mode 100644 services/web/frontend/js/shared/components/generic-error-boundary-fallback.tsx diff --git a/services/web/frontend/js/features/project-list/components/project-list-root.tsx b/services/web/frontend/js/features/project-list/components/project-list-root.tsx index b3d38ed69b..cd2bc4b0c9 100644 --- a/services/web/frontend/js/features/project-list/components/project-list-root.tsx +++ b/services/web/frontend/js/features/project-list/components/project-list-root.tsx @@ -25,6 +25,8 @@ import LoadMore from './load-more' import { useEffect } from 'react' import getMeta from '../../../utils/meta' import WelcomeMessageNew from './welcome-message-new' +import withErrorBoundary from '../../../infrastructure/error-boundary' +import { GenericErrorBoundaryFallback } from '../../../shared/components/generic-error-boundary-fallback' function ProjectListRoot() { const { isReady } = useWaitForI18n() @@ -191,4 +193,4 @@ function DashApiError() { ) } -export default ProjectListRoot +export default withErrorBoundary(ProjectListRoot, GenericErrorBoundaryFallback) diff --git a/services/web/frontend/js/shared/components/default-message.tsx b/services/web/frontend/js/shared/components/default-message.tsx new file mode 100644 index 0000000000..63b992fac5 --- /dev/null +++ b/services/web/frontend/js/shared/components/default-message.tsx @@ -0,0 +1,17 @@ +import { useTranslation } from 'react-i18next' + +type DefaultMessageProps = { + className?: string + style?: React.CSSProperties +} + +export function DefaultMessage({ className, style }: DefaultMessageProps) { + const { t } = useTranslation() + + return ( + <> + {`${t('generic_something_went_wrong')}. `} + {`${t('please_refresh')}`} + + ) +} diff --git a/services/web/frontend/js/shared/components/error-boundary-fallback.tsx b/services/web/frontend/js/shared/components/error-boundary-fallback.tsx index 14b9dc183b..7cfd9b7fe8 100644 --- a/services/web/frontend/js/shared/components/error-boundary-fallback.tsx +++ b/services/web/frontend/js/shared/components/error-boundary-fallback.tsx @@ -1,6 +1,6 @@ import { FC, ReactNode } from 'react' import { Alert } from 'react-bootstrap' -import { useTranslation } from 'react-i18next' +import { DefaultMessage } from './default-message' export const ErrorBoundaryFallback: FC<{ modal?: ReactNode }> = ({ children, @@ -8,14 +8,8 @@ export const ErrorBoundaryFallback: FC<{ modal?: ReactNode }> = ({ }) => { return (
- {children || } + {children || } {modal}
) } - -const DefaultContent = () => { - const { t } = useTranslation() - - return

{`${t('generic_something_went_wrong')}. ${t('please_refresh')}`}

-} diff --git a/services/web/frontend/js/shared/components/generic-error-boundary-fallback.tsx b/services/web/frontend/js/shared/components/generic-error-boundary-fallback.tsx new file mode 100644 index 0000000000..682eac67ce --- /dev/null +++ b/services/web/frontend/js/shared/components/generic-error-boundary-fallback.tsx @@ -0,0 +1,33 @@ +import { FC } from 'react' +import { useTranslation } from 'react-i18next' +import Icon from './icon' +import { Button } from 'react-bootstrap' +import { useLocation } from '../hooks/use-location' +import { DefaultMessage } from './default-message' + +export const GenericErrorBoundaryFallback: FC = ({ children }) => { + const { t } = useTranslation() + const { reload: handleClick } = useLocation() + + return ( +
+
+ +
+ {children || ( +
+ +
+ )} + +
+ ) +} diff --git a/services/web/frontend/stylesheets/app/editor/error-boundary.less b/services/web/frontend/stylesheets/app/editor/error-boundary.less index dcbcf8ee92..230a2081a2 100644 --- a/services/web/frontend/stylesheets/app/editor/error-boundary.less +++ b/services/web/frontend/stylesheets/app/editor/error-boundary.less @@ -5,3 +5,36 @@ background-color: @ol-blue-gray-0; padding: @line-height-computed / 2; } + +.error-boundary-container { + align-items: center; + display: flex; + flex-direction: column; + gap: 16px; + height: 211px; + justify-content: center; + margin: auto; + padding: 0px; + width: 266px; +} + +.error-message-container { + align-items: center; + color: @neutral-90; + display: flex; + flex-direction: column; + gap: 4px; + height: 56px; + padding: 0px; + width: 266px; +} + +.icon-error-boundary-container { + align-items: center; + background: #ffffff; + border-radius: 999px; + display: grid; + height: 88px; + padding: 24px; + width: 88px; +} diff --git a/services/web/frontend/stylesheets/app/project-list-react.less b/services/web/frontend/stylesheets/app/project-list-react.less index 461490e61c..da6b92fd34 100644 --- a/services/web/frontend/stylesheets/app/project-list-react.less +++ b/services/web/frontend/stylesheets/app/project-list-react.less @@ -5,6 +5,7 @@ padding-top: @header-height; padding-bottom: 0; min-height: calc(~'100vh -' @header-height); + display: flex; } .container:before {