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): rename change tip options #2003

Merged
merged 1 commit into from
Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion protocol-designer/src/components/StepEditForm/MixForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MixForm = (props: MixFormProps): React.Element<React.Fragment> => {
</FormGroup>
</div>
<div className={styles.right_settings_column}>
<ChangeTipField name="aspirate_changeTip" />
<ChangeTipField stepType="mix" name="aspirate_changeTip" />
<FlowRateField />
<TipPositionField />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const TransferLikeForm = (props: TransferLikeFormProps) => {
</FormGroup>
</div>
<div className={styles.right_settings_column}>
<ChangeTipField name="aspirate_changeTip" />
<ChangeTipField stepType={stepType} name="aspirate_changeTip" />
<FlowRateField />
<TipPositionField />
</div>
Expand Down
46 changes: 30 additions & 16 deletions protocol-designer/src/components/StepEditForm/formFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,36 @@ export const FlowRateField = () => <FormGroup label='FLOW RATE'>Default</FormGro
// this is a placeholder
export const TipPositionField = () => <FormGroup label='TIP POSITION'>Bottom, center</FormGroup>

const CHANGE_TIP_OPTIONS = [
{name: 'Always', value: 'always'},
{name: 'Once', value: 'once'},
const getChangeTipOptions = () => [
{name: 'For each aspirate', value: 'always'},
{name: 'Only the first aspirate', value: 'once'},
{name: 'Never', value: 'never'}
]

// NOTE: ChangeTipField not validated as of 6/27/18 so no focusHandlers needed
type ChangeTipFieldProps = {name: StepFieldName}
export const ChangeTipField = (props: ChangeTipFieldProps) => (
<StepField
name={props.name}
render={({value, updateValue}) => (
<FormGroup label='CHANGE TIP'>
<DropdownField
options={CHANGE_TIP_OPTIONS}
value={value ? String(value) : null}
onChange={(e: SyntheticEvent<HTMLSelectElement>) => { updateValue(e.currentTarget.value) } } />
</FormGroup>
)} />
)
type ChangeTipFieldProps = {name: StepFieldName, stepType: StepType}
export const ChangeTipField = (props: ChangeTipFieldProps) => {
const {name, stepType} = props
let options = getChangeTipOptions()
// Override change tip option names for certain step types
switch (stepType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These overrides would be a perfect place to throw in some parameterized i18n translations, but that could come down the road.

case 'consolidate':
options[0].name = 'For each dispense'
break
case 'mix':
options[0].name = 'For each well'
break
}
return (
<StepField
name={name}
render={({value, updateValue}) => (
<FormGroup label='Get new tip'>
<DropdownField
options={options}
value={value ? String(value) : null}
onChange={(e: SyntheticEvent<HTMLSelectElement>) => { updateValue(e.currentTarget.value) } } />
</FormGroup>
)} />
)
}
2 changes: 2 additions & 0 deletions protocol-designer/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ export const FIXED_TRASH_ID: 'trashId' = 'trashId'

export const START_TERMINAL_TITLE = 'STARTING DECK STATE'
export const END_TERMINAL_TITLE = 'FINAL DECK STATE'

export const DEFAULT_CHANGE_TIP_OPTION: 'always' = 'always'
5 changes: 0 additions & 5 deletions protocol-designer/src/steplist/fieldLevel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export type {
StepFieldName
}

const DEFAULT_CHANGE_TIP_OPTION: 'always' = 'always'

const hydrateLabware = (state, id) => (labwareIngredSelectors.getLabware(state)[id])

type StepFieldHelpers = {
Expand All @@ -35,9 +33,6 @@ const stepFieldHelperMap: {[StepFieldName]: StepFieldHelpers} = {
getErrors: composeErrors(requiredField),
hydrate: hydrateLabware
},
'changeTip': {
processValue: defaultTo(DEFAULT_CHANGE_TIP_OPTION)
},
'dispense_delayMinutes': {
processValue: composeProcessors(castToNumber, defaultTo(0))
},
Expand Down
10 changes: 6 additions & 4 deletions protocol-designer/src/steplist/formProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import type {
CommandCreatorData
} from '../step-generation'

import {FIXED_TRASH_ID} from '../constants'

const DEFAULT_CHANGE_TIP_OPTION: 'always' = 'always'
import {
DEFAULT_CHANGE_TIP_OPTION,
FIXED_TRASH_ID
} from '../constants'

// TODO LATER Ian 2018-03-01 remove or consolidate these 2 similar types?
export type ValidFormAndErrors = {
Expand Down Expand Up @@ -55,13 +56,14 @@ export const generateNewForm = (stepId: StepIdType, stepType: StepType): BlankFo
if (stepType === 'transfer' || stepType === 'consolidate' || stepType === 'mix') {
return {
...baseForm,
'aspirate_changeTip': 'once'
'aspirate_changeTip': DEFAULT_CHANGE_TIP_OPTION
}
}

if (stepType === 'distribute') {
return {
...baseForm,
'aspirate_changeTip': DEFAULT_CHANGE_TIP_OPTION,
'aspirate_disposalVol_checkbox': true,
'dispense_blowout_checkbox': true,
'dispense_blowout_labware': FIXED_TRASH_ID
Expand Down