Remove single store documentation and settings manager

This commit is contained in:
soupette 2019-02-11 14:57:20 +01:00
parent 835a26e8c3
commit 46e13f71c6
12 changed files with 66 additions and 104 deletions

View File

@ -1,5 +0,0 @@
/*
*
* App actions
*
*/

View File

@ -1,5 +0,0 @@
/*
*
* App constants
*
*/

View File

@ -6,41 +6,22 @@
*/
import React from 'react';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { Switch, Route } from 'react-router-dom';
import { bindActionCreators, compose } from 'redux';
// Utils
import { pluginId } from 'app';
// Containers
import HomePage from 'containers/HomePage';
import NotFoundPage from 'containers/NotFoundPage';
class App extends React.Component {
render() {
return (
<div className={pluginId}>
<Switch>
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
<Route component={NotFoundPage} />
</Switch>
</div>
);
}
function App() {
return (
<div className={pluginId}>
<Switch>
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
<Route component={NotFoundPage} />
</Switch>
</div>
);
}
App.propTypes = {};
export function mapDispatchToProps(dispatch) {
return bindActionCreators({}, dispatch);
}
const mapStateToProps = createStructuredSelector({});
// Wrap the component to inject dispatch and state into it
const withConnect = connect(
mapStateToProps,
mapDispatchToProps,
);
export default compose(withConnect)(App);
export default App;

View File

@ -1,18 +0,0 @@
/*
*
* App reducer
*
*/
import { fromJS } from 'immutable';
const initialState = fromJS({});
function appReducer(state = initialState, action) {
switch (action.type) {
default:
return state;
}
}
export default appReducer;

View File

@ -1,9 +0,0 @@
// import { createSelector } from 'reselect';
/**
* Direct selector to the list state domain
*/
// const selectGlobalDomain = () => state => state.get('global');
export {};

View File

@ -22,8 +22,6 @@ import Input from 'components/InputsIndex';
import { pluginId } from 'app';
// Utils
import auth from 'utils/auth';
import injectReducer from 'utils/injectReducer';
import injectSaga from 'utils/injectSaga';
import openWithNewTab from 'utils/openWithNewTab';
// Actions
import {
@ -245,8 +243,8 @@ const withConnect = connect(
mapStateToProps,
mapDispatchToProps,
);
const withReducer = injectReducer({ key: 'homePage', reducer });
const withSaga = injectSaga({ key: 'homePage', saga });
const withReducer = strapi.injectReducer({ key: 'homePage', reducer, pluginId: 'documentation' });
const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId: 'documentation' });
export default compose(
withReducer,

View File

@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
/**
* Direct selector to the homePage state domain
*/
const selectHomePageDomain = () => state => state.get('homePage');
const selectHomePageDomain = () => state => state.get('documentation-homePage');
/**
* Default selector used by HomePage
@ -30,4 +30,4 @@ const makeSelectVersionToDelete = () => createSelector(
);
export default selectHomePage;
export { makeSelectForm, makeSelectVersionToDelete, makeSelectPrefix };
export { makeSelectForm, makeSelectVersionToDelete, makeSelectPrefix };

View File

@ -16,14 +16,13 @@ import { Switch, Route } from 'react-router-dom';
import { isEmpty } from 'lodash';
import { pluginId } from 'app';
import injectSaga from 'utils/injectSaga';
import HomePage from 'containers/HomePage';
import { menuFetch, environmentsFetch } from './actions';
import { makeSelectLoading, makeSelectSections } from './selectors';
import styles from './styles.scss';
import reducer from './reducer';
import saga from './sagas';
/* eslint-disable react/require-default-props */
@ -95,9 +94,11 @@ const mapStateToProps = createStructuredSelector({
// Wrap the component to inject dispatch and state into it
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withSaga = injectSaga({ key: 'global', saga });
const withReducer = strapi.injectReducer({ key: 'global', reducer, pluginId: 'settings-manager' });
const withSaga = strapi.injectSaga({ key: 'global', saga, pluginId: 'settings-manager' });
export default compose(
withReducer,
withSaga,
withConnect,
)(App);

View File

@ -4,7 +4,7 @@ import { createSelector } from 'reselect';
* Direct selector to the list state domain
*/
const selectGlobalDomain = () => state => state.get('global');
const selectGlobalDomain = () => state => state.get('settings-manager-global');
const selectLocationState = () => {
let prevRoutingState;

View File

@ -45,8 +45,6 @@ import { makeSelectSections, makeSelectEnvironments } from 'containers/App/selec
// utils
import unknowFlag from 'assets/images/unknow_flag.png';
import injectReducer from 'utils/injectReducer';
import injectSaga from 'utils/injectSaga';
import supportedFlags from 'utils/supportedFlags.json';
import { checkFormValidity, getRequiredInputsDb } from '../../utils/inputValidations';
import getFlag, { formatLanguageLocale } from '../../utils/getFlag';
@ -564,8 +562,8 @@ HomePage.propTypes = {
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withReducer = injectReducer({ key: 'homePage', reducer });
const withSaga = injectSaga({ key: 'homePage', saga });
const withReducer = strapi.injectReducer({ key: 'homePage', reducer, pluginId: 'settings-manager' });
const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId: 'settings-manager' });
export default compose(
withReducer,

View File

@ -1,6 +1,15 @@
import { LOCATION_CHANGE } from 'react-router-redux';
// import { LOCATION_CHANGE } from 'react-router-redux';
import { forEach, set, map, replace } from 'lodash';
import { all, call, take, put, fork, cancel, select, takeLatest } from 'redux-saga/effects';
import {
all,
call,
// take,
put,
fork,
// cancel,
select,
takeLatest,
} from 'redux-saga/effects';
import request from 'utils/request';
// selectors
import { makeSelectModifiedData } from './selectors';
@ -240,28 +249,40 @@ export function* fetchSpecificDatabase(action) {
// Individual exports for testing
export function* defaultSaga() {
const loadConfigWatcher = yield fork(takeLatest, CONFIG_FETCH, fetchConfig);
const loadLanguagesWatcher = yield fork(takeLatest, LANGUAGES_FETCH, fetchLanguages);
const editConfigWatcher = yield fork(takeLatest, EDIT_SETTINGS, settingsEdit);
const postLanguageWatcher = yield fork(takeLatest, NEW_LANGUAGE_POST, postLanguage);
const deleteLanguageWatcher = yield fork(takeLatest, LANGUAGE_DELETE, deleteLanguage);
const loadDatabasesWatcher = yield fork(takeLatest, DATABASES_FETCH, fetchDatabases);
const postDatabaseWatcher = yield fork(takeLatest, NEW_DATABASE_POST, postDatabase);
const deleteDatabaseWatcher = yield fork(takeLatest, DATABASE_DELETE, deleteDatabase);
const fetchSpecificDatabaseWatcher = yield fork(takeLatest, SPECIFIC_DATABASE_FETCH, fetchSpecificDatabase);
const editDatabaseWatcher = yield fork(takeLatest, DATABASE_EDIT, editDatabase);
yield fork(takeLatest, CONFIG_FETCH, fetchConfig);
yield fork(takeLatest, LANGUAGES_FETCH, fetchLanguages);
yield fork(takeLatest, EDIT_SETTINGS, settingsEdit);
yield fork(takeLatest, NEW_LANGUAGE_POST, postLanguage);
yield fork(takeLatest, LANGUAGE_DELETE, deleteLanguage);
yield fork(takeLatest, DATABASES_FETCH, fetchDatabases);
yield fork(takeLatest, NEW_DATABASE_POST, postDatabase);
yield fork(takeLatest, DATABASE_DELETE, deleteDatabase);
yield fork(takeLatest, SPECIFIC_DATABASE_FETCH, fetchSpecificDatabase);
yield fork(takeLatest, DATABASE_EDIT, editDatabase);
yield take(LOCATION_CHANGE);
yield cancel(loadConfigWatcher);
yield cancel(loadLanguagesWatcher);
yield cancel(editConfigWatcher);
yield cancel(postLanguageWatcher);
yield cancel(deleteLanguageWatcher);
yield cancel(loadDatabasesWatcher);
yield cancel(postDatabaseWatcher);
yield cancel(deleteDatabaseWatcher);
yield cancel(fetchSpecificDatabaseWatcher);
yield cancel(editDatabaseWatcher);
// TODO Fix router (Other PR)
// const loadConfigWatcher = yield fork(takeLatest, CONFIG_FETCH, fetchConfig);
// const loadLanguagesWatcher = yield fork(takeLatest, LANGUAGES_FETCH, fetchLanguages);
// const editConfigWatcher = yield fork(takeLatest, EDIT_SETTINGS, settingsEdit);
// const postLanguageWatcher = yield fork(takeLatest, NEW_LANGUAGE_POST, postLanguage);
// const deleteLanguageWatcher = yield fork(takeLatest, LANGUAGE_DELETE, deleteLanguage);
// const loadDatabasesWatcher = yield fork(takeLatest, DATABASES_FETCH, fetchDatabases);
// const postDatabaseWatcher = yield fork(takeLatest, NEW_DATABASE_POST, postDatabase);
// const deleteDatabaseWatcher = yield fork(takeLatest, DATABASE_DELETE, deleteDatabase);
// const fetchSpecificDatabaseWatcher = yield fork(takeLatest, SPECIFIC_DATABASE_FETCH, fetchSpecificDatabase);
// const editDatabaseWatcher = yield fork(takeLatest, DATABASE_EDIT, editDatabase);
// yield take(LOCATION_CHANGE);
// yield cancel(loadConfigWatcher);
// yield cancel(loadLanguagesWatcher);
// yield cancel(editConfigWatcher);
// yield cancel(postLanguageWatcher);
// yield cancel(deleteLanguageWatcher);
// yield cancel(loadDatabasesWatcher);
// yield cancel(postDatabaseWatcher);
// yield cancel(deleteDatabaseWatcher);
// yield cancel(fetchSpecificDatabaseWatcher);
// yield cancel(editDatabaseWatcher);
}
// All sagas to be loaded

View File

@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
/**
* Direct selector to the home state domain
*/
const selectHomePageDomain = () => state => state.get('homePage');
const selectHomePageDomain = () => state => state.get('settings-manager-homePage');
/**
* Other specific selectors