diff --git a/app/src/components/RobotSettings/UpdateRobot/RestartRobotModal.js b/app/src/components/RobotSettings/UpdateRobot/RestartRobotModal.js new file mode 100644 index 00000000000..802541e0713 --- /dev/null +++ b/app/src/components/RobotSettings/UpdateRobot/RestartRobotModal.js @@ -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, ...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 ( + + Restart your robot to finish the update. It may take several minutes for + your robot to restart. + + ) +} + +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) + }, + } +} diff --git a/app/src/components/RobotSettings/UpdateRobotModal/SkipAppUpdateMessage.js b/app/src/components/RobotSettings/UpdateRobot/SkipAppUpdateMessage.js similarity index 100% rename from app/src/components/RobotSettings/UpdateRobotModal/SkipAppUpdateMessage.js rename to app/src/components/RobotSettings/UpdateRobot/SkipAppUpdateMessage.js diff --git a/app/src/components/RobotSettings/UpdateRobotModal/SyncRobotMessage.js b/app/src/components/RobotSettings/UpdateRobot/SyncRobotMessage.js similarity index 100% rename from app/src/components/RobotSettings/UpdateRobotModal/SyncRobotMessage.js rename to app/src/components/RobotSettings/UpdateRobot/SyncRobotMessage.js diff --git a/app/src/components/RobotSettings/UpdateRobotModal/UpdateAppMessage.js b/app/src/components/RobotSettings/UpdateRobot/UpdateAppMessage.js similarity index 100% rename from app/src/components/RobotSettings/UpdateRobotModal/UpdateAppMessage.js rename to app/src/components/RobotSettings/UpdateRobot/UpdateAppMessage.js diff --git a/app/src/components/RobotSettings/UpdateRobotModal/index.js b/app/src/components/RobotSettings/UpdateRobot/UpdateRobotModal.js similarity index 97% rename from app/src/components/RobotSettings/UpdateRobotModal/index.js rename to app/src/components/RobotSettings/UpdateRobot/UpdateRobotModal.js index 159a4d7aafe..9ed9f9b15e8 100644 --- a/app/src/components/RobotSettings/UpdateRobotModal/index.js +++ b/app/src/components/RobotSettings/UpdateRobot/UpdateRobotModal.js @@ -72,6 +72,7 @@ class UpdateRobotModal extends React.Component { render () { const { + update, ignoreUpdate, appVersion, robotVersion, @@ -95,7 +96,7 @@ class UpdateRobotModal extends React.Component { if (showReleaseNotes) { button = { children: 'Upgrade Robot', - onClick: () => console.log('install'), + onClick: update, } } else if (appUpdateAvailable) { message = @@ -122,14 +123,14 @@ class UpdateRobotModal extends React.Component { } else if (robotUpdateInfo.type === 'downgrade') { button = { children: 'Downgrade Robot', - onClick: () => console.log('install'), + onClick: update, } } } else { message = button = { children: 'Reinstall', - onClick: () => console.log('install'), + onClick: update, } } diff --git a/app/src/components/RobotSettings/UpdateRobotModal/VersionList.js b/app/src/components/RobotSettings/UpdateRobot/VersionList.js similarity index 100% rename from app/src/components/RobotSettings/UpdateRobotModal/VersionList.js rename to app/src/components/RobotSettings/UpdateRobot/VersionList.js diff --git a/app/src/components/RobotSettings/UpdateRobot/index.js b/app/src/components/RobotSettings/UpdateRobot/index.js new file mode 100644 index 00000000000..d1ec3baab3a --- /dev/null +++ b/app/src/components/RobotSettings/UpdateRobot/index.js @@ -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, + ...SP, +} + +export default connect( + makeMapStateToProps, + null +)(UpdateRobot) + +function UpdateRobot (props: Props) { + const {updateRequest, robot} = props + if (updateRequest.response) { + return + } + if (updateRequest.inProgress) { + // TODO (ka 2018-11-27): Clarify update message with UX + return + } else { + return + } +} + +function makeMapStateToProps (): (State, OP) => Props { + const getRobotUpdateRequest = makeGetRobotUpdateRequest() + + return (state, ownProps) => { + const {robot} = ownProps + return { + robot, + updateRequest: getRobotUpdateRequest(state, ownProps.robot), + } + } +} diff --git a/app/src/components/RobotSettings/UpdateRobotModal/styles.css b/app/src/components/RobotSettings/UpdateRobot/styles.css similarity index 100% rename from app/src/components/RobotSettings/UpdateRobotModal/styles.css rename to app/src/components/RobotSettings/UpdateRobot/styles.css diff --git a/app/src/components/RobotSettings/UpdateRobotModal/types.js b/app/src/components/RobotSettings/UpdateRobot/types.js similarity index 100% rename from app/src/components/RobotSettings/UpdateRobotModal/types.js rename to app/src/components/RobotSettings/UpdateRobot/types.js diff --git a/app/src/pages/Robots/RobotSettings.js b/app/src/pages/Robots/RobotSettings.js index c1bca7e2ece..93eab476164 100644 --- a/app/src/pages/Robots/RobotSettings.js +++ b/app/src/pages/Robots/RobotSettings.js @@ -23,7 +23,7 @@ import RobotSettings, { ConnectAlertModal, RobotUpdateModal, } from '../../components/RobotSettings' -import UpdateRobotModal from '../../components/RobotSettings/UpdateRobotModal' +import UpdateRobot from '../../components/RobotSettings/UpdateRobot' import CalibrateDeck from '../../components/CalibrateDeck' import ConnectBanner from '../../components/RobotSettings/ConnectBanner' import ReachableRobotBanner from '../../components/RobotSettings/ReachableRobotBanner' @@ -108,7 +108,7 @@ function RobotSettingsPage (props: Props) { path={`${path}/${UPDATE_FRAGMENT}`} render={() => { if (props.__featureEnabled) { - return + return } else { return }