diff --git a/ui/src/dashboards/containers/DashboardPage.js b/ui/src/dashboards/containers/DashboardPage.js index 261cff7d77..e6ff568323 100644 --- a/ui/src/dashboards/containers/DashboardPage.js +++ b/ui/src/dashboards/containers/DashboardPage.js @@ -10,7 +10,7 @@ import timeRanges from 'hson!../../shared/data/timeRanges.hson'; import {getDashboards} from '../apis'; import {getSource} from 'shared/apis'; -import {delayEnablePresentationMode} from 'shared/actions/ui'; +import {presentationButtonDispatcher} from 'shared/dispatchers' const { shape, @@ -133,9 +133,7 @@ const mapStateToProps = (state) => ({ }) const mapDispatchToProps = (dispatch) => ({ - handleClickPresentationButton: () => { - dispatch(delayEnablePresentationMode()) - }, + handleClickPresentationButton: presentationButtonDispatcher(dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(DashboardPage); diff --git a/ui/src/hosts/containers/HostPage.js b/ui/src/hosts/containers/HostPage.js index 80dd3497c3..e2002d99cd 100644 --- a/ui/src/hosts/containers/HostPage.js +++ b/ui/src/hosts/containers/HostPage.js @@ -9,7 +9,7 @@ import DashboardHeader from 'src/dashboards/components/DashboardHeader'; import timeRanges from 'hson!../../shared/data/timeRanges.hson'; import {getMappings, getAppsForHosts, getMeasurementsForHost, getAllHosts} from 'src/hosts/apis'; import {fetchLayouts} from 'shared/apis'; -import {delayEnablePresentationMode} from 'shared/actions/ui'; +import {presentationButtonDispatcher} from 'shared/dispatchers' const { shape, @@ -186,9 +186,7 @@ const mapStateToProps = (state) => ({ }) const mapDispatchToProps = (dispatch) => ({ - handleClickPresentationButton: () => { - dispatch(delayEnablePresentationMode()) - }, + handleClickPresentationButton: presentationButtonDispatcher(dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(HostPage) diff --git a/ui/src/index.js b/ui/src/index.js index 80fe3f038b..46d88fe691 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -18,7 +18,7 @@ import NotFound from 'src/shared/components/NotFound'; import configureStore from 'src/store/configureStore'; import {getMe, getSources} from 'shared/apis'; import {receiveMe} from 'shared/actions/me'; -import {delayDisablePresentationMode} from 'shared/actions/ui'; +import {disablePresentationMode} from 'shared/actions/ui'; import {loadLocalStorage} from './localStorage'; import 'src/style/chronograf.scss'; diff --git a/ui/src/kubernetes/components/KubernetesDashboard.js b/ui/src/kubernetes/components/KubernetesDashboard.js index 74f2c9d047..bda8906823 100644 --- a/ui/src/kubernetes/components/KubernetesDashboard.js +++ b/ui/src/kubernetes/components/KubernetesDashboard.js @@ -1,8 +1,9 @@ import React, {PropTypes} from 'react'; +import classnames from 'classnames' + import LayoutRenderer from 'shared/components/LayoutRenderer'; import DashboardHeader from 'src/dashboards/components/DashboardHeader'; import timeRanges from 'hson!../../shared/data/timeRanges.hson'; -import classnames from 'classnames' const { shape, diff --git a/ui/src/kubernetes/containers/KubernetesPage.js b/ui/src/kubernetes/containers/KubernetesPage.js index c0c3d5537d..213bc8a06c 100644 --- a/ui/src/kubernetes/containers/KubernetesPage.js +++ b/ui/src/kubernetes/containers/KubernetesPage.js @@ -3,7 +3,7 @@ import {connect} from 'react-redux' import {fetchLayouts} from 'shared/apis'; import KubernetesDashboard from 'src/kubernetes/components/KubernetesDashboard'; -import {delayEnablePresentationMode} from 'shared/actions/ui'; +import {presentationButtonDispatcher} from 'shared/dispatchers' const { shape, @@ -56,9 +56,7 @@ const mapStateToProps = (state) => ({ }) const mapDispatchToProps = (dispatch) => ({ - handleClickPresentationButton: () => { - dispatch(delayEnablePresentationMode()) - }, + handleClickPresentationButton: presentationButtonDispatcher(dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(KubernetesPage); diff --git a/ui/src/shared/actions/notifications.js b/ui/src/shared/actions/notifications.js index 7551e4facf..8e2b419110 100644 --- a/ui/src/shared/actions/notifications.js +++ b/ui/src/shared/actions/notifications.js @@ -17,6 +17,12 @@ export function dismissNotification(type) { }; } +export function delayDismissNotification(type, wait) { + return (dispatch) => { + setTimeout(() => dispatch(dismissNotification(type)), wait) + } +} + export function dismissAllNotifications() { return { type: 'ALL_NOTIFICATIONS_DISMISSED', diff --git a/ui/src/shared/actions/ui.js b/ui/src/shared/actions/ui.js index 2282d9fa98..740566beb9 100644 --- a/ui/src/shared/actions/ui.js +++ b/ui/src/shared/actions/ui.js @@ -1,4 +1,4 @@ -import {PRESENTATION_MODE_DELAY} from '../constants' +import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants' export function enablePresentationMode() { return { @@ -14,6 +14,6 @@ export function disablePresentationMode() { export function delayEnablePresentationMode() { return (dispatch) => { - setTimeout(() => dispatch(enablePresentationMode()), PRESENTATION_MODE_DELAY) + setTimeout(() => dispatch(enablePresentationMode()), PRESENTATION_MODE_ANIMATION_DELAY) } } diff --git a/ui/src/shared/constants/index.js b/ui/src/shared/constants/index.js index 1426be01df..da53f8e2af 100644 --- a/ui/src/shared/constants/index.js +++ b/ui/src/shared/constants/index.js @@ -468,4 +468,5 @@ export const STROKE_WIDTH = { light: 1.5, }; -export const PRESENTATION_MODE_DELAY = 250 // In milliseconds. +export const PRESENTATION_MODE_ANIMATION_DELAY = 250 // In milliseconds. +export const PRESENTATION_MODE_NOTIFICATION_DELAY = 2000 // In milliseconds. diff --git a/ui/src/shared/dispatchers/index.js b/ui/src/shared/dispatchers/index.js new file mode 100644 index 0000000000..fcf02767f9 --- /dev/null +++ b/ui/src/shared/dispatchers/index.js @@ -0,0 +1,9 @@ +import {delayEnablePresentationMode} from 'shared/actions/ui' +import {publishNotification, delayDismissNotification} from 'shared/actions/notifications' +import {PRESENTATION_MODE_NOTIFICATION_DELAY} from 'shared/constants' + +export const presentationButtonDispatcher = (dispatch) => () => { + dispatch(delayEnablePresentationMode()) + dispatch(publishNotification('success', 'Press ESC to disable presentation mode.')) + dispatch(delayDismissNotification('success', PRESENTATION_MODE_NOTIFICATION_DELAY)) +}