From 509a92a5414f6096ca5dbac5038061d5c67d3b1d Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Wed, 24 Oct 2018 16:35:14 -0400 Subject: [PATCH] deal with deletion --- protocol-designer/src/pipettes/thunks.js | 6 +++--- protocol-designer/src/pipettes/utils.js | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/protocol-designer/src/pipettes/thunks.js b/protocol-designer/src/pipettes/thunks.js index e583fc0ed72c..3c8c21da0523 100644 --- a/protocol-designer/src/pipettes/thunks.js +++ b/protocol-designer/src/pipettes/thunks.js @@ -25,7 +25,7 @@ export const editPipettes = (payload: EditPipettesFields) => const nextPipettesSlice = createNewPipettesSlice(state.pipettes.pipettes, payload.left, payload.right) - each(savedForms, formData => { + each(savedForms, (formData, stepId) => { const formPipetteMount = findKey(prevPipettesByMount, (pipetteData) => ( (pipetteData && pipetteData.id) === formData.pipette )) @@ -33,10 +33,10 @@ export const editPipettes = (payload: EditPipettesFields) => const nextPipetteId = nextPipettesSlice.byMount[formPipetteMount] const nextChannels = nextPipettesSlice.byId[nextPipetteId] && nextPipettesSlice.byId[nextPipetteId].channels dispatch(steplistActions.changeSavedStepForm({ - stepId: formData.id, + stepId, update: { ...reconcileFormPipette(formData, state, nextPipetteId, nextChannels), - pipette: nextPipetteId, + pipette: nextPipetteId || null, }, })) } diff --git a/protocol-designer/src/pipettes/utils.js b/protocol-designer/src/pipettes/utils.js index 2355eb5dc805..c6cdb8aef0ff 100644 --- a/protocol-designer/src/pipettes/utils.js +++ b/protocol-designer/src/pipettes/utils.js @@ -4,6 +4,7 @@ import {getPipette, getLabware} from '@opentrons/shared-data' import type {Mount} from '@opentrons/components' import type {PipetteData} from '../step-generation' +import type {PipetteFields} from '../load-file' import type {PipetteReducerState} from './types' export function createPipette ( @@ -38,7 +39,7 @@ export function createPipette ( } // TODO: BC type left and right here with form mount values -export const createNewPipettesSlice = (state: PipetteReducerState, left: any, right: any): PipetteReducerState => { +export const createNewPipettesSlice = (state: PipetteReducerState, left: PipetteFields, right: PipetteFields): PipetteReducerState => { const prevLeftPipette = state.byMount.left && state.byId[state.byMount.left] const prevRightPipette = state.byMount.right && state.byId[state.byMount.right] @@ -59,11 +60,11 @@ export const createNewPipettesSlice = (state: PipetteReducerState, left: any, ri const leftId = newLeftPipette ? newLeftPipette.id : state.byMount.left const rightId = newRightPipette ? newRightPipette.id : state.byMount.right - const leftPipette = newLeftPipette || (leftId ? state.byId[leftId] : null) - const rightPipette = newRightPipette || (rightId ? state.byId[rightId] : null) + const leftPipette = newLeftPipette || (leftId && left.pipetteModel ? state.byId[leftId] : null) + const rightPipette = newRightPipette || (rightId && left.pipetteModel ? state.byId[rightId] : null) return { - byMount: {left: leftId || null, right: rightId || null}, + byMount: {left: (left.pipetteModel ? leftId : null), right: (right.pipetteModel ? rightId : null)}, byId: ([leftPipette, rightPipette]).reduce((acc: {[pipetteId: string]: PipetteData}, pipette: ?PipetteData) => { return pipette ? {...acc, [pipette.id]: pipette} : acc }, {}),