Add presentation mode notification to dashboards.

pull/10616/head
Hunter Trujillo 2017-02-16 16:49:23 -07:00
parent a205e8ccce
commit 30ab673267
9 changed files with 28 additions and 17 deletions

View File

@ -10,7 +10,7 @@ import timeRanges from 'hson!../../shared/data/timeRanges.hson';
import {getDashboards} from '../apis'; import {getDashboards} from '../apis';
import {getSource} from 'shared/apis'; import {getSource} from 'shared/apis';
import {delayEnablePresentationMode} from 'shared/actions/ui'; import {presentationButtonDispatcher} from 'shared/dispatchers'
const { const {
shape, shape,
@ -133,9 +133,7 @@ const mapStateToProps = (state) => ({
}) })
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
handleClickPresentationButton: () => { handleClickPresentationButton: presentationButtonDispatcher(dispatch),
dispatch(delayEnablePresentationMode())
},
}) })
export default connect(mapStateToProps, mapDispatchToProps)(DashboardPage); export default connect(mapStateToProps, mapDispatchToProps)(DashboardPage);

View File

@ -9,7 +9,7 @@ import DashboardHeader from 'src/dashboards/components/DashboardHeader';
import timeRanges from 'hson!../../shared/data/timeRanges.hson'; import timeRanges from 'hson!../../shared/data/timeRanges.hson';
import {getMappings, getAppsForHosts, getMeasurementsForHost, getAllHosts} from 'src/hosts/apis'; import {getMappings, getAppsForHosts, getMeasurementsForHost, getAllHosts} from 'src/hosts/apis';
import {fetchLayouts} from 'shared/apis'; import {fetchLayouts} from 'shared/apis';
import {delayEnablePresentationMode} from 'shared/actions/ui'; import {presentationButtonDispatcher} from 'shared/dispatchers'
const { const {
shape, shape,
@ -186,9 +186,7 @@ const mapStateToProps = (state) => ({
}) })
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
handleClickPresentationButton: () => { handleClickPresentationButton: presentationButtonDispatcher(dispatch),
dispatch(delayEnablePresentationMode())
},
}) })
export default connect(mapStateToProps, mapDispatchToProps)(HostPage) export default connect(mapStateToProps, mapDispatchToProps)(HostPage)

View File

@ -18,7 +18,7 @@ import NotFound from 'src/shared/components/NotFound';
import configureStore from 'src/store/configureStore'; import configureStore from 'src/store/configureStore';
import {getMe, getSources} from 'shared/apis'; import {getMe, getSources} from 'shared/apis';
import {receiveMe} from 'shared/actions/me'; import {receiveMe} from 'shared/actions/me';
import {delayDisablePresentationMode} from 'shared/actions/ui'; import {disablePresentationMode} from 'shared/actions/ui';
import {loadLocalStorage} from './localStorage'; import {loadLocalStorage} from './localStorage';
import 'src/style/chronograf.scss'; import 'src/style/chronograf.scss';

View File

@ -1,8 +1,9 @@
import React, {PropTypes} from 'react'; import React, {PropTypes} from 'react';
import classnames from 'classnames'
import LayoutRenderer from 'shared/components/LayoutRenderer'; import LayoutRenderer from 'shared/components/LayoutRenderer';
import DashboardHeader from 'src/dashboards/components/DashboardHeader'; import DashboardHeader from 'src/dashboards/components/DashboardHeader';
import timeRanges from 'hson!../../shared/data/timeRanges.hson'; import timeRanges from 'hson!../../shared/data/timeRanges.hson';
import classnames from 'classnames'
const { const {
shape, shape,

View File

@ -3,7 +3,7 @@ import {connect} from 'react-redux'
import {fetchLayouts} from 'shared/apis'; import {fetchLayouts} from 'shared/apis';
import KubernetesDashboard from 'src/kubernetes/components/KubernetesDashboard'; import KubernetesDashboard from 'src/kubernetes/components/KubernetesDashboard';
import {delayEnablePresentationMode} from 'shared/actions/ui'; import {presentationButtonDispatcher} from 'shared/dispatchers'
const { const {
shape, shape,
@ -56,9 +56,7 @@ const mapStateToProps = (state) => ({
}) })
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
handleClickPresentationButton: () => { handleClickPresentationButton: presentationButtonDispatcher(dispatch),
dispatch(delayEnablePresentationMode())
},
}) })
export default connect(mapStateToProps, mapDispatchToProps)(KubernetesPage); export default connect(mapStateToProps, mapDispatchToProps)(KubernetesPage);

View File

@ -17,6 +17,12 @@ export function dismissNotification(type) {
}; };
} }
export function delayDismissNotification(type, wait) {
return (dispatch) => {
setTimeout(() => dispatch(dismissNotification(type)), wait)
}
}
export function dismissAllNotifications() { export function dismissAllNotifications() {
return { return {
type: 'ALL_NOTIFICATIONS_DISMISSED', type: 'ALL_NOTIFICATIONS_DISMISSED',

View File

@ -1,4 +1,4 @@
import {PRESENTATION_MODE_DELAY} from '../constants' import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants'
export function enablePresentationMode() { export function enablePresentationMode() {
return { return {
@ -14,6 +14,6 @@ export function disablePresentationMode() {
export function delayEnablePresentationMode() { export function delayEnablePresentationMode() {
return (dispatch) => { return (dispatch) => {
setTimeout(() => dispatch(enablePresentationMode()), PRESENTATION_MODE_DELAY) setTimeout(() => dispatch(enablePresentationMode()), PRESENTATION_MODE_ANIMATION_DELAY)
} }
} }

View File

@ -468,4 +468,5 @@ export const STROKE_WIDTH = {
light: 1.5, 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.

View File

@ -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))
}