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): new protocol modal defaults and visual updates #2739

Merged
merged 3 commits into from
Dec 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

.tiprack_labware {
flex: 3;
margin: 0;
}

.left_pipette,
Expand All @@ -21,24 +22,43 @@

.new_file_modal {
line-height: 1.5;
min-height: 100%;
height: 100%;
padding: 2rem;
min-height: 38rem;

/* override default modal top/bottom to allow scroll */
bottom: auto;
}

.new_file_modal_contents {
position: relative;
border-radius: 0;
margin: 0;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}

.new_file_modal_title {
@apply --font-header-dark;

& form > * {
margin-bottom: 1rem;
}
margin-bottom: 1rem;
}

.beta_restrictions {
@apply --font-body-2-dark;

margin: 1rem 0;
}

& ol > li {
counter-increment: step-counter;
list-style: none;
margin: 1rem 0;
}
.button_row {
display: flex;
justify-content: flex-end;
}

& ol > li::before {
content: counter(step-counter) ") ";
}
.button {
margin: 0 0 0 1rem;
}

.mount_fields_row {
Expand Down
75 changes: 36 additions & 39 deletions protocol-designer/src/components/modals/NewFileModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import * as React from 'react'
import cx from 'classnames'
import {
AlertModal,
Modal,
DropdownField,
FormGroup,
InputField,
OutlineButton,
type Mount,
} from '@opentrons/components'
import startCase from 'lodash/startCase'
import isEmpty from 'lodash/isEmpty'
import i18n from '../../../localization'
import {pipetteOptions} from '../../../pipettes/pipetteData'
import PipetteDiagram from './PipetteDiagram'
import TiprackDiagram from './TiprackDiagram'
Expand All @@ -26,23 +28,11 @@ type Props = {
onSave: (NewProtocolFields) => mixed,
}

// 'USER_HAS_NOT_SELECTED' state is just a concern of these dropdowns,
// not selected pipette state in general
// It's needed b/c user must select 'None' explicitly,
// they cannot just leave the dropdown blank.
const USER_HAS_NOT_SELECTED = 'USER_HAS_NOT_SELECTED'
// TODO: Ian 2018-06-22 use pristinity instead of this?

const pipetteOptionsWithNone = [
{name: 'None', value: ''},
...pipetteOptions,
]

const pipetteOptionsWithInvalid = [
{name: '', value: USER_HAS_NOT_SELECTED},
...pipetteOptionsWithNone,
]

// TODO: Ian 2018-06-22 get this programatically from shared-data labware defs
// and exclude options that are incompatible with pipette
// and also auto-select tiprack if there's only one compatible tiprack for a pipette
Expand All @@ -56,8 +46,8 @@ const tiprackOptions = [

const initialState = {
name: '',
left: {pipetteModel: USER_HAS_NOT_SELECTED, tiprackModel: null},
right: {pipetteModel: USER_HAS_NOT_SELECTED, tiprackModel: null},
left: {pipetteModel: '', tiprackModel: null},
right: {pipetteModel: '', tiprackModel: null},
}

// TODO: BC 2018-11-06 there is a lot of copy pasta between this component and the edit pipettes modal, lets consolidate
Expand Down Expand Up @@ -88,8 +78,6 @@ export default class NewFileModal extends React.Component<Props, State> {
const {name, left, right} = this.state

const pipetteSelectionIsValid = (
// neither can be invalid
(left.pipetteModel !== USER_HAS_NOT_SELECTED && right.pipetteModel !== USER_HAS_NOT_SELECTED) &&
// at least one must not be none (empty string)
(left.pipetteModel || right.pipetteModel)
)
Expand All @@ -103,33 +91,28 @@ export default class NewFileModal extends React.Component<Props, State> {
const canSubmit = pipetteSelectionIsValid && tiprackSelectionIsValid

return (
<AlertModal
className={cx(modalStyles.modal, styles.new_file_modal)}
buttons={[
{onClick: this.props.onCancel, children: 'Cancel', tabIndex: 7},
{onClick: this.handleSubmit, disabled: !canSubmit, children: 'Save', tabIndex: 6},
]}>
<form
className={modalStyles.modal_contents}
onSubmit={() => { canSubmit && this.handleSubmit() }}>
<h2>Create New Protocol</h2>

<FormGroup label='Name:'>
<Modal
contentsClassName={styles.new_file_modal_contents}
className={cx(modalStyles.modal, styles.new_file_modal)}>
<form onSubmit={() => { canSubmit && this.handleSubmit() }}>
<h2 className={styles.new_file_modal_title}>Create New Protocol</h2>
<FormGroup className={formStyles.stacked_row} label='Name:'>
<InputField
autoFocus
tabIndex={1}
placeholder='Untitled'
value={name}
onChange={this.handleNameChange} />
</FormGroup>

<BetaRestrictions />

<div className={styles.mount_fields_row}>
<div className={styles.mount_column}>
<FormGroup key="leftPipetteModel" label="Left Pipette" className={formStyles.stacked_row}>
<DropdownField
tabIndex={2}
options={this.state.left.pipetteModel === USER_HAS_NOT_SELECTED ? pipetteOptionsWithInvalid : pipetteOptionsWithNone}
options={pipetteOptionsWithNone}
value={this.state.left.pipetteModel}
onChange={this.makeHandleMountChange('left', 'pipetteModel')} />
</FormGroup>
Expand All @@ -150,7 +133,7 @@ export default class NewFileModal extends React.Component<Props, State> {
<FormGroup key="rightPipetteModel" label="Right Pipette" className={formStyles.stacked_row}>
<DropdownField
tabIndex={4}
options={this.state.right.pipetteModel === USER_HAS_NOT_SELECTED ? pipetteOptionsWithInvalid : pipetteOptionsWithNone}
options={pipetteOptionsWithNone}
value={this.state.right.pipetteModel}
onChange={this.makeHandleMountChange('right', 'pipetteModel')} />
</FormGroup>
Expand Down Expand Up @@ -178,19 +161,33 @@ export default class NewFileModal extends React.Component<Props, State> {
<TiprackDiagram containerType={this.state.right.tiprackModel} />
</div>
</form>
</AlertModal>
<div className={styles.button_row}>
<OutlineButton
onClick={this.props.onCancel}
tabIndex={7}
className={styles.button}>
{i18n.t('button.cancel')}
</OutlineButton>
<OutlineButton
onClick={this.handleSubmit}
disabled={!canSubmit}
tabIndex={6}
className={styles.button}>
{i18n.t('button.save')}
</OutlineButton>
</div>
</Modal>
)
}
}

const BetaRestrictions = () => (
<React.Fragment>
<h3>Beta Pipette Restrictions:</h3>
<ol>
<li>
Pipettes can&apos;t share tip racks. There needs to be at least 1 tip rack per
pipette on the deck.
</li>
</ol>
<p className={styles.beta_restrictions}>
<strong>NOTE:</strong>
&nbsp;
Pipettes can&apos;t share tip racks. There must be at least 1 tip rack per
pipette.
</p>
</React.Fragment>
)