Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol-designer): place tipracks on protocol creation #2750

Merged
merged 2 commits into from
Dec 5, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion protocol-designer/src/labware-ingred/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
import * as actions from '../actions'
import {getPDMetadata} from '../../file-types'
import type {BaseState, Options} from '../../types'
import type {LoadFileAction} from '../../load-file'
import type {LoadFileAction, NewProtocolFields} from '../../load-file'
import type {
RemoveWellsContents,
DeleteLiquidGroup,
Expand Down Expand Up @@ -195,6 +195,30 @@ export const containers = handleActions({
}
}, {})
},
CREATE_NEW_PROTOCOL: (
state: ContainersState,
action: {payload: NewProtocolFields}
): ContainersState => {
const initialTipracks = [action.payload.left, action.payload.right].reduce((acc, mount) => {
if (mount.tiprackModel) {
const id = `${uuid()}:${String(mount.tiprackModel)}`
return {
...acc,
[id]: {
slot: nextEmptySlot(_loadedContainersBySlot({...state, ...acc})),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style nitpick: if {...state, ...acc} was be acc here and L210, and the initial state of this reducer was {...state} instead of {}, I think it would be a bit simpler / more readable. Then you could also return the result of this reduce and not have to spread ...state in a 3rd time on L218

type: mount.tiprackModel,
disambiguationNumber: getNextDisambiguationNumber({...state, ...acc}, String(mount.tiprackModel)),
id,
name: null, // create with null name, so we force explicit naming.
},
}
}
}, {})
return {
...state,
...initialTipracks,
}
},
}, initialLabwareState)

type SavedLabwareState = {[labwareId: string]: boolean}
Expand Down