Skip to content

Commit

Permalink
fix(app): fix adapter/module location on move labware modal (#15976)
Browse files Browse the repository at this point in the history
Set `LabwareDisplayLocation` in `MoveLabwareInterventionContent` to slot
name or addressable area name even if move target is an adapter or if
the initial/final location is not directly on a slot, but rather on top
of a labware/adapter or module.

Closes RQA-2783
  • Loading branch information
ncdiehl11 authored Aug 13, 2024
1 parent 113b3aa commit 524740a
Showing 1 changed file with 34 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ import {
} from '@opentrons/components'
import {
OT2_ROBOT_TYPE,
TC_MODULE_LOCATION_OT2,
TC_MODULE_LOCATION_OT3,
THERMOCYCLER_MODULE_TYPE,
getDeckDefFromRobotType,
getLabwareDisplayName,
getLoadedLabwareDefinitionsByUri,
getModuleDisplayName,
getModuleType,
getOccludedSlotCountForModule,
} from '@opentrons/shared-data'

import {
getRunLabwareRenderInfo,
getRunModuleRenderInfo,
getLabwareNameFromRunData,
getModuleModelFromRunData,
getModuleDisplayLocationFromRunData,
} from './utils'
import { Divider } from '../../atoms/structure'
import {
Expand Down Expand Up @@ -252,15 +251,15 @@ function LabwareDisplayLocation(
props: LabwareDisplayLocationProps
): JSX.Element {
const { t } = useTranslation('protocol_command_text')
const { protocolData, location, robotType, labwareDefsByUri } = props
let displayLocation: React.ReactNode = ''
const { protocolData, location, robotType } = props
let displayLocation: string = ''
if (location === 'offDeck') {
// TODO(BC, 08/28/23): remove this string cast after update i18next to >23 (see https://www.i18next.com/overview/typescript#argument-of-type-defaulttfuncreturn-is-not-assignable-to-parameter-of-type-xyz)
displayLocation = <DeckInfoLabel deckLabel={String(t('offdeck'))} />
displayLocation = String(t('offdeck'))
} else if ('slotName' in location) {
displayLocation = <DeckInfoLabel deckLabel={location.slotName} />
displayLocation = location.slotName
} else if ('addressableAreaName' in location) {
displayLocation = <DeckInfoLabel deckLabel={location.addressableAreaName} />
displayLocation = location.addressableAreaName
} else if ('moduleId' in location) {
const moduleModel = getModuleModelFromRunData(
protocolData,
Expand All @@ -269,41 +268,32 @@ function LabwareDisplayLocation(
if (moduleModel == null) {
console.warn('labware is located on an unknown module model')
} else {
displayLocation = t('module_in_slot', {
count: getOccludedSlotCountForModule(
getModuleType(moduleModel),
robotType
),
module: getModuleDisplayName(moduleModel),
slot_name: getModuleDisplayLocationFromRunData(
protocolData,
location.moduleId
),
})
const slotName =
getLoadedModule(protocolData, location.moduleId)?.location?.slotName ??
''
const isModuleUnderAdapterThermocycler =
getModuleType(moduleModel) === THERMOCYCLER_MODULE_TYPE
if (isModuleUnderAdapterThermocycler) {
displayLocation =
robotType === OT2_ROBOT_TYPE
? TC_MODULE_LOCATION_OT2
: TC_MODULE_LOCATION_OT3
} else {
displayLocation = slotName
}
}
} else if ('labwareId' in location) {
const adapter = protocolData.labware.find(
lw => lw.id === location.labwareId
)
const adapterDef =
adapter != null ? labwareDefsByUri[adapter.definitionUri] : null
const adapterDisplayName =
adapterDef != null ? getLabwareDisplayName(adapterDef) : ''

if (adapter == null) {
console.warn('labware is located on an unknown adapter')
} else if (adapter.location === 'offDeck') {
displayLocation = t('off_deck')
} else if ('slotName' in adapter.location) {
displayLocation = t('adapter_in_slot', {
adapter: adapterDisplayName,
slot_name: adapter.location.slotName,
})
displayLocation = adapter.location.slotName
} else if ('addressableAreaName' in adapter.location) {
return t('adapter_in_slot', {
adapter: adapterDisplayName,
slot: adapter.location.addressableAreaName,
})
displayLocation = adapter.location.addressableAreaName
} else if ('moduleId' in adapter.location) {
const moduleIdUnderAdapter = adapter.location.moduleId
const moduleModel = protocolData.modules.find(
Expand All @@ -315,19 +305,20 @@ function LabwareDisplayLocation(
const slotName =
getLoadedModule(protocolData, adapter.location.moduleId)?.location
?.slotName ?? ''
displayLocation = t('adapter_in_module_in_slot', {
count: getOccludedSlotCountForModule(
getModuleType(moduleModel),
robotType ?? OT2_ROBOT_TYPE
),
module: getModuleDisplayName(moduleModel),
adapter: adapterDisplayName,
slot_name: slotName,
})
const isModuleUnderAdapterThermocycler =
getModuleType(moduleModel) === THERMOCYCLER_MODULE_TYPE
if (isModuleUnderAdapterThermocycler) {
displayLocation =
robotType === OT2_ROBOT_TYPE
? TC_MODULE_LOCATION_OT2
: TC_MODULE_LOCATION_OT3
} else {
displayLocation = slotName
}
}
} else {
console.warn('display location could not be established: ', location)
}
}
return <>{displayLocation}</>
return <DeckInfoLabel deckLabel={displayLocation} />
}

0 comments on commit 524740a

Please sign in to comment.