Skip to content

Commit

Permalink
fix(app): Improve tip probe wizard state and error handling (#3959)
Browse files Browse the repository at this point in the history
Closes #3948, closes #3944, closes #3943, closes #2008
  • Loading branch information
mcous authored Aug 28, 2019
1 parent aea86d4 commit b88c73b
Show file tree
Hide file tree
Showing 19 changed files with 189 additions and 261 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ make term
make term host=${some_other_ip_address}
```

If `make term` complains about not having a key, you may need to install a public key on the robot. To do this, create an ssh key and install it:
If `make term` complains about not having a key, you may need to install a public key on the robot. To do this, create an ssh key and install it:

```shell
ssh-keygen # note the path you save the key to
Expand Down
31 changes: 20 additions & 11 deletions app/src/components/ClearDeckAlertModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import { Link } from 'react-router-dom'

import { AlertModal } from '@opentrons/components'
import { Portal } from '../portal'
import removeTrashSrc from './img/[email protected]'
import styles from './styles.css'

type Props = {
type Props = {|
onContinueClick?: () => mixed,
onCancelClick?: () => mixed,
parentUrl: string,
parentUrl?: string,
cancelText: string,
continueText: string,
removeTrash?: boolean,
children?: React.Node,
}
const HEADING = 'Before continuing, remove from deck:'
|}

const HEADING = 'Before continuing, please remove:'

export default function ClearDeckAlertModal(props: Props) {
const {
Expand All @@ -23,6 +26,7 @@ export default function ClearDeckAlertModal(props: Props) {
parentUrl,
cancelText,
continueText,
removeTrash = false,
} = props

return (
Expand All @@ -32,9 +36,8 @@ export default function ClearDeckAlertModal(props: Props) {
buttons={[
{
children: `${cancelText}`,
Component: Link,
to: parentUrl,
onClick: onCancelClick,
...(parentUrl != null ? { Component: Link, to: parentUrl } : {}),
},
{
children: `${continueText}`,
Expand All @@ -44,11 +47,17 @@ export default function ClearDeckAlertModal(props: Props) {
]}
alertOverlay
>
<ul className={styles.alert_list}>
<li>All tipracks</li>
<li>All labware</li>
</ul>
{props.children && (
<div className={styles.alert_instructions}>
<ul className={styles.alert_list}>
<li>All labware from the deck</li>
<li>All tips from pipettes</li>
{removeTrash && <li>The removable trash bin</li>}
</ul>
{removeTrash && (
<img className={styles.alert_diagram} src={removeTrashSrc} />
)}
</div>
{props.children != null && (
<div>
<p className={styles.alert_note_heading}>Note:</p>
{props.children}
Expand Down
13 changes: 12 additions & 1 deletion app/src/components/ClearDeckAlertModal/styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
@import '@opentrons/components';

.alert_instructions {
display: flex;
flex-wrap: wrap;
align-items: center;
}

.alert_list {
padding-left: 1rem;
padding-right: 4rem;
list-style-type: none;
padding-left: 3rem;

& > li {
line-height: 2;
Expand All @@ -15,6 +22,10 @@
}
}

.alert_diagram {
max-height: 10rem;
}

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

Expand Down
26 changes: 0 additions & 26 deletions app/src/components/ConfirmTipProbeModal/Contents.css

This file was deleted.

19 changes: 0 additions & 19 deletions app/src/components/ConfirmTipProbeModal/Contents.js

This file was deleted.

50 changes: 0 additions & 50 deletions app/src/components/ConfirmTipProbeModal/index.js

This file was deleted.

17 changes: 14 additions & 3 deletions app/src/components/TipProbe/AttachTipPanel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @flow
import * as React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import cx from 'classnames'

import CalibrationInfoContent from '../CalibrationInfoContent'
import { PrimaryButton } from '@opentrons/components'

Expand All @@ -10,6 +12,7 @@ import {
} from '../../robot'
import attachSingle from '../../img/attach_tip_single.png'
import attachMulti from '../../img/attach_tip_multi.png'
import styles from './tip-probe.css'

import type { Dispatch } from '../../types'
import type { TipProbeProps } from './types'
Expand All @@ -26,6 +29,7 @@ export default function AttachTipPanel(props: Props) {

// $FlowFixMe: robotActions.probeTip is not typed
const handleTipProbe = () => dispatch(robotActions.probeTip(mount))
const isMulti = channels > 1

const leftChildren = (
<div>
Expand All @@ -39,17 +43,24 @@ export default function AttachTipPanel(props: Props) {
<br />{' '}
</>
)}
on pipette before continuing
on {isMulti ? 'the back-most channel of' : ''} the pipette before
continuing
</p>
<PrimaryButton onClick={handleTipProbe}>
Confirm Tip Attached
</PrimaryButton>
</div>
)

const imgSrc = channels === 1 ? attachSingle : attachMulti
const imgSrc = isMulti ? attachMulti : attachSingle

const rightChildren = <img src={imgSrc} alt="attach tip" />
const rightChildren = (
<img
src={imgSrc}
alt="attach tip"
className={cx(styles.pipette_diagram, styles[mount])}
/>
)

return (
<CalibrationInfoContent
Expand Down
91 changes: 39 additions & 52 deletions app/src/components/TipProbe/UnprobedPanel.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
// @flow
import * as React from 'react'
import { connect } from 'react-redux'
import { push } from 'connected-react-router'
import { useDispatch, useSelector } from 'react-redux'

import CalibrationInfoContent from '../CalibrationInfoContent'
import { PrimaryButton } from '@opentrons/components'
import ClearDeckAlertModal from '../ClearDeckAlertModal'
import CalibrationInfoContent from '../CalibrationInfoContent'

import {
actions as robotActions,
selectors as robotSelectors,
} from '../../robot'

import type { State, Dispatch } from '../../types'
import type { TipProbeProps } from './types'

type OP = TipProbeProps
import { actions as robotActions } from '../../robot'

type SP = {| _showContinueModal: boolean |}
import { getDeckPopulated } from '../../robot/selectors'

type DP = {| dispatch: Dispatch |}
import type { Dispatch } from '../../types'
import type { TipProbeProps } from './types'

type Props = {| ...OP, onPrepareClick: () => void |}
export default function UnprobedPanel(props: TipProbeProps) {
const { mount, probed } = props
const [showClearDeck, setShowClearDeck] = React.useState(false)
const dispatch = useDispatch<Dispatch>()
const deckPopulated = useSelector(getDeckPopulated)

export default connect<Props, OP, SP, {||}, State, Dispatch>(
mapStateToProps,
null,
mergeProps
)(UnprobedPanel)
const moveToFront = () => {
// $FlowFixMe: robotActions.moveToFront is not typed
dispatch(robotActions.moveToFront(mount))
setShowClearDeck(false)
}

function UnprobedPanel(props: Props) {
const { probed, onPrepareClick } = props
const handleStart = () => {
if (deckPopulated === true || deckPopulated === null) {
setShowClearDeck(true)
} else {
moveToFront()
}
}

const message = !probed
? 'Pipette tip is not calibrated'
Expand All @@ -40,37 +42,22 @@ function UnprobedPanel(props: Props) {
const leftChildren = (
<div>
<p>{message}</p>
<PrimaryButton onClick={onPrepareClick}>{buttonText}</PrimaryButton>
<PrimaryButton onClick={handleStart}>{buttonText}</PrimaryButton>
</div>
)

return <CalibrationInfoContent leftChildren={leftChildren} />
}

function mapStateToProps(state, ownProps: OP): SP {
const deckPopulated = robotSelectors.getDeckPopulated(state)

return {
_showContinueModal: deckPopulated === true || deckPopulated === null,
}
}

function mergeProps(stateProps: SP, dispatchProps: DP, ownProps: OP): Props {
const { _showContinueModal } = stateProps
const { dispatch } = dispatchProps
const { mount, confirmTipProbeUrl } = ownProps

const onPrepareClick = _showContinueModal
? () => {
dispatch(push(confirmTipProbeUrl))
}
: () => {
// $FlowFixMe: robotActions.moveToFront is not typed
dispatch(robotActions.moveToFront(mount))
}

return {
...ownProps,
onPrepareClick,
}
return (
<>
<CalibrationInfoContent leftChildren={leftChildren} />
{showClearDeck && (
<ClearDeckAlertModal
continueText={'Move pipette to front'}
cancelText={'Cancel'}
onContinueClick={moveToFront}
onCancelClick={() => setShowClearDeck(false)}
removeTrash
/>
)}
</>
)
}
Loading

0 comments on commit b88c73b

Please sign in to comment.