From 765d9a06acb56618d7ab4aaba2cbf5c6f27dead2 Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Thu, 23 May 2019 16:22:46 +0200 Subject: [PATCH] Fixed contrast mode in the URL. --- client/app/scripts/actions/app-actions.js | 3 ++- client/app/scripts/components/footer.js | 11 ++--------- client/app/scripts/reducers/root.js | 3 +++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 48b2aaa61..0587ca8b6 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -699,11 +699,12 @@ export function receiveNotFound(nodeId, requestTimestamp) { } export function setContrastMode(enabled) { - return (dispatch) => { + return (dispatch, getState) => { dispatch({ enabled, type: ActionTypes.TOGGLE_CONTRAST_MODE, }); + updateRoute(getState); }; } diff --git a/client/app/scripts/components/footer.js b/client/app/scripts/components/footer.js index f3f3f028a..bbac932fd 100644 --- a/client/app/scripts/components/footer.js +++ b/client/app/scripts/components/footer.js @@ -13,19 +13,12 @@ import { class Footer extends React.Component { - constructor(props, context) { - super(props, context); - - this.handleContrastClick = this.handleContrastClick.bind(this); - this.handleRelayoutClick = this.handleRelayoutClick.bind(this); - } - - handleContrastClick(ev) { + handleContrastClick = (ev) => { ev.preventDefault(); this.props.setContrastMode(!this.props.contrastMode); } - handleRelayoutClick(ev) { + handleRelayoutClick = (ev) => { ev.preventDefault(); trackAnalyticsEvent('scope.layout.refresh.click', { layout: this.props.topologyViewMode, diff --git a/client/app/scripts/reducers/root.js b/client/app/scripts/reducers/root.js index a69ddc7f2..9ebebae6f 100644 --- a/client/app/scripts/reducers/root.js +++ b/client/app/scripts/reducers/root.js @@ -692,6 +692,9 @@ export function rootReducer(state = initialState, action) { if (action.state.gridSortedDesc !== undefined) { state = state.set('gridSortedDesc', action.state.gridSortedDesc); } + if (action.state.contrastMode !== undefined) { + state = state.set('contrastMode', action.state.contrastMode); + } if (action.state.showingNetworks) { state = state.set('showingNetworks', action.state.showingNetworks); }