Skip to content

Commit 34a0054

Browse files
authored
fix(protocol-designer): auto-populate the drop tip location if applicable (#18500)
closes RQA-4239
1 parent 898887d commit 34a0054

File tree

1 file changed

+66
-16
lines changed
  • protocol-designer/src/step-forms/reducers

1 file changed

+66
-16
lines changed

protocol-designer/src/step-forms/reducers/index.ts

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,39 @@ export const savedStepForms = (
377377
const prevInitialDeckSetupStep =
378378
savedStepForms[INITIAL_DECK_SETUP_STEP_ID]
379379
const locationUpdate = `${name}LocationUpdate`
380-
return {
381-
...savedStepForms,
382-
[INITIAL_DECK_SETUP_STEP_ID]: {
383-
...prevInitialDeckSetupStep,
384-
[locationUpdate]: {
385-
...prevInitialDeckSetupStep[locationUpdate],
386-
[id]: location,
387-
},
388-
},
389-
}
380+
return mapValues(
381+
savedStepForms,
382+
(form: FormData): FormData => {
383+
if (form.stepType === 'manualIntervention') {
384+
return {
385+
...form,
386+
[INITIAL_DECK_SETUP_STEP_ID]: {
387+
...prevInitialDeckSetupStep,
388+
[locationUpdate]: {
389+
...prevInitialDeckSetupStep[locationUpdate],
390+
[id]: location,
391+
},
392+
},
393+
}
394+
} else if (
395+
form.dropTip_location == null &&
396+
(name === 'trashBin' || name === 'wasteChute')
397+
) {
398+
return {
399+
...form,
400+
...handleFormChange(
401+
{
402+
dropTip_location: id,
403+
},
404+
form,
405+
_getPipetteEntitiesRootState(rootState),
406+
_getLabwareEntitiesRootState(rootState)
407+
),
408+
}
409+
}
410+
return form
411+
}
412+
)
390413
}
391414
case 'DELETE_DECK_FIXTURE': {
392415
const { id } = action.payload
@@ -396,13 +419,41 @@ export const savedStepForms = (
396419
return mapValues(
397420
savedStepForms,
398421
(form: FormData): FormData => {
399-
const updatedLocation = omit(form[locationUpdate] || {}, id)
422+
if (form.stepType === 'manualIntervention') {
423+
const updatedLocation = omit(form[locationUpdate] || {}, id)
400424

401-
return {
402-
...form,
403-
[locationUpdate]:
404-
Object.keys(updatedLocation).length > 0 ? updatedLocation : {},
425+
return {
426+
...form,
427+
[locationUpdate]:
428+
Object.keys(updatedLocation).length > 0 ? updatedLocation : {},
429+
}
430+
} else if (id.includes(form.dropTip_location as string)) {
431+
return {
432+
...form,
433+
...handleFormChange(
434+
{
435+
dropTip_location: null,
436+
},
437+
form,
438+
_getPipetteEntitiesRootState(rootState),
439+
_getLabwareEntitiesRootState(rootState)
440+
),
441+
}
442+
} else if (id.includes(form.newLocation as string)) {
443+
return {
444+
...form,
445+
...handleFormChange(
446+
{
447+
newLocation: null,
448+
},
449+
form,
450+
_getPipetteEntitiesRootState(rootState),
451+
_getLabwareEntitiesRootState(rootState)
452+
),
453+
}
405454
}
455+
456+
return form
406457
}
407458
)
408459
}
@@ -668,7 +719,6 @@ export const savedStepForms = (
668719
return { ...savedForm, ...deleteLabwareUpdate }
669720
})
670721
}
671-
672722
case 'DELETE_PIPETTES': {
673723
// remove references to pipettes that have been deleted
674724
const deletedPipetteIds = action.payload

0 commit comments

Comments
 (0)