From e07dacab175aba9a45cea51373234afd6e7db03e Mon Sep 17 00:00:00 2001 From: Jethary Date: Tue, 12 Dec 2023 14:06:08 -0500 Subject: [PATCH] fix(protocol-designer): tC renders for OT-2 and fix isSlotEmpty logic closes RQA-2062 --- .../src/components/DeckSetup/index.tsx | 17 ++++---- .../src/step-forms/utils/index.ts | 42 ++++++++++++++----- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/protocol-designer/src/components/DeckSetup/index.tsx b/protocol-designer/src/components/DeckSetup/index.tsx index aee9167088d..f834b436eb8 100644 --- a/protocol-designer/src/components/DeckSetup/index.tsx +++ b/protocol-designer/src/components/DeckSetup/index.tsx @@ -39,6 +39,7 @@ import { TRASH_BIN_ADAPTER_FIXTURE, WASTE_CHUTE_CUTOUT, } from '@opentrons/shared-data' +import { SPAN7_8_10_11_SLOT } from '../../constants' import { selectors as labwareDefSelectors } from '../../labware-defs' import { selectors as featureFlagSelectors } from '../../feature-flags' @@ -190,16 +191,12 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => { <> {/* all modules */} {allModules.map(moduleOnDeck => { - // modules can be on the deck, including pseudo-slots (eg special 'spanning' slot for thermocycler position) - // const moduleParentSlots = [...deckSlots, ...values(PSEUDO_DECK_SLOTS)] - // const slot = moduleParentSlots.find( - // slot => slot.id === moduleOnDeck.slot - // ) - const slotPosition = getPositionFromSlotId(moduleOnDeck.slot, deckDef) + const slotId = + moduleOnDeck.slot === SPAN7_8_10_11_SLOT ? '7' : moduleOnDeck.slot + + const slotPosition = getPositionFromSlotId(slotId, deckDef) if (slotPosition == null) { - console.warn( - `no slot ${moduleOnDeck.slot} for module ${moduleOnDeck.id}` - ) + console.warn(`no slot ${slotId} for module ${moduleOnDeck.id}`) return null } const moduleDef = getModuleDef2(moduleOnDeck.model) @@ -257,7 +254,7 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => { def={moduleDef} orientation={inferModuleOrientationFromXCoordinate(slotPosition[0])} innerProps={getModuleInnerProps(moduleOnDeck.moduleState)} - targetSlotId={moduleOnDeck.slot} + targetSlotId={slotId} targetDeckId={deckDef.otId} > {labwareLoadedOnModule != null && !shouldHideChildren ? ( diff --git a/protocol-designer/src/step-forms/utils/index.ts b/protocol-designer/src/step-forms/utils/index.ts index 8bd93cf176f..5d0b0793ab5 100644 --- a/protocol-designer/src/step-forms/utils/index.ts +++ b/protocol-designer/src/step-forms/utils/index.ts @@ -32,6 +32,21 @@ import type { import type { FormData } from '../../form-types' export { createPresavedStepForm } from './createPresavedStepForm' +const slotToCutoutOt2Map: { [key: string]: string } = { + '1': 'cutout1', + '2': 'cutout2', + '3': 'cutout3', + '4': 'cutout4', + '5': 'cutout5', + '6': 'cutout6', + '7': 'cutout7', + '8': 'cutout8', + '9': 'cutout9', + '10': 'cutout10', + '11': 'cutout11', + '12': 'cutout12', +} + export function getIdsInRange( orderedIds: T[], startId: T, @@ -128,17 +143,22 @@ export const getSlotIsEmpty = ( return false } - const filteredAdditionalEquipmentOnDeck = includeStagingAreas - ? values( - initialDeckSetup.additionalEquipmentOnDeck - ).filter((additionalEquipment: AdditionalEquipmentOnDeck) => - additionalEquipment.location?.includes(slot) - ) - : values(initialDeckSetup.additionalEquipmentOnDeck).filter( - (additionalEquipment: AdditionalEquipmentOnDeck) => - additionalEquipment.location?.includes(slot) && - additionalEquipment.name !== 'stagingArea' - ) + const filteredAdditionalEquipmentOnDeck = values( + initialDeckSetup.additionalEquipmentOnDeck + ).filter((additionalEquipment: AdditionalEquipmentOnDeck) => { + const cutoutForSlotOt2 = slotToCutoutOt2Map[slot] + const includeStaging = includeStagingAreas + ? true + : additionalEquipment.name !== 'stagingArea' + if (cutoutForSlotOt2 != null) { + // for Ot-2 + return additionalEquipment.location === cutoutForSlotOt2 && includeStaging + } else { + // for Flex + return additionalEquipment.location?.includes(slot) && includeStaging + } + }) + return ( [ ...values(initialDeckSetup.modules).filter((moduleOnDeck: ModuleOnDeck) =>