Skip to content

Commit

Permalink
refactor SetupLabwareMap and getLocationInfoNames util to check addre…
Browse files Browse the repository at this point in the history
…ssable areas
  • Loading branch information
ncdiehl11 committed Aug 9, 2024
1 parent 1382fcc commit 67b14aa
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { OffDeckLabwareList } from './OffDeckLabwareList'

import type {
CompletedProtocolAnalysis,
LoadLabwareRunTimeCommand,
ProtocolAnalysisOutput,
} from '@opentrons/shared-data'
import { LabwareStackModal } from './LabwareStackModal'
Expand Down Expand Up @@ -143,23 +142,15 @@ export function SetupLabwareMap({
topLabwareId != null &&
labwareInAdapter != null

const loadLabwareCommand = commands.find(
command =>
command.commandType === 'loadLabware' &&
command.result?.labwareId === labwareId
) as LoadLabwareRunTimeCommand
const labwareLocation = loadLabwareCommand?.params.location
return {
labwareLocation,
labwareLocation: { slotName },
definition: topLabwareDefinition,
topLabwareId,
topLabwareDisplayName,
// TODO (nd: 08/08/2024) fix passing of onLabwareClick to actually perform click handling.
// Here, I set to an empty function to produce pointer cursor style.
onLabwareClick: isLabwareInStack ? () => {} : undefined,
highlight: isLabwareInStack && hoverLabwareId === topLabwareId,
labwareChildren: (
<g
cursor={isLabwareInStack ? 'pointer' : ''}
onClick={() => {
if (isLabwareInStack) {
setLabwareStackDetailsLabwareId(topLabwareId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { ModuleModel } from '@opentrons/shared-data'
const ADAPTER_DISPLAY_NAME = 'Opentrons 96 Flat Bottom Adapter'
const LABWARE_DISPLAY_NAME = 'Corning 24 Well Plate 3.4 mL Flat'
const SLOT = '5'
const SLOT_EXTENSION = 'C4'
const MOCK_MODEL = 'heaterShakerModuleV1' as ModuleModel
const ADAPTER_ID =
'd9a85adf-d272-4edd-9aae-426ef5756fef:opentrons/opentrons_96_flat_bottom_adapter/1'
Expand Down Expand Up @@ -119,6 +120,34 @@ const MOCK_ADAPTER_COMMANDS = [
},
},
]
const MOCK_ADAPTER_EXTENSION_COMMANDS = [
{
commandType: 'loadLabware',
params: {
location: {
addressableAreaName: SLOT_EXTENSION,
},
},
result: {
labwareId: ADAPTER_ID,
definition: {
metadata: { displayName: ADAPTER_DISPLAY_NAME },
},
},
},
{
commandType: 'loadLabware',
params: {
location: {
labwareId: ADAPTER_ID,
},
},
result: {
labwareId: LABWARE_ID,
definition: {},
},
},
]

vi.mock('@opentrons/shared-data')

Expand Down Expand Up @@ -168,4 +197,15 @@ describe('getLocationInfoNames', () => {
getLocationInfoNames(LABWARE_ID, MOCK_ADAPTER_COMMANDS as any)
).toEqual(expected)
})
it('returns the adapter, slot number if the labware is on an adapter on the deck extension slot', () => {
const expected = {
slotName: SLOT_EXTENSION,
labwareName: LABWARE_DISPLAY_NAME,
adapterName: ADAPTER_DISPLAY_NAME,
adapterId: ADAPTER_ID,
}
expect(
getLocationInfoNames(LABWARE_ID, MOCK_ADAPTER_EXTENSION_COMMANDS as any)
).toEqual(expected)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ export function getLocationInfoNames(
loadedAdapterCommand?.result?.definition.metadata.displayName,
adapterId: loadedAdapterCommand?.result?.labwareId,
}
} else if (
loadedAdapterCommand?.params.location !== 'offDeck' &&
'addressableAreaName' in loadedAdapterCommand?.params.location
) {
return {
slotName: loadedAdapterCommand?.params.location.addressableAreaName,
labwareName,
labwareNickname,
adapterName:
loadedAdapterCommand?.result?.definition.metadata.displayName,
adapterId: loadedAdapterCommand?.result?.labwareId,
}
} else if (
loadedAdapterCommand?.params.location !== 'offDeck' &&
'moduleId' in loadedAdapterCommand?.params.location
Expand Down

0 comments on commit 67b14aa

Please sign in to comment.