Skip to content

Commit

Permalink
fix(protocol-designer): clean up trash modal and new labware dropdown…
Browse files Browse the repository at this point in the history
… logic (#15070)

closes RQA-2501, RQA-2143, RQA-1156, AUTH-378
  • Loading branch information
jerader authored May 2, 2024
1 parent b2749d8 commit 926ef09
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export function LabwareSelectionModal(): JSX.Element | null {
<ul>
{customLabwareURIs.length > 0 ? (
<PDTitledList
title="Custom Labware"
title={t('custom_labware')}
collapsed={selectedCategory !== CUSTOM_CATEGORY}
onCollapseToggle={makeToggleCategory(CUSTOM_CATEGORY)}
onClick={makeToggleCategory(CUSTOM_CATEGORY)}
Expand Down Expand Up @@ -530,7 +530,7 @@ export function LabwareSelectionModal(): JSX.Element | null {
<PDTitledList
data-testid="LabwareSelectionModal_adapterCompatibleLabware"
key={adapterCompatibleLabware}
title="adapter compatible labware"
title={t('adapter_compatible_labware')}
collapsed={selectedCategory !== adapterCompatibleLabware}
onCollapseToggle={makeToggleCategory(adapterCompatibleLabware)}
onClick={makeToggleCategory(adapterCompatibleLabware)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('LabwareSelectionModal', () => {
})
render()
fireEvent.click(
screen.getByText(nestedTextMatcher('adapter compatible labware'))
screen.getByText(nestedTextMatcher('Adapter Compatible Labware'))
)
screen.getByText('Opentrons GEB 1000uL Tiprack')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import * as React from 'react'
import { useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { getModuleDisplayName } from '@opentrons/shared-data'
import {
getModuleDisplayName,
WASTE_CHUTE_CUTOUT,
} from '@opentrons/shared-data'
import {
getAdditionalEquipmentEntities,
getLabwareEntities,
getModuleEntities,
} from '../../../../step-forms/selectors'
import {
getRobotStateAtActiveItem,
getUnoccupiedLabwareLocationOptions,
} from '../../../../top-selectors/labware-locations'
import { getHasWasteChute } from '../../../labware'
import { StepFormDropdown } from '../StepFormDropdownField'

export function LabwareLocationField(
Expand All @@ -27,32 +22,18 @@ export function LabwareLocationField(
const labwareEntities = useSelector(getLabwareEntities)
const robotState = useSelector(getRobotStateAtActiveItem)
const moduleEntities = useSelector(getModuleEntities)
const additionalEquipmentEntities = useSelector(
getAdditionalEquipmentEntities
)
const hasWasteChute = getHasWasteChute(additionalEquipmentEntities)
const isLabwareOffDeck =
labware != null ? robotState?.labware[labware]?.slot === 'offDeck' : false
const displayWasteChuteValue =
useGripper && hasWasteChute && !isLabwareOffDeck

let unoccupiedLabwareLocationsOptions =
useSelector(getUnoccupiedLabwareLocationOptions) ?? []

if (isLabwareOffDeck && hasWasteChute) {
unoccupiedLabwareLocationsOptions = unoccupiedLabwareLocationsOptions.filter(
option =>
option.value !== 'offDeck' && option.value !== WASTE_CHUTE_CUTOUT
)
} else if (useGripper || isLabwareOffDeck) {
if (useGripper || isLabwareOffDeck) {
unoccupiedLabwareLocationsOptions = unoccupiedLabwareLocationsOptions.filter(
option => option.value !== 'offDeck'
)
} else if (!displayWasteChuteValue) {
unoccupiedLabwareLocationsOptions = unoccupiedLabwareLocationsOptions.filter(
option => option.name !== 'Waste Chute in D3'
)
}

const location: string = value as string

const bothFieldsSelected = labware != null && value != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ import {
OT2_ROBOT_TYPE,
getPipetteSpecsV2,
} from '@opentrons/shared-data'
import { StepChangesConfirmModal } from '../EditPipettesModal/StepChangesConfirmModal'
import { PipetteFields } from './PipetteFields'
import { CrashInfoBox } from '../../modules'
import styles from './FilePipettesModal.module.css'
import modalStyles from '../modal.module.css'
import {
actions as stepFormActions,
selectors as stepFormSelectors,
Expand All @@ -42,14 +37,29 @@ import { INITIAL_DECK_SETUP_STEP_ID } from '../../../constants'
import { NewProtocolFields } from '../../../load-file'
import { getRobotType } from '../../../file-data/selectors'
import { uuid } from '../../../utils'
import { getLabwareEntities } from '../../../step-forms/selectors'
import {
createContainer,
deleteContainer,
} from '../../../labware-ingred/actions'
import { actions as steplistActions } from '../../../steplist'
import { selectors as featureFlagSelectors } from '../../../feature-flags'
import { CrashInfoBox } from '../../modules'
import { getCrashableModuleSelected } from '../CreateFileWizard/utils'
import { adapter96ChannelDefUri } from '../CreateFileWizard'
import { StepChangesConfirmModal } from '../EditPipettesModal/StepChangesConfirmModal'
import { PipetteFields } from './PipetteFields'

import type {
LabwareEntities,
NormalizedPipette,
} from '@opentrons/step-generation'
import type { DeckSlot, ThunkDispatch } from '../../../types'
import type { NormalizedPipette } from '@opentrons/step-generation'
import type { StepIdType } from '../../../form-types'

import styles from './FilePipettesModal.module.css'
import modalStyles from '../modal.module.css'

export type PipetteFieldsData = Omit<
PipetteOnDeck,
'id' | 'spec' | 'tiprackLabwareDef'
Expand Down Expand Up @@ -124,6 +134,7 @@ const validationSchema: any = Yup.object().shape({
})

const makeUpdatePipettes = (
labwareEntities: LabwareEntities,
prevPipettes: { [pipetteId: string]: PipetteOnDeck },
orderedStepIds: StepIdType[],
dispatch: ThunkDispatch<any>,
Expand Down Expand Up @@ -159,6 +170,38 @@ const makeUpdatePipettes = (
}
}
})
const newTiprackUris = new Set(
newPipetteArray.flatMap(pipette => pipette.tiprackDefURI)
)
const previousTiprackLabwares = Object.values(labwareEntities).filter(
labware => labware.def.parameters.isTiprack
)

const previousTiprackUris = new Set(
previousTiprackLabwares.map(labware => labware.labwareDefURI)
)

// Find tipracks to delete (old tipracks not in new pipettes)
previousTiprackLabwares
.filter(labware => !newTiprackUris.has(labware.labwareDefURI))
.forEach(labware => dispatch(deleteContainer({ labwareId: labware.id })))

// Create new tipracks that are not in previous tiprackURIs
newTiprackUris.forEach(tiprackDefUri => {
if (!previousTiprackUris.has(tiprackDefUri)) {
const adapterUnderLabwareDefURI = newPipetteArray.some(
pipette => pipette.name === 'p1000_96'
)
? adapter96ChannelDefUri
: undefined
dispatch(
createContainer({
labwareDefURI: tiprackDefUri,
adapterUnderLabwareDefURI,
})
)
}
})

dispatch(
stepFormActions.createPipettes(
Expand Down Expand Up @@ -275,6 +318,7 @@ export const FilePipettesModal = (props: Props): JSX.Element => {
const { t } = useTranslation(['modal', 'button', 'form'])
const robotType = useSelector(getRobotType)
const dispatch = useDispatch()
const labwareEntities = useSelector(getLabwareEntities)
const initialPipettes = useSelector(
stepFormSelectors.getPipettesForEditPipetteForm
)
Expand All @@ -295,6 +339,7 @@ export const FilePipettesModal = (props: Props): JSX.Element => {
modules: ModuleCreationArgs[]
pipettes: PipetteFieldsData[]
}) => void = makeUpdatePipettes(
labwareEntities,
prevPipettes,
orderedStepIds,
dispatch,
Expand Down
13 changes: 8 additions & 5 deletions protocol-designer/src/components/modules/TrashModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ const TrashModalComponent = (props: TrashModalComponentProps): JSX.Element => {
name: 'selectedSlot',
defaultValue: defaultValue,
})
const isSlotEmpty = getSlotIsEmpty(
initialDeckSetup,
selectedSlot,
trashName === 'trashBin'
)
const hasTrashAlreadyInSlot = Object.values(
initialDeckSetup.additionalEquipmentOnDeck
).find(aE => aE.name === 'trashBin' && aE.location === selectedSlot)

const isSlotEmpty =
getSlotIsEmpty(initialDeckSetup, selectedSlot, trashName === 'trashBin') ||
hasTrashAlreadyInSlot

const slotFromCutout = selectedSlot.replace('cutout', '')
const flexDeck = getDeckDefFromRobotType(FLEX_ROBOT_TYPE)

Expand Down
2 changes: 2 additions & 0 deletions protocol-designer/src/localization/en/modules.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"adapter_compatible_labware": "Adapter Compatible Labware",
"custom_labware": "Custom Labware",
"additional_equipment_display_names": {
"gripper": "Flex Gripper",
"stagingAreas": "Staging Area Slots",
Expand Down

0 comments on commit 926ef09

Please sign in to comment.