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(app): Show connect alert banner on successful connection #1700

Merged
merged 2 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions app/src/components/RobotSettings/ConnectBanner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @flow
import * as React from 'react'
import {type Robot} from '../../robot'
import {AlertItem} from '@opentrons/components'

type State = {
dismissed: boolean
}

export default class ConnectBanner extends React.Component <Robot, State> {
constructor (props: Robot) {
super(props)

this.state = {
dismissed: false
}
}

render () {
const {isConnected, name} = this.props
const isVisible = isConnected && !this.state.dismissed
const TITLE = `${name} successfully connected`
return (
<div>
{isVisible && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also do an early null return if !isVisible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i like that. will change in a bit

<AlertItem
type='success'
onCloseClick={() => this.setState({dismissed: true})}
title={TITLE} />
)}
</div>
)
}
}
2 changes: 2 additions & 0 deletions app/src/pages/Robots.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Page from '../components/Page'
import RobotSettings, {ConnectAlertModal} from '../components/RobotSettings'
import ChangePipette from '../components/ChangePipette'
import CalibrateDeck from '../components/CalibrateDeck'
import ConnectBanner from '../components/RobotSettings/ConnectBanner'

type StateProps = {
robot: ?Robot,
Expand Down Expand Up @@ -58,6 +59,7 @@ function RobotSettingsPage (props: Props) {
return (
<Page>
<TitleBar title={robot.name} />
<ConnectBanner {...robot} key={Number(robot.isConnected)}/>
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of Number here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flow was expected number or string not a bool

<RobotSettings {...robot} />

<Route path={`${path}/pipettes`} render={(props) => (
Expand Down