Skip to content

Commit

Permalink
refactor(app): Remove "new" aspiration function opt-out pop-up (#3724)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Jul 15, 2019
1 parent 1e72261 commit ca58301
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 189 deletions.
136 changes: 44 additions & 92 deletions app/src/components/RobotSettings/AdvancedSettingsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import * as React from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import reduce from 'lodash/reduce'

import {
fetchSettings,
Expand All @@ -16,12 +15,10 @@ import { CONNECTABLE } from '../../discovery'
import { downloadLogs } from '../../shell'
import { RefreshCard } from '@opentrons/components'
import { LabeledButton, LabeledToggle } from '../controls'
import PipetteUpdateWarningModal from './PipetteUpdateWarningModal'

import type { State, Dispatch } from '../../types'
import type { ViewableRobot } from '../../discovery'
import type { RobotSettings } from '../../robot-api'
import type { ToggleRef } from './PipetteUpdateWarningModal'
import UploadRobotUpdate from './UploadRobotUpdate'

type OP = {|
Expand All @@ -31,7 +28,6 @@ type OP = {|

type SP = {|
settings: RobotSettings,
showPipetteUpdateWarning: boolean,
__buildRootEnabled: boolean,
|}

Expand All @@ -41,19 +37,17 @@ type DP = {|
download: () => mixed,
|}

type Props = { ...OP, ...SP, ...DP }
type Props = {| ...OP, ...SP, ...DP |}

type BooleanSettingProps = {
type BooleanSettingProps = {|
id: string,
title: string,
description: string,
value: boolean | null,
set: (id: string, value: boolean) => mixed,
toggleRef?: ToggleRef,
}
|}

const TITLE = 'Advanced Settings'
const PIPETTE_UPDATE_OPT_OUT_ID = 'useOldAspirationFunctions'

class BooleanSettingToggle extends React.Component<BooleanSettingProps> {
toggle = value => this.props.set(this.props.id, !this.props.value)
Expand All @@ -65,103 +59,61 @@ class BooleanSettingToggle extends React.Component<BooleanSettingProps> {
onClick={this.toggle}
toggledOn={this.props.value === true}
>
<p ref={this.props.toggleRef}>{this.props.description}</p>
<p>{this.props.description}</p>
</LabeledToggle>
)
}
}

class AdvancedSettingsCard extends React.Component<Props> {
pipetteUpdateOptOutRef: ToggleRef

constructor(props: Props) {
super(props)
this.pipetteUpdateOptOutRef = React.createRef()
}

render() {
const {
robot,
settings,
set,
fetch,
download,
resetUrl,
showPipetteUpdateWarning,
} = this.props
const { name, health, status } = robot
const disabled = status !== CONNECTABLE
const logsAvailable = health && health.logs

return (
<RefreshCard
watch={name}
refresh={fetch}
title={TITLE}
disabled={disabled}
column
function AdvancedSettingsCard(props: Props) {
const { robot, settings, set, fetch, download, resetUrl } = props
const { name, health, status } = robot
const disabled = status !== CONNECTABLE
const logsAvailable = health && health.logs

return (
<RefreshCard
watch={name}
refresh={fetch}
title={TITLE}
disabled={disabled}
column
>
<LabeledButton
label="Download Logs"
buttonProps={{
disabled: disabled || !logsAvailable,
onClick: download,
children: 'Download',
}}
>
<LabeledButton
label="Download Logs"
buttonProps={{
disabled: disabled || !logsAvailable,
onClick: download,
children: 'Download',
}}
>
<p>Access logs from this robot.</p>
</LabeledButton>
<LabeledButton
label="Factory Reset"
buttonProps={{
disabled,
Component: Link,
to: resetUrl,
children: 'Reset',
}}
>
<p>Restore robot to factory configuration</p>
</LabeledButton>
{showPipetteUpdateWarning && (
<PipetteUpdateWarningModal
id={PIPETTE_UPDATE_OPT_OUT_ID}
set={set}
toggleRef={this.pipetteUpdateOptOutRef}
/>
)}
{settings.map(s => (
<BooleanSettingToggle
{...s}
key={s.id}
set={set}
toggleRef={
s.id === PIPETTE_UPDATE_OPT_OUT_ID
? this.pipetteUpdateOptOutRef
: undefined
}
/>
))}
{this.props.__buildRootEnabled && <UploadRobotUpdate />}
</RefreshCard>
)
}
<p>Access logs from this robot.</p>
</LabeledButton>
<LabeledButton
label="Factory Reset"
buttonProps={{
disabled,
Component: Link,
to: resetUrl,
children: 'Reset',
}}
>
<p>Restore robot to factory configuration</p>
</LabeledButton>
{settings.map(s => (
<BooleanSettingToggle {...s} key={s.id} set={set} />
))}
{props.__buildRootEnabled && <UploadRobotUpdate />}
</RefreshCard>
)
}

function mapStateToProps(state: State, ownProps: OP): SP {
const { robot } = ownProps
const settings = getRobotSettingsState(state, robot.name)
const pipetteUpdateOptedOut = reduce(
settings,
(result, setting) => {
if (setting.id === PIPETTE_UPDATE_OPT_OUT_ID) return setting.value
return result
},
false
)

return {
settings: settings,
showPipetteUpdateWarning: pipetteUpdateOptedOut === null,
__buildRootEnabled: Boolean(getConfig(state).devInternal?.enableBuildRoot),
}
}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit ca58301

Please sign in to comment.