restructure redux files
This commit is contained in:
parent
3a26cdd491
commit
81aabddeb1
21 changed files with 92 additions and 91 deletions
9
client/modules/IDE/actions/files.js
Normal file
9
client/modules/IDE/actions/files.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import * as ActionTypes from '../../../constants';
|
||||
|
||||
export function updateFile(name, content) {
|
||||
return {
|
||||
type: ActionTypes.CHANGE_SELECTED_FILE,
|
||||
name: name,
|
||||
content: content
|
||||
}
|
||||
}
|
19
client/modules/IDE/actions/ide.js
Normal file
19
client/modules/IDE/actions/ide.js
Normal file
|
@ -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
|
||||
}
|
||||
}
|
25
client/modules/IDE/actions/preferences.js
Normal file
25
client/modules/IDE/actions/preferences.js
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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})
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as ActionTypes from '../constants/constants';
|
||||
import * as ActionTypes from '../../../constants';
|
||||
|
||||
const initialState = {
|
||||
name: "sketch.js",
|
|
@ -1,4 +1,4 @@
|
|||
import * as ActionTypes from '../constants/constants';
|
||||
import * as ActionTypes from '../../../constants';
|
||||
|
||||
const initialState = {
|
||||
isPlaying: false
|
|
@ -1,4 +1,4 @@
|
|||
import * as ActionTypes from '../constants/constants';
|
||||
import * as ActionTypes from '../../../constants';
|
||||
|
||||
const initialState = {
|
||||
isPreferencesShowing: false,
|
|
@ -1,4 +1,4 @@
|
|||
import * as ActionTypes from '../constants/constants';
|
||||
import * as ActionTypes from '../../../constants';
|
||||
|
||||
const initialState = {
|
||||
name: "Hello p5.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'
|
||||
|
|
@ -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 {
|
|
@ -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'
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import * as ActionTypes from '../constants/constants'
|
||||
import * as ActionTypes from '../../constants'
|
||||
|
||||
const user = (state = {authenticated: false}, action) => {
|
||||
switch (action.type) {
|
18
client/reducers.js
Normal file
18
client/reducers.js
Normal file
|
@ -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
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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 (
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue