Fix content-type creation bug in content-manager

This commit is contained in:
cyril lopez 2017-10-17 11:37:34 +02:00
parent 3c9434c024
commit be5f28260b
4 changed files with 22 additions and 3 deletions

View File

@ -4,7 +4,13 @@
*
*/
import { LOAD_MODELS, LOADED_MODELS, UPDATE_SCHEMA } from './constants';
import { EMPTY_STORE, LOAD_MODELS, LOADED_MODELS, UPDATE_SCHEMA } from './constants';
export function emptyStore() {
return {
type: EMPTY_STORE,
};
}
export function loadModels() {
return {

View File

@ -4,6 +4,7 @@
*
*/
export const EMPTY_STORE = 'contentManager/App/EMPTY_STORE';
export const LOAD_MODELS = 'contentManager/App/LOAD_MODELS';
export const LOADED_MODELS = 'contentManager/App/LOADED_MODELS';
export const UPDATE_SCHEMA = 'contentManager/App/UPDATE_SCHEMA';

View File

@ -19,7 +19,7 @@ import Home from 'containers/Home';
import Edit from 'containers/Edit';
import List from 'containers/List';
import { loadModels, updateSchema } from './actions';
import { emptyStore, loadModels, updateSchema } from './actions';
import { makeSelectLoading } from './selectors';
import saga from './sagas';
@ -43,6 +43,10 @@ class App extends React.Component {
}
}
componentWillUnmount() {
this.props.emptyStore();
}
render() {
if (this.props.loading) {
return <div />;
@ -65,6 +69,7 @@ App.contextTypes = {
};
App.propTypes = {
emptyStore: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
loadModels: PropTypes.func.isRequired,
updateSchema: PropTypes.func.isRequired,
@ -73,6 +78,7 @@ App.propTypes = {
export function mapDispatchToProps(dispatch) {
return bindActionCreators(
{
emptyStore,
loadModels,
updateSchema,
},

View File

@ -6,7 +6,7 @@
import { fromJS, List } from 'immutable';
import { LOAD_MODELS, LOADED_MODELS, UPDATE_SCHEMA } from './constants';
import { EMPTY_STORE, LOAD_MODELS, LOADED_MODELS, UPDATE_SCHEMA } from './constants';
const initialState = fromJS({
loading: true,
@ -17,6 +17,12 @@ const initialState = fromJS({
function appReducer(state = initialState, action) {
switch (action.type) {
case EMPTY_STORE:
return state
.set('loading', true)
.set('models', false)
.set('schema', false)
.set('formValidations', List());
case LOAD_MODELS:
return state;
case LOADED_MODELS: