From e842755b9e43b66b4505d965a9651f0f55fb738a Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 27 Dec 2016 16:05:24 -0300 Subject: [PATCH] Ivan - Add maintenance mode structure [skip ci] --- client/src/app/App.js | 8 ++++++++ client/src/app/Routes.js | 2 ++ client/src/app/main/main-maintenance-page.js | 13 +++++++++++++ client/src/data/fixtures/system-fixtures.js | 1 + client/src/index.js | 2 +- client/src/reducers/config-reducer.js | 6 ++++-- 6 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 client/src/app/main/main-maintenance-page.js diff --git a/client/src/app/App.js b/client/src/app/App.js index 1cbeaf90..23da32fe 100644 --- a/client/src/app/App.js +++ b/client/src/app/App.js @@ -59,6 +59,14 @@ class App extends React.Component { loggedInStaff: !_.includes(props.location.pathname, '/admin/panel') && props.session.logged && props.session.staff, loggedOutStaff: _.includes(props.location.pathname, '/admin/panel') && !props.session.logged }; + + if(props.config['maintenance-mode'] && !_.includes(props.location.pathname, '/admin') && !_.includes(props.location.pathname, '/maintenance')) { + browserHistory.push('/maintenance'); + } + + if(!props.config['maintenance-mode'] && _.includes(props.location.pathname, '/maintenance')) { + browserHistory.push('/'); + } if (validations.languageChanged) { browserHistory.push(props.location.pathname); diff --git a/client/src/app/Routes.js b/client/src/app/Routes.js index 970fc454..bd97b39b 100644 --- a/client/src/app/Routes.js +++ b/client/src/app/Routes.js @@ -11,6 +11,7 @@ import MainLayout from 'app/main/main-layout'; import MainHomePage from 'app/main/main-home/main-home-page'; import MainSignUpPage from 'app/main/main-signup/main-signup-page'; import MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-page'; +import MainMaintenancePage from 'app/main/main-maintenance-page'; import DashboardLayout from 'app/main/dashboard/dashboard-layout'; import DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page'; @@ -59,6 +60,7 @@ export default ( + diff --git a/client/src/app/main/main-maintenance-page.js b/client/src/app/main/main-maintenance-page.js new file mode 100644 index 00000000..bcee3051 --- /dev/null +++ b/client/src/app/main/main-maintenance-page.js @@ -0,0 +1,13 @@ +import React from 'react'; + +class MainMaintenancePage extends React.Component { + render() { + return ( +
+ Maintenance +
+ ); + } +} + +export default MainMaintenancePage; \ No newline at end of file diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 672e964e..ad471c8a 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -8,6 +8,7 @@ module.exports = [ data: { 'language': 'en', 'reCaptchaKey': '6LfM5CYTAAAAAGLz6ctpf-hchX2_l0Ge-Bn-n8wS', + 'maintenance-mode': false, 'departments': [ {id: 1, name: 'Sales Support', owners: 2}, {id: 2, name: 'Technical Issues', owners: 5}, diff --git a/client/src/index.js b/client/src/index.js index 00c95300..2d96694c 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -33,7 +33,7 @@ store.dispatch(SessionActions.initSession()); let unsubscribe = store.subscribe(() => { console.log(store.getState()); - if (store.getState().session.initDone) { + if (store.getState().session.initDone && store.getState().config.initDone) { unsubscribe(); renderApplication(); } diff --git a/client/src/reducers/config-reducer.js b/client/src/reducers/config-reducer.js index 3526bedf..5aee8933 100644 --- a/client/src/reducers/config-reducer.js +++ b/client/src/reducers/config-reducer.js @@ -7,7 +7,8 @@ class ConfigReducer extends Reducer { getInitialState() { return { - language: sessionStore.getItem('language') + language: sessionStore.getItem('language'), + initDone: false }; } @@ -35,7 +36,8 @@ class ConfigReducer extends Reducer { })); return _.extend({}, state, payload.data, { - language: currentLanguage || payload.language + language: currentLanguage || payload.language, + initDone: true }); } }