Skip to content

Commit

Permalink
feat(app): Communicate upgrades and downgrades more clearly
Browse files Browse the repository at this point in the history
closes #2354
  • Loading branch information
Kadee80 committed Sep 27, 2018
1 parent 9021247 commit cd3971f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/src/components/RobotSettings/InformationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
makeGetRobotUpdateInfo,
} from '../../http-api-client'

import {
checkShellUpdate,
} from '../../shell'

import {RefreshCard, LabeledValue, OutlineButton} from '@opentrons/components'
import {CardContentQuarter} from '../layout'

Expand All @@ -28,6 +32,7 @@ type StateProps = {

type DispatchProps = {
fetchHealth: () => mixed,
checkAppUpdate: () => mixed,
}

type Props = OwnProps & StateProps & DispatchProps
Expand All @@ -45,6 +50,7 @@ function InformationCard (props: Props) {
updateInfo,
fetchHealth,
updateUrl,
checkAppUpdate,
healthRequest: {inProgress, response: health},
} = props

Expand Down Expand Up @@ -82,6 +88,7 @@ function InformationCard (props: Props) {
<OutlineButton
Component={Link}
to={updateUrl}
onClick={checkAppUpdate}
>
{updateText}
</OutlineButton>
Expand All @@ -106,5 +113,6 @@ function mapDispatchToProps (
): DispatchProps {
return {
fetchHealth: () => dispatch(fetchHealthAndIgnored(ownProps)),
checkAppUpdate: () => dispatch(checkShellUpdate()),
}
}
11 changes: 11 additions & 0 deletions app/src/components/RobotSettings/UpdateAppMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @flow
import * as React from 'react'
import {Link} from 'react-router-dom'

export default function UpdateAppMessage () {
return (
<p>
There is an app update available. Please <Link to={'/menu/app/update'}>update your app</Link> to receive the latest robot updates.
</p>
)
}
22 changes: 20 additions & 2 deletions app/src/components/RobotSettings/UpdateModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ import {
setIgnoredUpdate,
} from '../../http-api-client'

import {
getShellUpdateState,
} from '../../shell'

import type {ShellUpdateState} from '../../shell'

import {AlertModal, Icon} from '@opentrons/components'
import UpdateAppMessage from './UpdateAppMessage'

type OP = Robot

type SP = {
appUpdate: ShellUpdateState,
updateInfo: RobotUpdateInfo,
updateRequest: RobotServerUpdate,
restartRequest: RobotServerRestart,
Expand All @@ -45,7 +53,15 @@ const Spinner = () => (<Icon name='ot-spinner' height='1em' spin />)
export default connect(makeMapStateToProps, null, mergeProps)(UpdateModal)

function UpdateModal (props: Props) {
const {updateInfo, ignoreUpdate, update, restart, updateRequest, restartRequest} = props
const {
updateInfo,
ignoreUpdate,
update,
restart,
updateRequest,
restartRequest,
appUpdate: {available},
} = props
const inProgress = updateRequest.inProgress || restartRequest.inProgress
let closeButtonText = 'not now'
let message
Expand Down Expand Up @@ -87,7 +103,8 @@ function UpdateModal (props: Props) {
]}
alertOverlay
>
{message}
{available && <UpdateAppMessage />}
<p>{message}</p>
</AlertModal>
)
}
Expand All @@ -98,6 +115,7 @@ function makeMapStateToProps (): (State, OP) => SP {
const getRobotRestartRequest = makeGetRobotRestartRequest()

return (state, ownProps) => ({
appUpdate: getShellUpdateState(state),
updateInfo: getRobotUpdateInfo(state, ownProps),
updateRequest: getRobotUpdateRequest(state, ownProps),
restartRequest: getRobotRestartRequest(state, ownProps),
Expand Down

0 comments on commit cd3971f

Please sign in to comment.