Skip to content

Commit 0935720

Browse files
authored
style(app): reformat TC run profile command text on ODD (#14092)
Closes RQA-1937
1 parent 5a7f7dc commit 0935720

File tree

4 files changed

+67
-8
lines changed

4 files changed

+67
-8
lines changed

app/src/organisms/CommandText/__tests__/CommandText.test.tsx

+35-1
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ describe('CommandText', () => {
742742
)[0]
743743
getByText('Setting Target Temperature of Heater-Shaker to 20°C')
744744
})
745-
it('renders correct text for thermocycler/runProfile', () => {
745+
it('renders correct text for thermocycler/runProfile on Desktop', () => {
746746
const mockProfileSteps = [
747747
{ holdSeconds: 10, celsius: 20 },
748748
{ holdSeconds: 30, celsius: 40 },
@@ -773,6 +773,40 @@ describe('CommandText', () => {
773773
getByText('temperature: 20°C, seconds: 10')
774774
getByText('temperature: 40°C, seconds: 30')
775775
})
776+
it('renders correct text for thermocycler/runProfile on ODD', () => {
777+
const mockProfileSteps = [
778+
{ holdSeconds: 10, celsius: 20 },
779+
{ holdSeconds: 30, celsius: 40 },
780+
]
781+
const { getByText, queryByText } = renderWithProviders(
782+
<CommandText
783+
command={{
784+
commandType: 'thermocycler/runProfile',
785+
params: { profile: mockProfileSteps, moduleId: 'abc123' },
786+
id: 'def456',
787+
result: {},
788+
status: 'queued',
789+
error: null,
790+
createdAt: 'fake_timestamp',
791+
startedAt: null,
792+
completedAt: null,
793+
}}
794+
robotSideAnalysis={mockRobotSideAnalysis}
795+
robotType={FLEX_ROBOT_TYPE}
796+
isOnDevice={true}
797+
/>,
798+
{
799+
i18nInstance: i18n,
800+
}
801+
)[0]
802+
getByText(
803+
'Thermocycler starting 2 repetitions of cycle composed of the following steps:'
804+
)
805+
getByText('temperature: 20°C, seconds: 10')
806+
expect(
807+
queryByText('temperature: 40°C, seconds: 30')
808+
).not.toBeInTheDocument()
809+
})
776810
it('renders correct text for heaterShaker/setAndWaitForShakeSpeed', () => {
777811
const { getByText } = renderWithProviders(
778812
<CommandText

app/src/organisms/CommandText/index.tsx

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import * as React from 'react'
22
import { useTranslation } from 'react-i18next'
33

4-
import { Flex, DIRECTION_COLUMN, SPACING } from '@opentrons/components'
4+
import {
5+
Flex,
6+
DIRECTION_COLUMN,
7+
SPACING,
8+
ALIGN_CENTER,
9+
} from '@opentrons/components'
510
import { getPipetteNameSpecs, RunTimeCommand } from '@opentrons/shared-data'
611
import {
712
getAddressableAreaDisplayName,
@@ -48,9 +53,16 @@ interface Props extends StyleProps {
4853
command: RunTimeCommand
4954
robotSideAnalysis: CompletedProtocolAnalysis
5055
robotType: RobotType
56+
isOnDevice?: boolean
5157
}
5258
export function CommandText(props: Props): JSX.Element | null {
53-
const { command, robotSideAnalysis, robotType, ...styleProps } = props
59+
const {
60+
command,
61+
robotSideAnalysis,
62+
robotType,
63+
isOnDevice = false,
64+
...styleProps
65+
} = props
5466
const { t } = useTranslation('protocol_command_text')
5567

5668
switch (command.commandType) {
@@ -96,20 +108,31 @@ export function CommandText(props: Props): JSX.Element | null {
96108
const { profile } = command.params
97109
const steps = profile.map(
98110
({ holdSeconds, celsius }: { holdSeconds: number; celsius: number }) =>
99-
t('tc_run_profile_steps', { celsius: celsius, seconds: holdSeconds })
111+
t('tc_run_profile_steps', {
112+
celsius: celsius,
113+
seconds: holdSeconds,
114+
}).trim()
100115
)
101116
return (
102-
<Flex flexDirection={DIRECTION_COLUMN} {...styleProps}>
117+
<Flex
118+
flexDirection={DIRECTION_COLUMN}
119+
{...styleProps}
120+
alignItems={isOnDevice ? ALIGN_CENTER : undefined}
121+
>
103122
<StyledText as="p" marginBottom={SPACING.spacing4} {...styleProps}>
104123
{t('tc_starting_profile', {
105124
repetitions: Object.keys(steps).length,
106125
})}
107126
</StyledText>
108127
<StyledText as="p" marginLeft={SPACING.spacing16}>
109128
<ul>
110-
{steps.map((step: string, index: number) => (
111-
<li key={index}> {step}</li>
112-
))}
129+
{isOnDevice ? (
130+
<li>{steps[0]}</li>
131+
) : (
132+
steps.map((step: string, index: number) => (
133+
<li key={index}> {step}</li>
134+
))
135+
)}
113136
</ul>
114137
</StyledText>
115138
</Flex>

app/src/organisms/OnDeviceDisplay/RunningProtocol/CurrentRunningProtocolCommand.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export function CurrentRunningProtocolCommand({
235235
command={currentCommand}
236236
robotSideAnalysis={robotSideAnalysis}
237237
robotType={robotType}
238+
isOnDevice={true}
238239
/>
239240
) : null}
240241
</Flex>

app/src/organisms/OnDeviceDisplay/RunningProtocol/RunningProtocolCommandList.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export function RunningProtocolCommandList({
241241
robotSideAnalysis={robotSideAnalysis}
242242
robotType={robotType}
243243
css={COMMAND_ROW_STYLE}
244+
isOnDevice={true}
244245
/>
245246
</Flex>
246247
</Flex>

0 commit comments

Comments
 (0)