Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): fix adapter/module location on move labware modal #15976

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} />
}
Loading