-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): correct visuals for LPC errors (#16091)
For reasons I don't understand, the LPC fatal error screen is its own modal, which maybe used to be good but now looks extremely weird on the ODD and maybe the app. Maybe because we changed the modal background or something? I don't know why we didn't see this before. Anyway, it's gross that it works that way, so just split it into a contents component and an actual modal component. When we get a fatal error that's not bad enough to break the JS, we render it as the active component, and when we hit the (unique?) error boundary, we render it as a modal. Closes RQA-2987
- Loading branch information
Showing
3 changed files
with
89 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,69 +25,91 @@ import { WizardHeader } from '../../molecules/WizardHeader' | |
import { i18n } from '../../i18n' | ||
|
||
const SUPPORT_EMAIL = '[email protected]' | ||
|
||
interface FatalErrorModalProps { | ||
interface FatalErrorProps { | ||
errorMessage: string | ||
shouldUseMetalProbe: boolean | ||
onClose: () => void | ||
} | ||
|
||
interface FatalErrorModalProps extends FatalErrorProps { | ||
isOnDevice: boolean | ||
} | ||
|
||
export function FatalErrorModal(props: FatalErrorModalProps): JSX.Element { | ||
const { errorMessage, shouldUseMetalProbe, onClose } = props | ||
const { t } = useTranslation(['labware_position_check', 'shared', 'branded']) | ||
const { onClose, isOnDevice } = props | ||
return createPortal( | ||
<LegacyModalShell | ||
width="47rem" | ||
header={ | ||
isOnDevice ? ( | ||
<LegacyModalShell fullPage> | ||
<WizardHeader | ||
title={t('labware_position_check_title')} | ||
onExit={onClose} | ||
/> | ||
} | ||
> | ||
<Flex | ||
padding={SPACING.spacing32} | ||
flexDirection={DIRECTION_COLUMN} | ||
alignItems={ALIGN_CENTER} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
gridGap={SPACING.spacing16} | ||
<FatalError {...props} /> | ||
</LegacyModalShell> | ||
) : ( | ||
<LegacyModalShell | ||
width="47rem" | ||
header={ | ||
<WizardHeader | ||
title={t('labware_position_check_title')} | ||
onExit={onClose} | ||
/> | ||
} | ||
> | ||
<Icon | ||
name="ot-alert" | ||
size="2.5rem" | ||
color={COLORS.red50} | ||
aria-label="alert" | ||
/> | ||
<ErrorHeader> | ||
{i18n.format(t('shared:something_went_wrong'), 'sentenceCase')} | ||
</ErrorHeader> | ||
{shouldUseMetalProbe ? ( | ||
<LegacyStyledText | ||
as="p" | ||
fontWeight={TYPOGRAPHY.fontWeightSemiBold} | ||
textAlign={TEXT_ALIGN_CENTER} | ||
> | ||
{t('remove_probe_before_exit')} | ||
</LegacyStyledText> | ||
) : null} | ||
<LegacyStyledText as="p" textAlign={TEXT_ALIGN_CENTER}> | ||
{t('branded:help_us_improve_send_error_report', { | ||
support_email: SUPPORT_EMAIL, | ||
})} | ||
</LegacyStyledText> | ||
<ErrorTextArea readOnly value={errorMessage ?? ''} spellCheck={false} /> | ||
<PrimaryButton | ||
textTransform={TEXT_TRANSFORM_CAPITALIZE} | ||
alignSelf={ALIGN_FLEX_END} | ||
onClick={onClose} | ||
> | ||
{t('shared:exit')} | ||
</PrimaryButton> | ||
</Flex> | ||
</LegacyModalShell>, | ||
<FatalError {...props} /> | ||
</LegacyModalShell> | ||
), | ||
getTopPortalEl() | ||
) | ||
} | ||
|
||
export function FatalError(props: FatalErrorProps): JSX.Element { | ||
const { errorMessage, shouldUseMetalProbe, onClose } = props | ||
const { t } = useTranslation(['labware_position_check', 'shared', 'branded']) | ||
return ( | ||
<Flex | ||
padding={SPACING.spacing32} | ||
flexDirection={DIRECTION_COLUMN} | ||
alignItems={ALIGN_CENTER} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
gridGap={SPACING.spacing16} | ||
> | ||
<Icon | ||
name="ot-alert" | ||
size="2.5rem" | ||
color={COLORS.red50} | ||
aria-label="alert" | ||
/> | ||
<ErrorHeader> | ||
{i18n.format(t('shared:something_went_wrong'), 'sentenceCase')} | ||
</ErrorHeader> | ||
{shouldUseMetalProbe ? ( | ||
<LegacyStyledText | ||
as="p" | ||
fontWeight={TYPOGRAPHY.fontWeightSemiBold} | ||
textAlign={TEXT_ALIGN_CENTER} | ||
> | ||
{t('remove_probe_before_exit')} | ||
</LegacyStyledText> | ||
) : null} | ||
<LegacyStyledText as="p" textAlign={TEXT_ALIGN_CENTER}> | ||
{t('branded:help_us_improve_send_error_report', { | ||
support_email: SUPPORT_EMAIL, | ||
})} | ||
</LegacyStyledText> | ||
<ErrorTextArea readOnly value={errorMessage ?? ''} spellCheck={false} /> | ||
<PrimaryButton | ||
textTransform={TEXT_TRANSFORM_CAPITALIZE} | ||
alignSelf={ALIGN_FLEX_END} | ||
onClick={onClose} | ||
> | ||
{t('shared:exit')} | ||
</PrimaryButton> | ||
</Flex> | ||
) | ||
} | ||
|
||
const ErrorHeader = styled.h1` | ||
text-align: ${TEXT_ALIGN_CENTER}; | ||
${TYPOGRAPHY.h1Default} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters