Skip to content

Commit 04e00ad

Browse files
authored
refactor(protocol-designer): minimize and extend position and tuberac… (#14998)
…k warnings closes AUTH-370 AUTH-371
1 parent c7bd4bb commit 04e00ad

File tree

6 files changed

+43
-53
lines changed

6 files changed

+43
-53
lines changed

protocol-designer/src/components/StepEditForm/fields/TipPositionField/TipPositionModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export const TipPositionModal = (
234234
yValue != null &&
235235
(parseInt(yValue) > PERCENT_RANGE_TO_SHOW_WARNING * yMaxWidth ||
236236
parseInt(yValue) < PERCENT_RANGE_TO_SHOW_WARNING * yMinWidth)
237+
const isZValueAtBottom = zValue != null && zValue === '0'
237238

238239
const TipPositionInputField = !isDefault ? (
239240
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing8}>
@@ -315,7 +316,8 @@ export const TipPositionModal = (
315316
<p>{t(`tip_position.body.${zSpec?.name}`)}</p>
316317
</div>
317318

318-
{(isXValueNearEdge || isYValueNearEdge) && !isDefault ? (
319+
{(isXValueNearEdge || isYValueNearEdge || isZValueAtBottom) &&
320+
!isDefault ? (
319321
<Flex marginTop={SPACING.spacing8}>
320322
<PDAlert
321323
alertType="warning"

protocol-designer/src/components/StepEditForm/fields/TipPositionField/__tests__/TipPositionModal.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ describe('TipPositionModal', () => {
6666
render(props)
6767
screen.getByText('warning')
6868
screen.getByText(
69-
'The X and/or Y position value is close to edge of the well and might collide with it'
69+
'One or more position offset values are close to the edge of the well and might collide with it'
7070
)
7171
})
7272
it('renders the alert if the x/y position values are too close to the max/min for y value', () => {
7373
props.specs.y.value = -9.7
7474
render(props)
7575
screen.getByText('warning')
7676
screen.getByText(
77-
'The X and/or Y position value is close to edge of the well and might collide with it'
77+
'One or more position offset values are close to the edge of the well and might collide with it'
7878
)
7979
})
8080
it('renders the custom options, captions, and visual', () => {

protocol-designer/src/localization/en/modal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"tip_position": {
7171
"title": "Tip Positioning",
7272
"caption": "between {{min}} and {{max}}",
73-
"warning": "The X and/or Y position value is close to edge of the well and might collide with it",
73+
"warning": "One or more position offset values are close to the edge of the well and might collide with it",
7474
"radio_button": {
7575
"default": "{{defaultMmFromBottom}} mm from the bottom center (default)",
7676
"blowout": "0 mm from the top center (default)",

protocol-designer/src/steplist/formLevel/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ import {
2929
minDisposalVolume,
3030
minAspirateAirGapVolume,
3131
minDispenseAirGapVolume,
32-
aspirateTipPositionInTube,
33-
dispenseTipPositionInTube,
3432
mixTipPositionInTube,
33+
tipPositionInTube,
3534
} from './warnings'
3635

3736
import { HydratedFormdata, StepType } from '../../form-types'
@@ -75,8 +74,7 @@ const stepFormHelperMap: Partial<Record<StepType, FormHelpers>> = {
7574
minDisposalVolume,
7675
minAspirateAirGapVolume,
7776
minDispenseAirGapVolume,
78-
aspirateTipPositionInTube,
79-
dispenseTipPositionInTube
77+
tipPositionInTube
8078
),
8179
},
8280
magnet: {

protocol-designer/src/steplist/formLevel/test/warnings.test.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {
55
belowPipetteMinimumVolume,
66
minDisposalVolume,
77
maxDispenseWellVolume,
8-
aspirateTipPositionInTube,
9-
dispenseTipPositionInTube,
8+
tipPositionInTube,
109
mixTipPositionInTube,
1110
} from '../warnings'
1211
import type { LabwareEntity } from '@opentrons/step-generation'
@@ -294,26 +293,20 @@ describe('Max dispense well volume', () => {
294293
dispense_mmFromBottom: null,
295294
}
296295
})
297-
it('renders the errors for all 3', () => {
298-
expect(aspirateTipPositionInTube(fields)?.type).toBe(
299-
'ASPIRATE_TIP_POSITIONED_LOW_IN_TUBE'
300-
)
301-
expect(dispenseTipPositionInTube(fields)?.type).toBe(
302-
'DISPENSE_TIP_POSITIONED_LOW_IN_TUBE'
303-
)
296+
it('renders the errors for all 2', () => {
297+
expect(tipPositionInTube(fields)?.type).toBe('TIP_POSITIONED_LOW_IN_TUBE')
304298
expect(mixTipPositionInTube(fields)?.type).toBe(
305299
'MIX_TIP_POSITIONED_LOW_IN_TUBE'
306300
)
307301
})
308-
it('renders null for all 3 when the number has been adjusted', () => {
302+
it('renders null for both when the number has been adjusted', () => {
309303
fields.aspirate_mmFromBottom = 3
310304
fields.dispense_mmFromBottom = 3
311305
fields.mix_mmFromBottom = 3
312-
expect(aspirateTipPositionInTube(fields)).toBe(null)
313-
expect(dispenseTipPositionInTube(fields)).toBe(null)
306+
expect(tipPositionInTube(fields)).toBe(null)
314307
expect(mixTipPositionInTube(fields)).toBe(null)
315308
})
316-
it('renders null for all 3 when the labware is not a tube rack', () => {
309+
it('renders null for both when the labware is not a tube rack', () => {
317310
fields.aspirate_labware = {
318311
def: fixture96Plate as LabwareDefinition2,
319312
id: 'mockId',
@@ -329,8 +322,7 @@ describe('Max dispense well volume', () => {
329322
id: 'mockId',
330323
labwareDefURI: 'mockURI',
331324
}
332-
expect(aspirateTipPositionInTube(fields)).toBe(null)
333-
expect(dispenseTipPositionInTube(fields)).toBe(null)
325+
expect(tipPositionInTube(fields)).toBe(null)
334326
expect(mixTipPositionInTube(fields)).toBe(null)
335327
})
336328
})

protocol-designer/src/steplist/formLevel/warnings.tsx

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import * as React from 'react'
22
import { getWellTotalVolume } from '@opentrons/shared-data'
33
import { KnowledgeBaseLink } from '../../components/KnowledgeBaseLink'
44
import type { FormError } from './errors'
5+
56
/*******************
67
** Warning Messages **
78
********************/
89

910
export type FormWarningType =
10-
| 'ASPIRATE_TIP_POSITIONED_LOW_IN_TUBE'
1111
| 'BELOW_MIN_AIR_GAP_VOLUME'
1212
| 'BELOW_MIN_DISPOSAL_VOLUME'
1313
| 'BELOW_PIPETTE_MINIMUM_VOLUME'
14-
| 'DISPENSE_TIP_POSITIONED_LOW_IN_TUBE'
1514
| 'OVER_MAX_WELL_VOLUME'
1615
| 'MIX_TIP_POSITIONED_LOW_IN_TUBE'
16+
| 'TIP_POSITIONED_LOW_IN_TUBE'
1717

1818
export type FormWarning = FormError & {
1919
type: FormWarningType
@@ -59,18 +59,11 @@ const belowMinDisposalVolumeWarning = (min: number): FormWarning => ({
5959
dependentFields: ['disposalVolume_volume', 'pipette'],
6060
})
6161

62-
const aspirateTipPositionedLowInTube = (): FormWarning => ({
63-
type: 'ASPIRATE_TIP_POSITIONED_LOW_IN_TUBE',
62+
const tipPositionedLowInTube = (): FormWarning => ({
63+
type: 'TIP_POSITIONED_LOW_IN_TUBE',
6464
title:
65-
'The default aspirate height is 1mm from the bottom of the well, which could cause liquid overflow or pipette damage. Edit tip position in advanced settings.',
66-
dependentFields: ['aspirate_labware'],
67-
})
68-
69-
const dispenseTipPositionedLowInTube = (): FormWarning => ({
70-
type: 'DISPENSE_TIP_POSITIONED_LOW_IN_TUBE',
71-
title:
72-
'The default dispense height is 0.5mm from the bottom of the well, which could cause liquid overflow or pipette damage. Edit tip position in advanced settings.',
73-
dependentFields: ['dispense_labware'],
65+
'A tuberack has an aspirate and dispense default height at 1mm and 0.5mm from the bottom of the well, which could cause liquid overflow or pipette damage. Edit tip position in advanced settings.',
66+
dependentFields: ['aspirate_labware', 'dispense_labware'],
7467
})
7568

7669
const mixTipPositionedLowInTube = (): FormWarning => ({
@@ -88,34 +81,39 @@ export type WarningChecker = (val: unknown) => FormWarning | null
8881
// TODO: real HydratedFormData type
8982
export type HydratedFormData = any
9083

91-
export const aspirateTipPositionInTube = (
84+
export const tipPositionInTube = (
9285
fields: HydratedFormData
9386
): FormWarning | null => {
94-
const { aspirate_labware, aspirate_mmFromBottom } = fields
95-
let isTubeRack: boolean = false
87+
const {
88+
aspirate_labware,
89+
aspirate_mmFromBottom,
90+
dispense_labware,
91+
dispense_mmFromBottom,
92+
} = fields
93+
let isAspirateTubeRack: boolean = false
94+
let isDispenseTubeRack: boolean = false
9695
if (aspirate_labware != null) {
97-
isTubeRack = aspirate_labware.def.metadata.displayCategory === 'tubeRack'
96+
isAspirateTubeRack =
97+
aspirate_labware.def.metadata.displayCategory === 'tubeRack'
9898
}
99-
return isTubeRack && aspirate_mmFromBottom === null
100-
? aspirateTipPositionedLowInTube()
101-
: null
102-
}
103-
export const dispenseTipPositionInTube = (
104-
fields: HydratedFormData
105-
): FormWarning | null => {
106-
const { dispense_labware, dispense_mmFromBottom } = fields
107-
let isTubeRack: boolean = false
10899
if (dispense_labware != null) {
109-
isTubeRack =
100+
isDispenseTubeRack =
110101
// checking that the dispense labware is a labware and not a trash/waste chute
111102
'def' in dispense_labware
112103
? dispense_labware.def.metadata.displayCategory === 'tubeRack'
113104
: false
114105
}
115-
return isTubeRack && dispense_mmFromBottom === null
116-
? dispenseTipPositionedLowInTube()
117-
: null
106+
107+
if (
108+
(isAspirateTubeRack && aspirate_mmFromBottom === null) ||
109+
(isDispenseTubeRack && dispense_mmFromBottom === null)
110+
) {
111+
return tipPositionedLowInTube()
112+
} else {
113+
return null
114+
}
118115
}
116+
119117
export const mixTipPositionInTube = (
120118
fields: HydratedFormData
121119
): FormWarning | null => {

0 commit comments

Comments
 (0)