Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Apr 29, 2024
1 parent 331eddc commit e7c2c54
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 10 deletions.
4 changes: 3 additions & 1 deletion app/src/App/OnDeviceDisplayApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { InstrumentDetail } from '../pages/InstrumentDetail'
import { Welcome } from '../pages/Welcome'
import { InitialLoadingScreen } from '../pages/InitialLoadingScreen'
import { DeckConfigurationEditor } from '../pages/DeckConfiguration'
import { ErrorRecoveryFlows } from '../pages/ErrorRecoveryFlows'

Check failure on line 45 in app/src/App/OnDeviceDisplayApp.tsx

View workflow job for this annotation

GitHub Actions / js checks

'ErrorRecoveryFlows' is defined but never used
import { PortalRoot as ModalPortalRoot } from './portal'
import { getOnDeviceDisplaySettings, updateConfigValue } from '../redux/config'
import { updateBrightness } from '../redux/shell'
Expand Down Expand Up @@ -85,12 +86,13 @@ export const ON_DEVICE_DISPLAY_PATHS = [
'/welcome',
] as const

// TOME: THIS IS FOR DEV PURPOSES ONLY - DO NOT COMMIT THIS!
function getPathComponent(
path: typeof ON_DEVICE_DISPLAY_PATHS[number]
): JSX.Element {
switch (path) {
case '/dashboard':
return <RobotDashboard />
return <RunningProtocol />
case '/deck-configuration':
return <DeckConfigurationEditor />
case '/emergency-stop':
Expand Down
7 changes: 6 additions & 1 deletion app/src/assets/localization/en/error_recovery.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"run_paused": "Run paused"
"before_you_begin": "Before you begin",
"general_error": "General error",
"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",
"view_recovery_options": "View recovery options"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import {
} from '@opentrons/components'

interface RunPausedSplashProps {
onClose: () => void
onClick: () => void
errorType?: string
protocolName?: string
}

export function RunPausedSplash({
onClose,
onClick,
errorType,
protocolName,
}: RunPausedSplashProps): JSX.Element {
Expand All @@ -48,7 +48,7 @@ export function RunPausedSplash({
gridGap={SPACING.spacing40}
padding={SPACING.spacing120}
backgroundColor={COLORS.grey50}
onClick={onClose}
onClick={onClick}
>
<SplashFrame>
<Flex gridGap={SPACING.spacing32} alignItems={ALIGN_CENTER}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('ConfirmCancelRunModal', () => {

beforeEach(() => {
props = {
onClose: mockOnClose,
onClick: mockOnClose,
protocolName: MOCK_PROTOCOL_NAME,
errorType: '',
}
Expand Down
59 changes: 59 additions & 0 deletions app/src/pages/ErrorRecoveryFlows/BeforeBeginning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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, MediumButton } from '../../atoms/buttons'

Check failure on line 13 in app/src/pages/ErrorRecoveryFlows/BeforeBeginning.tsx

View workflow job for this annotation

GitHub Actions / js checks

'MediumButton' is defined but never used
import {
RECOVERY_COLOR_STYLE,
BODY_TEXT_STYLE,
ODD_SECTION_TITLE_STYLE,
} from './constants'

interface BeforeBeginningProps {
isOnDevice: boolean
proceed: () => void
}
export function BeforeBeginning({
isOnDevice,
proceed,
}: BeforeBeginningProps): JSX.Element | null {
const { t } = useTranslation('error_recovery')

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
}
}
82 changes: 82 additions & 0 deletions app/src/pages/ErrorRecoveryFlows/ErrorRecoveryHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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'

// TOME: You'll need the util here for getting this string.
export function ErrorRecoveryHeader(): JSX.Element {
const { t } = useTranslation('error_recovery')

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}>
{t('general_error')}
</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: ${COLORS.black90};
@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};
}
`
5 changes: 5 additions & 0 deletions app/src/pages/ErrorRecoveryFlows/SelectRecoveryOption.tsx
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.
71 changes: 71 additions & 0 deletions app/src/pages/ErrorRecoveryFlows/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { css } from 'styled-components'

import { COLORS, SPACING, TYPOGRAPHY } from '@opentrons/components'

import type { RouteStep } from './types'

// 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

// Styling

// These colors are temp and will be removed as design does design things.
const NON_DESIGN_SANCTIONED_COLOR_1 = '#56FF00'
const NON_DESIGN_SANCTIONED_COLOR_2 = '#FF00EF'

export const RECOVERY_COLOR_STYLE = css`
background-color: ${COLORS.black90};
&: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};
`
Loading

0 comments on commit e7c2c54

Please sign in to comment.