Skip to content

Commit

Permalink
fix(app): update both thermocycler cutouts when removing for location…
Browse files Browse the repository at this point in the history
… conflict (#16157)

when removing a thermocycler, to issue a valid deck configuration update
we must update both cutouts A1 and B1. this substitutes a single left
slot fixture in the paired cutout of the target location conflict cutout
id.

closes RQA-3074
  • Loading branch information
brenthagen authored Aug 30, 2024
1 parent 622a315 commit 0598a39
Showing 1 changed file with 68 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import {
THERMOCYCLER_MODULE_V2,
getCutoutFixturesForModuleModel,
getFixtureIdByCutoutIdFromModuleSlotName,
SINGLE_LEFT_SLOT_FIXTURE,
THERMOCYCLER_V2_FRONT_FIXTURE,
THERMOCYCLER_V2_REAR_FIXTURE,
} from '@opentrons/shared-data'

import { getTopPortalEl } from '../../../../App/portal'
Expand Down Expand Up @@ -76,25 +79,20 @@ export const LocationConflictModal = (
(deckFixture: CutoutConfig) => deckFixture.cutoutId === cutoutId
)?.cutoutFixtureId

const isThermocycler =
const isThermocyclerRequired =
requiredModule === THERMOCYCLER_MODULE_V1 ||
requiredModule === THERMOCYCLER_MODULE_V2

// check if current fixture in cutoutId is thermocycler
const isThermocyclerCurrentFixture =
deckConfigurationAtLocationFixtureId === THERMOCYCLER_V2_REAR_FIXTURE ||
deckConfigurationAtLocationFixtureId === THERMOCYCLER_V2_FRONT_FIXTURE

const currentFixtureDisplayName =
deckConfigurationAtLocationFixtureId != null
? getFixtureDisplayName(deckConfigurationAtLocationFixtureId)
: ''

// get fixture display name at A1 for themocycler if B1 is slot
const deckConfigurationAtA1 = deckConfig.find(
(deckFixture: CutoutConfig) => deckFixture.cutoutId === 'cutoutA1'
)?.cutoutFixtureId

const currentThermocyclerFixtureDisplayName =
currentFixtureDisplayName === 'Slot' && deckConfigurationAtA1 != null
? getFixtureDisplayName(deckConfigurationAtA1)
: currentFixtureDisplayName

const handleConfigureModule = (moduleSerialNumber?: string): void => {
if (requiredModule != null) {
const slotName = cutoutId.replace('cutout', '')
Expand All @@ -111,14 +109,35 @@ export const LocationConflictModal = (
const newDeckConfig = deckConfig.map(existingCutoutConfig => {
const replacementCutoutFixtureId =
moduleFixtureIdByCutoutId[existingCutoutConfig.cutoutId]
return existingCutoutConfig.cutoutId in moduleFixtureIdByCutoutId &&
if (
existingCutoutConfig.cutoutId in moduleFixtureIdByCutoutId &&
replacementCutoutFixtureId != null
? {
...existingCutoutConfig,
cutoutFixtureId: replacementCutoutFixtureId,
opentronsModuleSerialNumber: moduleSerialNumber,
}
: existingCutoutConfig
) {
return {
...existingCutoutConfig,
cutoutFixtureId: replacementCutoutFixtureId,
opentronsModuleSerialNumber: moduleSerialNumber,
}
} else if (
isThermocyclerCurrentFixture &&
((cutoutId === 'cutoutA1' &&
existingCutoutConfig.cutoutId === 'cutoutB1') ||
(cutoutId === 'cutoutB1' &&
existingCutoutConfig.cutoutId === 'cutoutA1'))
) {
/**
* special-case for removing current thermocycler:
* set paired cutout (B1 for A1, A1 for B1) to single slot left fixture
* TODO(bh, 2024-08-29): generalize to remove all entities from FixtureGroup
*/
return {
...existingCutoutConfig,
cutoutFixtureId: SINGLE_LEFT_SLOT_FIXTURE,
opentronsModuleSerialNumber: undefined,
}
} else {
return existingCutoutConfig
}
})
updateDeckConfiguration(newDeckConfig)
}
Expand All @@ -129,15 +148,33 @@ export const LocationConflictModal = (
if (requiredModule != null) {
setShowModuleSelect(true)
} else if (requiredFixtureId != null) {
const newRequiredFixtureDeckConfig = deckConfig.map(fixture =>
fixture.cutoutId === cutoutId
? {
...fixture,
cutoutFixtureId: requiredFixtureId,
opentronsModuleSerialNumber: undefined,
}
: fixture
)
const newRequiredFixtureDeckConfig = deckConfig.map(fixture => {
if (fixture.cutoutId === cutoutId) {
return {
...fixture,
cutoutFixtureId: requiredFixtureId,
opentronsModuleSerialNumber: undefined,
}
} else if (
isThermocyclerCurrentFixture &&
((cutoutId === 'cutoutA1' && fixture.cutoutId === 'cutoutB1') ||
(cutoutId === 'cutoutB1' && fixture.cutoutId === 'cutoutA1'))
) {
/**
* special-case for removing current thermocycler:
* set paired cutout (B1 for A1, A1 for B1) to single slot left fixture
* TODO(bh, 2024-08-29): generalize to remove all entities from FixtureGroup
*/
return {
...fixture,
cutoutFixtureId: SINGLE_LEFT_SLOT_FIXTURE,
opentronsModuleSerialNumber: undefined,
}
} else {
return fixture
}
})

updateDeckConfiguration(newRequiredFixtureDeckConfig)
onCloseClick()
} else {
Expand All @@ -154,7 +191,7 @@ export const LocationConflictModal = (
protocolSpecifiesDisplayName = getModuleDisplayName(requiredModule)
}

const displaySlotName = isThermocycler
const displaySlotName = isThermocyclerRequired
? 'A1 + B1'
: getCutoutDisplayName(cutoutId)

Expand Down Expand Up @@ -189,7 +226,7 @@ export const LocationConflictModal = (
<Trans
t={t}
i18nKey={
isThermocycler
isThermocyclerRequired
? 'deck_conflict_info_thermocycler'
: 'deck_conflict_info'
}
Expand Down Expand Up @@ -298,7 +335,7 @@ export const LocationConflictModal = (
<Trans
t={t}
i18nKey={
isThermocycler
isThermocyclerRequired
? 'deck_conflict_info_thermocycler'
: 'deck_conflict_info'
}
Expand Down Expand Up @@ -350,9 +387,7 @@ export const LocationConflictModal = (
{t('currently_configured')}
</LegacyStyledText>
<LegacyStyledText as="label" flex="1">
{isThermocycler
? currentThermocyclerFixtureDisplayName
: currentFixtureDisplayName}
{currentFixtureDisplayName}
</LegacyStyledText>
</Flex>
</Flex>
Expand Down

0 comments on commit 0598a39

Please sign in to comment.