Skip to content

Commit

Permalink
address more feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Mar 25, 2024
1 parent c234f7d commit b00d24b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import type { ThunkDispatch } from 'redux-thunk'
import type { BaseState } from '../../../types'
import type { FormState as TypeFormState } from './index'

export interface Props {
export interface PipetteFieldsProps {
values: FormPipettesByMount
setValue: UseFormSetValue<TypeFormState>
trigger: UseFormTrigger<TypeFormState>
Expand All @@ -59,7 +59,7 @@ interface TiprackSelectProps {
robotType: RobotType
}

export function PipetteFields(props: Props): JSX.Element {
export function PipetteFields(props: PipetteFieldsProps): JSX.Element {
const { values, setValue, trigger, robotType } = props
const { t } = useTranslation(['modal', 'button'])
const allowAllTipracks = useSelector(getAllowAllTipracks)
Expand All @@ -70,9 +70,9 @@ export function PipetteFields(props: Props): JSX.Element {

React.useEffect(() => {
if (has96Channel) {
values.right = { pipetteName: null, tiprackDefURI: [] }
values.right = { pipetteName: null, tiprackDefURI: null }
}
}, [values.left])
}, [has96Channel, values.left])

const renderPipetteSelect = (props: PipetteSelectProps): JSX.Element => {
const { tabIndex, mount } = props
Expand Down Expand Up @@ -117,7 +117,7 @@ export function PipetteFields(props: Props): JSX.Element {
mount={mount}
tiprackOptions={tiprackOptions}
values={values}
onSetFieldValue={(field: string, value: string[]) => {
onSetFieldValue={(field: string, value: string[]): void => {
// @ts-expect-error: TS can't figure out this type with react-hook-form
setValue(field, value)
trigger(`pipettesByMount.${mount}.tiprackDefURI`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react'
import { Mount, Flex, DIRECTION_COLUMN } from '@opentrons/components'
import { Flex, DIRECTION_COLUMN } from '@opentrons/components'
import { TiprackOption } from './TiprackOption'
import { FormPipettesByMount } from '../../../step-forms'

import type { Mount } from '@opentrons/components'
import type { FormPipettesByMount } from '../../../step-forms'
import type { TiprackOption as TiprackOptionType } from '../utils'

interface TiprackSelectProps {
Expand All @@ -26,7 +26,9 @@ export const TiprackSelect = (
}
}, [selectedValues, onSetFieldValue, tiprackOptions])

return selectedPipetteName != null ? (
if (selectedPipetteName == null) return null

return (
<Flex height="15rem" overflowY="scroll" flexDirection={DIRECTION_COLUMN}>
{tiprackOptions.map(option => (
<TiprackOption
Expand All @@ -45,5 +47,5 @@ export const TiprackSelect = (
/>
))}
</Flex>
) : null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export const FilePipettesModal = (props: Props): JSX.Element => {
) // this is mostly for flow
// @ts-expect-error(sa, 2021-6-21): TODO validate that pipette names coming from the modal are actually valid pipette names on PipetteName type
return formPipette &&
formPipette.pipetteName &&
formPipette.pipetteName != null &&
formPipette.tiprackDefURI != null &&
(mount === 'left' || mount === 'right')
? [
Expand Down
8 changes: 4 additions & 4 deletions protocol-designer/src/load-file/migration/8_1_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ export const migrateFile = (
const pipettingSavedStepsWithTipRack = pipettingSavedSteps.reduce(
(acc, item) => {
const tipRackUri = tiprackAssignments[item.pipette]
const tiprackLoadname =
const tiprackLoadName =
labwareDefinitions[tipRackUri]?.parameters.loadName
if (tiprackLoadname == null) {
if (tiprackLoadName == null) {
console.error(
`expected to find tiprack definition with labwareDefintionURI ${tipRackUri} but could not`
)
}
const tiprackIds = loadLabwareCommands
.filter(command => command.params.loadName === tiprackLoadname)
.map(command => command.params.labwareId as string)
.filter(command => command.params.loadName === tiprackLoadName)
.map(command => command.params.labwareId)

acc[item.id] = { ...item, tipRack: tiprackIds[0] }
return acc
Expand Down
10 changes: 5 additions & 5 deletions protocol-designer/src/pipettes/pipetteData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { DropdownOption } from '../../../components/lib/forms/DropdownField.d'
import {
getPipetteNameSpecs,
getTiprackVolume,
PipetteName,
getLabwareDefURI,
} from '@opentrons/shared-data'
import { Options } from '@opentrons/components'
import { LabwareEntities, PipetteEntity } from '@opentrons/step-generation'
import type { PipetteName } from '@opentrons/shared-data'
import type { Options } from '@opentrons/components'
import type { LabwareEntities, PipetteEntity } from '@opentrons/step-generation'
const supportedPipetteNames: PipetteName[] = [
'p10_single',
'p10_multi',
Expand All @@ -33,11 +33,11 @@ export const pipetteOptions: Options = supportedPipetteNames
)

// NOTE: this is similar to getPipetteWithTipMaxVol, the fns
export function getPipetteCapacity(
export const getPipetteCapacity = (
pipetteEntity: PipetteEntity,
labwareEntities: LabwareEntities,
tipRack?: string | null
): number {
): number => {
const spec = pipetteEntity.spec
const tiprackDefs = pipetteEntity.tiprackLabwareDef
const tipRackDefUri =
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/step-forms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
AdditionalEquipmentEntity,
} from '@opentrons/step-generation'
export interface FormPipette {
pipetteName: string | null | undefined
tiprackDefURI: string[] | null | undefined
pipetteName?: string | null
tiprackDefURI?: string[] | null
}
export interface FormPipettesByMount {
left: FormPipette
Expand Down

0 comments on commit b00d24b

Please sign in to comment.