-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
556 additions
and
10 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
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{ | ||
"run_paused": "Run paused" | ||
"before_you_begin": "Before you begin", | ||
"general_error": "General error", | ||
"general_error_message": "<Placeholder>", | ||
"recovery_mode": "Recovery Mode", | ||
"recovery_mode_explanation": "<block>Recovery Mode provides you with guided and manual controls for handling errors at runtime.</block><br/><block>You can make changes to ensure the step in progress when the error occurred can be completed or choose to cancel the protocol. When changes are made and no subsequent errors are detected, the method completes. Depending on the conditions that caused the error, you will only be provided with appropriate options.</block>", | ||
"run_paused": "Run paused", | ||
"stand_back": "Stand back, robot is in motion", | ||
"view_recovery_options": "View recovery options" | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as React from 'react' | ||
import { Trans, useTranslation } from 'react-i18next' | ||
|
||
import { | ||
DIRECTION_COLUMN, | ||
Flex, | ||
JUSTIFY_SPACE_BETWEEN, | ||
SPACING, | ||
JUSTIFY_CENTER, | ||
StyledText, | ||
} from '@opentrons/components' | ||
|
||
import { SmallButton } from '../../atoms/buttons' | ||
import { | ||
RECOVERY_COLOR_STYLE, | ||
BODY_TEXT_STYLE, | ||
ODD_SECTION_TITLE_STYLE, | ||
} from './constants' | ||
|
||
import type { RecoveryContentProps } from './types' | ||
|
||
export function BeforeBeginning({ | ||
isOnDevice, | ||
routeUpdateActions, | ||
}: RecoveryContentProps): JSX.Element | null { | ||
const { t } = useTranslation('error_recovery') | ||
const { proceed } = routeUpdateActions | ||
|
||
if (isOnDevice) { | ||
return ( | ||
<Flex | ||
padding={SPACING.spacing32} | ||
flexDirection={DIRECTION_COLUMN} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
height="100%" | ||
> | ||
<Flex flexDirection={DIRECTION_COLUMN} height="100%"> | ||
<Flex css={ODD_SECTION_TITLE_STYLE}>{t('before_you_begin')}</Flex> | ||
<Trans | ||
t={t} | ||
i18nKey={'error_recovery:recovery_mode_explanation'} | ||
components={{ block: <StyledText as="p" css={BODY_TEXT_STYLE} /> }} | ||
/> | ||
<SmallButton | ||
buttonType="primary" | ||
css={RECOVERY_COLOR_STYLE} | ||
buttonText={t('view_recovery_options')} | ||
justifyContent={JUSTIFY_CENTER} | ||
onClick={proceed} | ||
marginTop="auto" | ||
/> | ||
</Flex> | ||
</Flex> | ||
) | ||
} else { | ||
return null | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { css } from 'styled-components' | ||
|
||
import { | ||
Box, | ||
DIRECTION_ROW, | ||
BORDERS, | ||
ALIGN_CENTER, | ||
Flex, | ||
JUSTIFY_SPACE_BETWEEN, | ||
TYPOGRAPHY, | ||
COLORS, | ||
SPACING, | ||
RESPONSIVENESS, | ||
StyledText, | ||
Icon, | ||
} from '@opentrons/components' | ||
|
||
import { useErrorName } from './utils' | ||
import { NON_DESIGNED_SANCTION_COLOR_BLACK } from './constants' | ||
|
||
interface ErrorRecoveryHeaderProps { | ||
errorType?: string | ||
} | ||
export function ErrorRecoveryHeader({ | ||
errorType, | ||
}: ErrorRecoveryHeaderProps): JSX.Element { | ||
const { t } = useTranslation('error_recovery') | ||
const errorName = useErrorName(errorType) | ||
|
||
return ( | ||
<Box css={BOX_STYLE}> | ||
<Flex css={HEADER_CONTAINER_STYLE}> | ||
<Flex | ||
flexDirection={DIRECTION_ROW} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
alignItems={ALIGN_CENTER} | ||
width="100%" | ||
> | ||
<StyledText css={HEADER_TEXT_STYLE}>{t('recovery_mode')}</StyledText> | ||
<Flex gridGap={SPACING.spacing8}> | ||
<AlertHeaderIcon /> | ||
<StyledText css={HEADER_TEXT_STYLE}>{errorName}</StyledText> | ||
</Flex> | ||
</Flex> | ||
</Flex> | ||
</Box> | ||
) | ||
} | ||
|
||
function AlertHeaderIcon(): JSX.Element { | ||
return ( | ||
<Icon | ||
name="ot-alert" | ||
css={css` | ||
color: ${COLORS.white}; | ||
`} | ||
size="1.75rem" | ||
/> | ||
) | ||
} | ||
|
||
const BOX_STYLE = css` | ||
background-color: ${NON_DESIGNED_SANCTION_COLOR_BLACK}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
border-radius: ${BORDERS.borderRadius12} ${BORDERS.borderRadius12} 0 0; | ||
} | ||
` | ||
const HEADER_CONTAINER_STYLE = css` | ||
flex-direction: ${DIRECTION_ROW}; | ||
justify-content: ${JUSTIFY_SPACE_BETWEEN}; | ||
padding: ${SPACING.spacing16} ${SPACING.spacing32}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
padding: 1.75rem ${SPACING.spacing32}; | ||
} | ||
` | ||
const HEADER_TEXT_STYLE = css` | ||
${TYPOGRAPHY.pSemiBold} | ||
color: ${COLORS.white}; | ||
cursor: default; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
font-size: ${TYPOGRAPHY.fontSize22}; | ||
font-weight: ${TYPOGRAPHY.fontWeightBold}; | ||
line-height: ${TYPOGRAPHY.lineHeight28}; | ||
} | ||
` |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as React from 'react' | ||
|
||
export function SelectRecoveryOption(): JSX.Element { | ||
return <div>RECOVERY OPTION</div> | ||
} |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { css } from 'styled-components' | ||
|
||
import { COLORS, SPACING, TYPOGRAPHY } from '@opentrons/components' | ||
|
||
import type { RouteStep } from './types' | ||
|
||
/** | ||
* Error Kinds | ||
*/ | ||
|
||
export const ERROR_KINDS = { | ||
GENERAL_ERROR: 'GENERAL_ERROR', | ||
} as const | ||
|
||
/** | ||
* Recovery Routes and Steps | ||
*/ | ||
|
||
// A recovery route represents a flow accessible within Error Recovery. | ||
export const RECOVERY_ROUTES = { | ||
OPTION_SELECTION: 'OPTION_SELECTION', | ||
BEFORE_BEGINNING: 'BEFORE_BEGINNING', | ||
DROP_TIP: 'DROP_TIP', | ||
ROBOT_IN_MOTION: 'ROBOT_IN_MOTION', | ||
} as const | ||
|
||
// Valid steps for a particular route. | ||
export const STEPS = { | ||
OPTION_SELECTION: { | ||
SELECT: 'SELECT', | ||
}, | ||
BEFORE_BEGINNING: { | ||
RECOVERY_DESCRIPTION: 'RECOVERY_DESCRIPTION', | ||
}, | ||
ROBOT_IN_MOTION: { | ||
IN_MOTION: 'IN_MOTION', | ||
}, | ||
INVALID: 'INVALID', | ||
} as const | ||
|
||
const { BEFORE_BEGINNING, OPTION_SELECTION, ROBOT_IN_MOTION } = STEPS | ||
|
||
export const OPTION_SELECTION_STEPS: RouteStep[] = [OPTION_SELECTION.SELECT] | ||
export const BEFORE_BEGINNING_STEPS: RouteStep[] = [ | ||
BEFORE_BEGINNING.RECOVERY_DESCRIPTION, | ||
] | ||
export const ROBOT_IN_MOTION_STEPS: RouteStep[] = [ROBOT_IN_MOTION.IN_MOTION] | ||
|
||
// Possible recovery options. | ||
export const RECOVERY_OPTIONS = { | ||
REFILL_AND_RESUME: 'REFILL_AND_RESUME', | ||
IGNORE_AND_RESUME: 'IGNORE_AND_RESUME', | ||
CANCEL_RUN: 'CANCEL_RUN', | ||
} as const | ||
|
||
/** | ||
* Recovery Options | ||
* Valid recovery options given an errorKind. | ||
*/ | ||
|
||
const { REFILL_AND_RESUME, IGNORE_AND_RESUME, CANCEL_RUN } = RECOVERY_OPTIONS | ||
|
||
export const GENERAL_ERROR_OPTIONS = [ | ||
REFILL_AND_RESUME, | ||
IGNORE_AND_RESUME, | ||
CANCEL_RUN, | ||
] | ||
|
||
/** | ||
* Styling | ||
*/ | ||
|
||
// These colors are temp and will be removed as design does design things. | ||
export const NON_DESIGN_SANCTIONED_COLOR_1 = '#56FF00' | ||
export const NON_DESIGN_SANCTIONED_COLOR_2 = '#FF00EF' | ||
export const NON_DESIGNED_SANCTION_COLOR_BLACK = COLORS.black90 | ||
|
||
export const RECOVERY_COLOR_STYLE = css` | ||
background-color: ${NON_DESIGNED_SANCTION_COLOR_BLACK}; | ||
&:active { | ||
background-color: ${NON_DESIGN_SANCTIONED_COLOR_2}; | ||
} | ||
&:hover { | ||
background-color: ${NON_DESIGN_SANCTIONED_COLOR_1}; | ||
} | ||
&:focus { | ||
background-color: ${NON_DESIGN_SANCTIONED_COLOR_2}; | ||
} | ||
` | ||
|
||
export const BODY_TEXT_STYLE = css` | ||
${TYPOGRAPHY.bodyTextRegular}; | ||
` | ||
|
||
export const ODD_SECTION_TITLE_STYLE = css` | ||
${TYPOGRAPHY.level4HeaderSemiBold} | ||
margin-bottom: ${SPACING.spacing16}; | ||
` |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
import { ERROR_KINDS } from './constants' | ||
Oops, something went wrong.