diff --git a/client/redux/constants/constants.js b/client/constants.js similarity index 100% rename from client/redux/constants/constants.js rename to client/constants.js diff --git a/client/modules/IDE/actions/files.js b/client/modules/IDE/actions/files.js new file mode 100644 index 00000000..0b5684b5 --- /dev/null +++ b/client/modules/IDE/actions/files.js @@ -0,0 +1,9 @@ +import * as ActionTypes from '../../../constants'; + +export function updateFile(name, content) { + return { + type: ActionTypes.CHANGE_SELECTED_FILE, + name: name, + content: content + } +} \ No newline at end of file diff --git a/client/modules/IDE/actions/ide.js b/client/modules/IDE/actions/ide.js new file mode 100644 index 00000000..63ed4a3c --- /dev/null +++ b/client/modules/IDE/actions/ide.js @@ -0,0 +1,19 @@ +import * as ActionTypes from '../../../constants'; + +export function toggleSketch() { + return { + type: ActionTypes.TOGGLE_SKETCH + } +} + +export function startSketch() { + return { + type: ActionTypes.START_SKETCH + } +} + +export function stopSketch() { + return { + type: ActionTypes.STOP_SKETCH + } +} \ No newline at end of file diff --git a/client/modules/IDE/actions/preferences.js b/client/modules/IDE/actions/preferences.js new file mode 100644 index 00000000..c825714f --- /dev/null +++ b/client/modules/IDE/actions/preferences.js @@ -0,0 +1,25 @@ +import * as ActionTypes from '../../../constants'; + +export function openPreferences() { + return { + type: ActionTypes.OPEN_PREFERENCES + } +} + +export function closePreferences() { + return { + type: ActionTypes.CLOSE_PREFERENCES + } +} + +export function increaseFont() { + return { + type: ActionTypes.INCREASE_FONTSIZE + } +} + +export function decreaseFont() { + return { + type: ActionTypes.DECREASE_FONTSIZE + } +} \ No newline at end of file diff --git a/client/redux/actions/project.js b/client/modules/IDE/actions/project.js similarity index 91% rename from client/redux/actions/project.js rename to client/modules/IDE/actions/project.js index 85715980..9c275e53 100644 --- a/client/redux/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -1,17 +1,9 @@ -import * as ActionTypes from '../constants/constants' +import * as ActionTypes from '../../../constants'; import { browserHistory } from 'react-router' import axios from 'axios' const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; -export function updateFile(name, content) { - return { - type: ActionTypes.CHANGE_SELECTED_FILE, - name: name, - content: content - } -} - export function getProject(id) { return function(dispatch) { axios.get(`${ROOT_URL}/projects/${id}`, {withCredentials: true}) diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 06669e5e..8f0d139a 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -6,8 +6,10 @@ import Preferences from '../components/Preferences' import Nav from '../../../components/Nav' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import * as IndexActions from '../../../redux/actions' -import * as ProjectActions from '../../../redux/actions/project' +import * as FileActions from '../actions/files' +import * as IDEActions from '../actions/ide' +import * as PreferencesActions from '../actions/preferences' +import * as ProjectActions from '../actions/project' class IDEView extends React.Component { componentDidMount() { @@ -65,7 +67,7 @@ function mapStateToProps(state) { } function mapDispatchToProps(dispatch) { - return bindActionCreators(Object.assign({}, IndexActions, ProjectActions), dispatch); + return bindActionCreators(Object.assign({}, FileActions, ProjectActions, IDEActions, PreferencesActions), dispatch); } export default connect(mapStateToProps, mapDispatchToProps)(IDEView); diff --git a/client/redux/reducers/files.js b/client/modules/IDE/reducers/files.js similarity index 91% rename from client/redux/reducers/files.js rename to client/modules/IDE/reducers/files.js index 35b6f912..d780961d 100644 --- a/client/redux/reducers/files.js +++ b/client/modules/IDE/reducers/files.js @@ -1,4 +1,4 @@ -import * as ActionTypes from '../constants/constants'; +import * as ActionTypes from '../../../constants'; const initialState = { name: "sketch.js", diff --git a/client/redux/reducers/ide.js b/client/modules/IDE/reducers/ide.js similarity index 83% rename from client/redux/reducers/ide.js rename to client/modules/IDE/reducers/ide.js index 60e30701..e6df1422 100644 --- a/client/redux/reducers/ide.js +++ b/client/modules/IDE/reducers/ide.js @@ -1,4 +1,4 @@ -import * as ActionTypes from '../constants/constants'; +import * as ActionTypes from '../../../constants'; const initialState = { isPlaying: false diff --git a/client/redux/reducers/preferences.js b/client/modules/IDE/reducers/preferences.js similarity index 89% rename from client/redux/reducers/preferences.js rename to client/modules/IDE/reducers/preferences.js index 40e04259..75a6d128 100644 --- a/client/redux/reducers/preferences.js +++ b/client/modules/IDE/reducers/preferences.js @@ -1,4 +1,4 @@ -import * as ActionTypes from '../constants/constants'; +import * as ActionTypes from '../../../constants'; const initialState = { isPreferencesShowing: false, @@ -32,4 +32,4 @@ const preferences = (state = initialState, action) => { } } -export default preferences; +export default preferences; \ No newline at end of file diff --git a/client/redux/reducers/project.js b/client/modules/IDE/reducers/project.js similarity index 87% rename from client/redux/reducers/project.js rename to client/modules/IDE/reducers/project.js index b4256aa8..d58f24ed 100644 --- a/client/redux/reducers/project.js +++ b/client/modules/IDE/reducers/project.js @@ -1,4 +1,4 @@ -import * as ActionTypes from '../constants/constants'; +import * as ActionTypes from '../../../constants'; const initialState = { name: "Hello p5.js" diff --git a/client/redux/actions/user.js b/client/modules/User/actions.js similarity index 96% rename from client/redux/actions/user.js rename to client/modules/User/actions.js index 5dc2a78f..747c087b 100644 --- a/client/redux/actions/user.js +++ b/client/modules/User/actions.js @@ -1,4 +1,4 @@ -import * as ActionTypes from '../constants/constants' +import * as ActionTypes from '../../constants' import { browserHistory } from 'react-router' import axios from 'axios' diff --git a/client/modules/Auth/components/LoginForm.jsx b/client/modules/User/components/LoginForm.jsx similarity index 100% rename from client/modules/Auth/components/LoginForm.jsx rename to client/modules/User/components/LoginForm.jsx diff --git a/client/modules/Auth/components/SignupForm.jsx b/client/modules/User/components/SignupForm.jsx similarity index 100% rename from client/modules/Auth/components/SignupForm.jsx rename to client/modules/User/components/SignupForm.jsx diff --git a/client/modules/Auth/pages/LoginView.jsx b/client/modules/User/pages/LoginView.jsx similarity index 85% rename from client/modules/Auth/pages/LoginView.jsx rename to client/modules/User/pages/LoginView.jsx index bebcd8ba..fe645397 100644 --- a/client/modules/Auth/pages/LoginView.jsx +++ b/client/modules/User/pages/LoginView.jsx @@ -1,7 +1,7 @@ import React from 'react' import { bindActionCreators } from 'redux' import {reduxForm} from 'redux-form' -import * as UserActions from '../../../redux/actions/user' +import * as UserActions from '../actions' import LoginForm from '../components/LoginForm' class LoginView extends React.Component { diff --git a/client/modules/Auth/pages/SignupView.jsx b/client/modules/User/pages/SignupView.jsx similarity index 93% rename from client/modules/Auth/pages/SignupView.jsx rename to client/modules/User/pages/SignupView.jsx index f80c1f95..7af19073 100644 --- a/client/modules/Auth/pages/SignupView.jsx +++ b/client/modules/User/pages/SignupView.jsx @@ -1,7 +1,7 @@ import React from 'react' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import * as UserActions from '../../../redux/actions/user' +import * as UserActions from '../actions' import { reduxForm } from 'redux-form' import SignupForm from '../components/SignupForm' diff --git a/client/redux/reducers/user.js b/client/modules/User/reducers.js similarity index 79% rename from client/redux/reducers/user.js rename to client/modules/User/reducers.js index 84c90f4c..fa2ae8d2 100644 --- a/client/redux/reducers/user.js +++ b/client/modules/User/reducers.js @@ -1,4 +1,4 @@ -import * as ActionTypes from '../constants/constants' +import * as ActionTypes from '../../constants' const user = (state = {authenticated: false}, action) => { switch (action.type) { diff --git a/client/reducers.js b/client/reducers.js new file mode 100644 index 00000000..6e7e657f --- /dev/null +++ b/client/reducers.js @@ -0,0 +1,18 @@ +import { combineReducers } from 'redux' +import file from './modules/IDE/reducers/files' +import ide from './modules/IDE/reducers/ide' +import preferences from './modules/IDE/reducers/preferences' +import project from './modules/IDE/reducers/project' +import user from './modules/User/reducers' +import { reducer as form } from 'redux-form' + +const rootReducer = combineReducers({ + form, + ide, + file, + preferences, + user, + project +}) + +export default rootReducer \ No newline at end of file diff --git a/client/redux/actions/index.js b/client/redux/actions/index.js deleted file mode 100644 index 1f484f65..00000000 --- a/client/redux/actions/index.js +++ /dev/null @@ -1,46 +0,0 @@ -import * as ActionTypes from '../constants/constants'; -import axios from 'axios' - -const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; - -export function toggleSketch() { - return { - type: ActionTypes.TOGGLE_SKETCH - } -} - -export function startSketch() { - return { - type: ActionTypes.START_SKETCH - } -} - -export function stopSketch() { - return { - type: ActionTypes.STOP_SKETCH - } -} - -export function openPreferences() { - return { - type: ActionTypes.OPEN_PREFERENCES - } -} - -export function closePreferences() { - return { - type: ActionTypes.CLOSE_PREFERENCES - } -} - -export function increaseFont() { - return { - type: ActionTypes.INCREASE_FONTSIZE - } -} - -export function decreaseFont() { - return { - type: ActionTypes.DECREASE_FONTSIZE - } -} diff --git a/client/redux/reducers/index.js b/client/redux/reducers/index.js deleted file mode 100644 index 000c79c6..00000000 --- a/client/redux/reducers/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { combineReducers } from 'redux' -import file from './files' -import ide from './ide' -import preferences from './preferences' -import user from './user' -import project from './project' -import { reducer as form } from 'redux-form' - -const rootReducer = combineReducers({ - form, - file, - ide, - preferences, - user, - project -}) - -export default rootReducer diff --git a/client/routes.js b/client/routes.js index 81d220f5..a47e82e0 100644 --- a/client/routes.js +++ b/client/routes.js @@ -2,9 +2,9 @@ import { Route, IndexRoute } from 'react-router' import React from 'react' import App from './modules/App/App' import IDEView from './modules/IDE/pages/IDEView' -import LoginView from './modules/Auth/pages/LoginView' -import SignupView from './modules/Auth/pages/SignupView' -import { getUser } from './redux/actions/user' +import LoginView from './modules/User/pages/LoginView' +import SignupView from './modules/User/pages/SignupView' +import { getUser } from './modules/User/actions' const routes = (store) => { return ( diff --git a/client/store.js b/client/store.js index 0ad45f29..d94f3cb0 100644 --- a/client/store.js +++ b/client/store.js @@ -1,6 +1,6 @@ import { createStore, applyMiddleware, compose } from 'redux' import thunk from 'redux-thunk' -import rootReducer from './redux/reducers' +import rootReducer from './reducers' export default function configureStore(initialState) { const store = createStore( @@ -11,8 +11,8 @@ export default function configureStore(initialState) { if (module.hot) { // Enable Webpack hot module replacement for reducers - module.hot.accept('./redux/reducers', () => { - const nextRootReducer = require('./redux/reducers').default + module.hot.accept('./reducers', () => { + const nextRootReducer = require('./reducers').default store.replaceReducer(nextRootReducer) }) }