Skip to content

Commit 63f8e60

Browse files
shiyaochenshiyaochen
shiyaochen
authored and
shiyaochen
committed
clean up code based on reviews
1 parent cd0a78d commit 63f8e60

File tree

7 files changed

+25
-20
lines changed

7 files changed

+25
-20
lines changed

protocol-designer/src/__fixtures__/formDataForSingleStep.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"pipette": "af1e518a-0e00-4270-a22a-ca5b43daff30",
5454
"preWetTip": false,
5555
"tipRack": "opentrons/opentrons_flex_96_filtertiprack_50ul/1",
56-
"volume": 20,
56+
"volume": "10",
5757
"stepType": "moveLiquid",
5858
"stepName": "transfer",
5959
"stepDetails": "",

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/LiquidClassesStepTools.tsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ import {
99
StyledText,
1010
} from '@opentrons/components'
1111
import {
12-
PIPETTE_NAMES_MAP,
13-
getDisableLiquidClasses,
12+
getDisabledLiquidClasses,
1413
getSortedLiquidClassDefs,
14+
PIPETTE_NAMES_MAP,
1515
} from '@opentrons/shared-data'
1616
import { getLiquidEntities } from '../../../../../../step-forms/selectors'
1717
import { getLiquidClassDisplayName } from '../../../../../../liquid-defs/utils'
1818
import { selectors as stepFormSelectors } from '../../../../../../step-forms'
1919
import type { ChangeEvent, Dispatch, SetStateAction } from 'react'
20-
import type { LiquidClassesOption } from '@opentrons/shared-data'
21-
import type { FormData } from '../../../../../../form-types'
2220
import type { FieldPropsByName } from '../../types'
21+
import type { FormData } from '../../../../../../form-types'
2322

2423
interface LiquidClassesStepToolsProps {
2524
propsForFields: FieldPropsByName
@@ -35,10 +34,10 @@ export const LiquidClassesStepTools = ({
3534
const liquids = useSelector(getLiquidEntities)
3635
const pipetteEntities = useSelector(stepFormSelectors.getPipetteEntities)
3736
const sortedLiquidClassDefs = getSortedLiquidClassDefs()
38-
const pipetteName = pipetteEntities[formData.pipette].name
37+
const pipetteName = pipetteEntities[formData.pipette]?.name
3938
const pipetteModel = PIPETTE_NAMES_MAP[pipetteName]
4039
const { volume, tipRack, pipette, path } = formData
41-
const disabledLiquidClasses = getDisableLiquidClasses(
40+
const disabledLiquidClasses = getDisabledLiquidClasses(
4241
{
4342
volume,
4443
tipRack,
@@ -138,10 +137,7 @@ export const LiquidClassesStepTools = ({
138137
align: 'vertical',
139138
}}
140139
largeDesktopBorderRadius
141-
disabled={
142-
disabledLiquidClasses !== null &&
143-
disabledLiquidClasses.has(name as LiquidClassesOption)
144-
}
140+
disabled={disabledLiquidClasses?.has(name)}
145141
/>
146142
)
147143
})}

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/__tests__/LiquidClassesStepTools.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('LiquidClassesStepMoveLiquidTools', () => {
5454
})
5555

5656
it('renders fields and buttons', () => {
57+
props.formData.volume = 11
5758
render(props)
5859
screen.getByText('Apply liquid class settings for this transfer')
5960
screen.getByText("Don't use a liquid class")

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {
2-
PIPETTE_NAMES_MAP,
2+
MIN_LIQUID_CLASSES_COMPATIBLE_VOLUME,
33
getIncompatibleLiquidClasses,
44
getWellTotalVolume,
5+
PIPETTE_NAMES_MAP,
56
} from '@opentrons/shared-data'
6-
import type { FormError } from './errors'
77
import type { LabwareDefinition2, PipetteName } from '@opentrons/shared-data'
8+
import type { FormError } from './errors'
89

910
/*******************
1011
** Warning Messages **
@@ -184,7 +185,9 @@ export const lowVolumeTransfer = (
184185
): FormWarning | null => {
185186
const { volume } = fields
186187

187-
return volume <= 10 ? lowVolumeTransferWarning() : null
188+
return volume <= MIN_LIQUID_CLASSES_COMPATIBLE_VOLUME
189+
? lowVolumeTransferWarning()
190+
: null
188191
}
189192

190193
export const incompatiblePipettePath = (

shared-data/js/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ export const WELL_CENTER: 'well-center' = 'well-center'
664664
export const WELL_BOTTOM: 'well-bottom' = 'well-bottom'
665665
export const LIQUID_MENISCUS: 'liquid-meniscus' = 'liquid-meniscus'
666666

667+
export const MIN_LIQUID_CLASSES_COMPATIBLE_VOLUME = 10
668+
667669
export const PIPETTE_NAMES_MAP: Record<PipetteName, string> = {
668670
p10_single: 'p10_single',
669671
p10_multi: 'p10_multi',

shared-data/js/helpers/__tests__/index.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, vi, it } from 'vitest'
22

33
import {
4-
getDisableLiquidClasses,
4+
getDisabledLiquidClasses,
55
getIncompatibleLiquidClasses,
66
getSortedLiquidClassDefs,
77
} from '..'
@@ -124,10 +124,10 @@ describe('getIncompatibleLiquidClasses', () => {
124124
})
125125
})
126126

127-
describe('getDisableLiquidClasses', () => {
127+
describe('getDisabledLiquidClasses', () => {
128128
it('should returns a list of liquid class names that should be diasbled given incompatible volume', () => {
129129
const valuesForLiquidClasses = { volume: 10, pipette: 'mockId' }
130-
const disabledLiquidClasses = getDisableLiquidClasses(
130+
const disabledLiquidClasses = getDisabledLiquidClasses(
131131
valuesForLiquidClasses,
132132
'mockPipetteModel1'
133133
)

shared-data/js/helpers/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import uniq from 'lodash/uniq'
22

3-
import { OPENTRONS_LABWARE_NAMESPACE } from '../constants'
3+
import {
4+
MIN_LIQUID_CLASSES_COMPATIBLE_VOLUME,
5+
OPENTRONS_LABWARE_NAMESPACE,
6+
} from '../constants'
47
import standardOt2DeckDef from '../../deck/definitions/5/ot2_standard.json'
58
import standardFlexDeckDef from '../../deck/definitions/5/ot3_standard.json'
69
import type {
@@ -456,15 +459,15 @@ export interface ValuesForLiquidClasses {
456459
tipRack?: string | null
457460
pipette?: string | null
458461
}
459-
export const getDisableLiquidClasses = (
462+
export const getDisabledLiquidClasses = (
460463
values: ValuesForLiquidClasses,
461464
pipetteModel: string
462465
): Set<LiquidClassesOption> | null => {
463466
const { volume, tipRack, pipette, path } = values
464467
if (pipette == null) return null
465468
const disabledLiquidClasses = new Set<LiquidClassesOption>()
466469

467-
if (volume != null && volume <= 10) {
470+
if (volume != null && volume <= MIN_LIQUID_CLASSES_COMPATIBLE_VOLUME) {
468471
disabledLiquidClasses.add('Aqueous')
469472
disabledLiquidClasses.add('Viscous')
470473
disabledLiquidClasses.add('Volatile')

0 commit comments

Comments
 (0)