-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add robot restart alert for FF changes that require restart (
#4285) * feat(app): add robot restart alert for FF changes that require restart * fixup: Defer to API for restart required state
- Loading branch information
Showing
26 changed files
with
664 additions
and
85 deletions.
There are no files selected for viewing
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
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
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,47 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import { useDispatch } from 'react-redux' | ||
import { AlertItem, OutlineButton } from '@opentrons/components' | ||
|
||
import { restartRobot } from '../../robot-admin' | ||
import styles from './styles.css' | ||
|
||
import type { Dispatch } from '../../types' | ||
import type { RobotHost } from '../../robot-api/types' | ||
|
||
export type RestartRequiredBannerProps = {| | ||
robot: RobotHost, | ||
|} | ||
|
||
// TODO(mc, 2019-10-24): i18n | ||
const TITLE = 'Robot restart required' | ||
const MESSAGE = | ||
'You must restart your robot for your settings changes to take effect' | ||
const RESTART_NOW = 'Restart Now' | ||
|
||
function RestartRequiredBanner(props: RestartRequiredBannerProps) { | ||
const { robot } = props | ||
const [dismissed, setDismissed] = React.useState(false) | ||
const dispatch = useDispatch<Dispatch>() | ||
const restart = React.useCallback(() => dispatch(restartRobot(robot)), [ | ||
dispatch, | ||
robot, | ||
]) | ||
|
||
if (dismissed) return null | ||
|
||
return ( | ||
<AlertItem | ||
type="warning" | ||
onCloseClick={() => setDismissed(true)} | ||
title={TITLE} | ||
> | ||
<div className={styles.restart_banner_message}> | ||
<p>{MESSAGE}</p> | ||
<OutlineButton onClick={restart}>{RESTART_NOW}</OutlineButton> | ||
</div> | ||
</AlertItem> | ||
) | ||
} | ||
|
||
export default RestartRequiredBanner |
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
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
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
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
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
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
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
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
Oops, something went wrong.