-
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.
feat(app): add pause-type intervention modal (#12379)
* feat(app): add pause-type intervention modal adds a pause-type intervention modal for protocol runs. The modal displays the command message as well as a timer that counts up from the time the pause command started closes RLAB-318 closes RLAB-319
- Loading branch information
Showing
6 changed files
with
178 additions
and
5 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
73 changes: 73 additions & 0 deletions
73
app/src/organisms/InterventionModal/PauseInterventionContent.tsx
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,73 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { | ||
ALIGN_CENTER, | ||
COLORS, | ||
DIRECTION_COLUMN, | ||
Flex, | ||
Icon, | ||
SPACING, | ||
useInterval, | ||
} from '@opentrons/components' | ||
|
||
import { EMPTY_TIMESTAMP } from '../Devices/constants' | ||
import { formatInterval } from '../RunTimeControl/utils' | ||
import { StyledText } from '../../atoms/text' | ||
|
||
import type { WaitForResumeRunTimeCommand } from '@opentrons/shared-data' | ||
|
||
export interface PauseContentProps { | ||
command: WaitForResumeRunTimeCommand | ||
} | ||
|
||
export function PauseInterventionContent({ | ||
command, | ||
}: PauseContentProps): JSX.Element { | ||
const { t, i18n } = useTranslation('protocol_command_text') | ||
|
||
return ( | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap="0.75rem"> | ||
<PauseHeader startedAt={command.startedAt} /> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}> | ||
<StyledText as="h6" color={COLORS.errorDisabled}> | ||
{i18n.format(t('notes'), 'upperCase')}: | ||
</StyledText> | ||
<StyledText as="p"> | ||
{command.params?.message != null && command.params.message !== '' | ||
? command.params.message.length > 220 | ||
? `${command.params.message.substring(0, 217)}...` | ||
: command.params.message | ||
: t('wait_for_resume')} | ||
</StyledText> | ||
</Flex> | ||
</Flex> | ||
) | ||
} | ||
|
||
interface PauseHeaderProps { | ||
startedAt: string | null | ||
} | ||
|
||
function PauseHeader({ startedAt }: PauseHeaderProps): JSX.Element { | ||
const { t, i18n } = useTranslation('run_details') | ||
const [now, setNow] = React.useState(Date()) | ||
useInterval(() => setNow(Date()), 500, true) | ||
|
||
const runTime = | ||
startedAt != null ? formatInterval(startedAt, now) : EMPTY_TIMESTAMP | ||
|
||
return ( | ||
<Flex alignItems={ALIGN_CENTER} gridGap="0.75rem"> | ||
<Icon | ||
name="pause-circle" | ||
size={SPACING.spacing32} | ||
flex="0 0 auto" | ||
color={COLORS.darkGreyEnabled} | ||
/> | ||
<StyledText as="h1"> | ||
{i18n.format(t('paused_for'), 'capitalize')} {runTime} | ||
</StyledText> | ||
</Flex> | ||
) | ||
} |
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,40 @@ | ||
export const fullCommandMessage = | ||
'This is a user generated message that gives details about the pause command. This text is truncated to 220 characters. semper risus in hendrerit gravida rutrum quisque non tellus orci ac auctor augue mauris augue neque gravida in fermentum et sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque' | ||
|
||
export const truncatedCommandMessage = | ||
'This is a user generated message that gives details about the pause command. This text is truncated to 220 characters. semper risus in hendrerit gravida rutrum quisque non tellus orci ac auctor augue mauris augue nequ...' | ||
|
||
export const shortCommandText = | ||
"this won't get truncated because it isn't more than 220 characters." | ||
|
||
export const mockPauseCommandWithStartTime = { | ||
commandType: 'waitForResume', | ||
startedAt: new Date(), | ||
params: { | ||
message: fullCommandMessage, | ||
}, | ||
} as any | ||
|
||
export const mockPauseCommandWithoutStartTime = { | ||
commandType: 'waitForResume', | ||
startedAt: null, | ||
params: { | ||
message: fullCommandMessage, | ||
}, | ||
} as any | ||
|
||
export const mockPauseCommandWithShortMessage = { | ||
commandType: 'waitForResume', | ||
startedAt: null, | ||
params: { | ||
message: shortCommandText, | ||
}, | ||
} as any | ||
|
||
export const mockPauseCommandWithNoMessage = { | ||
commandType: 'waitForResume', | ||
startedAt: null, | ||
params: { | ||
message: null, | ||
}, | ||
} as any |
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