-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): Add update in progress and restart screens (#2728)
- Loading branch information
Showing
10 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
app/src/components/RobotSettings/UpdateRobot/RestartRobotModal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import {connect} from 'react-redux' | ||
import {push} from 'react-router-redux' | ||
|
||
import {restartRobotServer, clearUpdateResponse} from '../../../http-api-client' | ||
import {AlertModal} from '@opentrons/components' | ||
|
||
import type {Dispatch} from '../../../types' | ||
import type {ViewableRobot} from '../../../discovery' | ||
|
||
type OP = {robot: ViewableRobot} | ||
|
||
type DP = {| | ||
restart: () => mixed, | ||
close: () => mixed, | ||
|} | ||
|
||
type Props = {...$Exact<OP>, ...DP} | ||
|
||
export default connect( | ||
null, | ||
mapDispatchToProps | ||
)(RestartRobotModal) | ||
|
||
// TODO (ka 2018-11-27): Clarify heading and messaging with UX | ||
const RESTART_HEADING = 'Update installed' | ||
|
||
function RestartRobotModal (props: Props) { | ||
return ( | ||
<AlertModal | ||
heading={RESTART_HEADING} | ||
buttons={[ | ||
{onClick: props.close, children: 'not now'}, | ||
{onClick: props.restart, children: 'restart'}, | ||
]} | ||
alertOverlay | ||
> | ||
Restart your robot to finish the update. It may take several minutes for | ||
your robot to restart. | ||
</AlertModal> | ||
) | ||
} | ||
|
||
function mapDispatchToProps (dispatch: Dispatch, ownProps: OP): DP { | ||
const {robot} = ownProps | ||
|
||
const close = () => dispatch(push(`/robots/${robot.name}`)) | ||
|
||
return { | ||
close, | ||
restart: () => { | ||
dispatch(restartRobotServer(robot)) | ||
.then(() => dispatch(clearUpdateResponse(robot))) | ||
.then(close) | ||
}, | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import {connect} from 'react-redux' | ||
|
||
import {makeGetRobotUpdateRequest} from '../../../http-api-client' | ||
|
||
import {SpinnerModal} from '@opentrons/components' | ||
import UpdateRobotModal from './UpdateRobotModal' | ||
import RestartRobotModal from './RestartRobotModal' | ||
|
||
import type {State} from '../../../types' | ||
import type {ViewableRobot} from '../../../discovery' | ||
import type {RobotServerUpdate} from '../../../http-api-client' | ||
|
||
type OP = {robot: ViewableRobot} | ||
|
||
type SP = {| | ||
updateRequest: RobotServerUpdate, | ||
|} | ||
|
||
type Props = { | ||
...$Exact<OP>, | ||
...SP, | ||
} | ||
|
||
export default connect( | ||
makeMapStateToProps, | ||
null | ||
)(UpdateRobot) | ||
|
||
function UpdateRobot (props: Props) { | ||
const {updateRequest, robot} = props | ||
if (updateRequest.response) { | ||
return <RestartRobotModal robot={robot} /> | ||
} | ||
if (updateRequest.inProgress) { | ||
// TODO (ka 2018-11-27): Clarify update message with UX | ||
return <SpinnerModal message="Robot is updating" alertOverlay /> | ||
} else { | ||
return <UpdateRobotModal robot={robot} /> | ||
} | ||
} | ||
|
||
function makeMapStateToProps (): (State, OP) => Props { | ||
const getRobotUpdateRequest = makeGetRobotUpdateRequest() | ||
|
||
return (state, ownProps) => { | ||
const {robot} = ownProps | ||
return { | ||
robot, | ||
updateRequest: getRobotUpdateRequest(state, ownProps.robot), | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters