From 3a26cdd49115587eca852e9b1ef349bcc37b35a2 Mon Sep 17 00:00:00 2001 From: catarak Date: Wed, 22 Jun 2016 13:49:06 -0400 Subject: [PATCH] restructure react components --- .../Nav => client/components}/Nav.jsx | 0 client/index.js | 4 +- .../containers => client/modules/App}/App.jsx | 0 .../modules/Auth/components}/LoginForm.jsx | 0 .../modules/Auth/components}/SignupForm.jsx | 0 .../modules/Auth/pages}/LoginView.jsx | 4 +- .../modules/Auth/pages}/SignupView.jsx | 4 +- .../modules/IDE/components}/Editor.jsx | 0 .../modules/IDE/components}/Preferences.jsx | 6 +-- .../modules/IDE/components}/Preview.jsx | 0 .../modules/IDE/components}/PreviewFrame.jsx | 0 .../modules/IDE/components}/Toolbar.jsx | 8 ++-- .../modules/IDE/pages}/IDEView.jsx | 14 +++---- {shared => client}/redux/actions/index.js | 0 {shared => client}/redux/actions/project.js | 0 {shared => client}/redux/actions/user.js | 0 .../redux/constants/constants.js | 0 {shared => client}/redux/reducers/files.js | 0 {shared => client}/redux/reducers/ide.js | 0 {shared => client}/redux/reducers/index.js | 0 .../redux/reducers/preferences.js | 0 {shared => client}/redux/reducers/project.js | 0 {shared => client}/redux/reducers/user.js | 0 {shared => client}/routes.js | 11 +++-- .../configureStore.js => client/store.js | 6 +-- shared/containers/ProjectView/ProjectView.jsx | 40 ------------------- 26 files changed, 28 insertions(+), 69 deletions(-) rename {shared/components/Nav => client/components}/Nav.jsx (100%) rename {shared/containers => client/modules/App}/App.jsx (100%) rename {shared/components/LoginForm => client/modules/Auth/components}/LoginForm.jsx (100%) rename {shared/components/SignupForm => client/modules/Auth/components}/SignupForm.jsx (100%) rename {shared/containers/LoginView => client/modules/Auth/pages}/LoginView.jsx (77%) rename {shared/containers/SignupView => client/modules/Auth/pages}/SignupView.jsx (86%) rename {shared/components/Editor => client/modules/IDE/components}/Editor.jsx (100%) rename {shared/components/Preferences => client/modules/IDE/components}/Preferences.jsx (87%) rename {shared/components/Preview => client/modules/IDE/components}/Preview.jsx (100%) rename {shared/components/Preview => client/modules/IDE/components}/PreviewFrame.jsx (100%) rename {shared/components/Toolbar => client/modules/IDE/components}/Toolbar.jsx (86%) rename {shared/containers/IDEView => client/modules/IDE/pages}/IDEView.jsx (82%) rename {shared => client}/redux/actions/index.js (100%) rename {shared => client}/redux/actions/project.js (100%) rename {shared => client}/redux/actions/user.js (100%) rename {shared => client}/redux/constants/constants.js (100%) rename {shared => client}/redux/reducers/files.js (100%) rename {shared => client}/redux/reducers/ide.js (100%) rename {shared => client}/redux/reducers/index.js (100%) rename {shared => client}/redux/reducers/preferences.js (100%) rename {shared => client}/redux/reducers/project.js (100%) rename {shared => client}/redux/reducers/user.js (100%) rename {shared => client}/routes.js (57%) rename shared/redux/store/configureStore.js => client/store.js (71%) delete mode 100644 shared/containers/ProjectView/ProjectView.jsx diff --git a/shared/components/Nav/Nav.jsx b/client/components/Nav.jsx similarity index 100% rename from shared/components/Nav/Nav.jsx rename to client/components/Nav.jsx diff --git a/client/index.js b/client/index.js index a1a1bdf2..7fa19f1b 100644 --- a/client/index.js +++ b/client/index.js @@ -2,8 +2,8 @@ import React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' import { Router, browserHistory } from 'react-router' -import configureStore from '../shared/redux/store/configureStore' -import routes from '../shared/routes' +import configureStore from './store' +import routes from './routes' require('../styles/main.scss'); diff --git a/shared/containers/App.jsx b/client/modules/App/App.jsx similarity index 100% rename from shared/containers/App.jsx rename to client/modules/App/App.jsx diff --git a/shared/components/LoginForm/LoginForm.jsx b/client/modules/Auth/components/LoginForm.jsx similarity index 100% rename from shared/components/LoginForm/LoginForm.jsx rename to client/modules/Auth/components/LoginForm.jsx diff --git a/shared/components/SignupForm/SignupForm.jsx b/client/modules/Auth/components/SignupForm.jsx similarity index 100% rename from shared/components/SignupForm/SignupForm.jsx rename to client/modules/Auth/components/SignupForm.jsx diff --git a/shared/containers/LoginView/LoginView.jsx b/client/modules/Auth/pages/LoginView.jsx similarity index 77% rename from shared/containers/LoginView/LoginView.jsx rename to client/modules/Auth/pages/LoginView.jsx index 47e6c26d..bebcd8ba 100644 --- a/shared/containers/LoginView/LoginView.jsx +++ b/client/modules/Auth/pages/LoginView.jsx @@ -1,8 +1,8 @@ import React from 'react' import { bindActionCreators } from 'redux' import {reduxForm} from 'redux-form' -import * as UserActions from '../../redux/actions/user' -import LoginForm from '../../components/LoginForm/LoginForm' +import * as UserActions from '../../../redux/actions/user' +import LoginForm from '../components/LoginForm' class LoginView extends React.Component { render() { diff --git a/shared/containers/SignupView/SignupView.jsx b/client/modules/Auth/pages/SignupView.jsx similarity index 86% rename from shared/containers/SignupView/SignupView.jsx rename to client/modules/Auth/pages/SignupView.jsx index fdfc83b8..f80c1f95 100644 --- a/shared/containers/SignupView/SignupView.jsx +++ b/client/modules/Auth/pages/SignupView.jsx @@ -1,9 +1,9 @@ import React from 'react' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import * as UserActions from '../../redux/actions/user' +import * as UserActions from '../../../redux/actions/user' import { reduxForm } from 'redux-form' -import SignupForm from '../../components/SignupForm/SignupForm' +import SignupForm from '../components/SignupForm' class SignupView extends React.Component { render() { diff --git a/shared/components/Editor/Editor.jsx b/client/modules/IDE/components/Editor.jsx similarity index 100% rename from shared/components/Editor/Editor.jsx rename to client/modules/IDE/components/Editor.jsx diff --git a/shared/components/Preferences/Preferences.jsx b/client/modules/IDE/components/Preferences.jsx similarity index 87% rename from shared/components/Preferences/Preferences.jsx rename to client/modules/IDE/components/Preferences.jsx index 6dc067d1..4e8b2300 100644 --- a/shared/components/Preferences/Preferences.jsx +++ b/client/modules/IDE/components/Preferences.jsx @@ -1,9 +1,9 @@ import React from 'react'; var Isvg = require('react-inlinesvg'); -var exitUrl = require('../../../images/exit.svg'); -var plusUrl = require('../../../images/plus.svg'); -var minusUrl = require('../../../images/minus.svg'); +var exitUrl = require('../../../../images/exit.svg'); +var plusUrl = require('../../../../images/plus.svg'); +var minusUrl = require('../../../../images/minus.svg'); var classNames = require('classnames'); class Preferences extends React.Component { diff --git a/shared/components/Preview/Preview.jsx b/client/modules/IDE/components/Preview.jsx similarity index 100% rename from shared/components/Preview/Preview.jsx rename to client/modules/IDE/components/Preview.jsx diff --git a/shared/components/Preview/PreviewFrame.jsx b/client/modules/IDE/components/PreviewFrame.jsx similarity index 100% rename from shared/components/Preview/PreviewFrame.jsx rename to client/modules/IDE/components/PreviewFrame.jsx diff --git a/shared/components/Toolbar/Toolbar.jsx b/client/modules/IDE/components/Toolbar.jsx similarity index 86% rename from shared/components/Toolbar/Toolbar.jsx rename to client/modules/IDE/components/Toolbar.jsx index 94cf4450..1e838ca5 100644 --- a/shared/components/Toolbar/Toolbar.jsx +++ b/client/modules/IDE/components/Toolbar.jsx @@ -1,10 +1,10 @@ import React from 'react'; var Isvg = require('react-inlinesvg'); -var playUrl = require('../../../images/play.svg'); -var logoUrl = require('../../../images/p5js-logo.svg'); -var stopUrl = require('../../../images/stop.svg'); -var preferencesUrl = require('../../../images/preferences.svg'); +var playUrl = require('../../../../images/play.svg'); +var logoUrl = require('../../../../images/p5js-logo.svg'); +var stopUrl = require('../../../../images/stop.svg'); +var preferencesUrl = require('../../../../images/preferences.svg'); var classNames = require('classnames'); class Toolbar extends React.Component { diff --git a/shared/containers/IDEView/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx similarity index 82% rename from shared/containers/IDEView/IDEView.jsx rename to client/modules/IDE/pages/IDEView.jsx index 81ec5fff..06669e5e 100644 --- a/shared/containers/IDEView/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -1,13 +1,13 @@ import React from 'react' -import Editor from '../../components/Editor/Editor' -import PreviewFrame from '../../components/Preview/PreviewFrame' -import Toolbar from '../../components/Toolbar/Toolbar' -import Preferences from '../../components/Preferences/Preferences' -import Nav from '../../components/Nav/Nav' +import Editor from '../components/Editor' +import PreviewFrame from '../components/PreviewFrame' +import Toolbar from '../components/Toolbar' +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 IndexActions from '../../../redux/actions' +import * as ProjectActions from '../../../redux/actions/project' class IDEView extends React.Component { componentDidMount() { diff --git a/shared/redux/actions/index.js b/client/redux/actions/index.js similarity index 100% rename from shared/redux/actions/index.js rename to client/redux/actions/index.js diff --git a/shared/redux/actions/project.js b/client/redux/actions/project.js similarity index 100% rename from shared/redux/actions/project.js rename to client/redux/actions/project.js diff --git a/shared/redux/actions/user.js b/client/redux/actions/user.js similarity index 100% rename from shared/redux/actions/user.js rename to client/redux/actions/user.js diff --git a/shared/redux/constants/constants.js b/client/redux/constants/constants.js similarity index 100% rename from shared/redux/constants/constants.js rename to client/redux/constants/constants.js diff --git a/shared/redux/reducers/files.js b/client/redux/reducers/files.js similarity index 100% rename from shared/redux/reducers/files.js rename to client/redux/reducers/files.js diff --git a/shared/redux/reducers/ide.js b/client/redux/reducers/ide.js similarity index 100% rename from shared/redux/reducers/ide.js rename to client/redux/reducers/ide.js diff --git a/shared/redux/reducers/index.js b/client/redux/reducers/index.js similarity index 100% rename from shared/redux/reducers/index.js rename to client/redux/reducers/index.js diff --git a/shared/redux/reducers/preferences.js b/client/redux/reducers/preferences.js similarity index 100% rename from shared/redux/reducers/preferences.js rename to client/redux/reducers/preferences.js diff --git a/shared/redux/reducers/project.js b/client/redux/reducers/project.js similarity index 100% rename from shared/redux/reducers/project.js rename to client/redux/reducers/project.js diff --git a/shared/redux/reducers/user.js b/client/redux/reducers/user.js similarity index 100% rename from shared/redux/reducers/user.js rename to client/redux/reducers/user.js diff --git a/shared/routes.js b/client/routes.js similarity index 57% rename from shared/routes.js rename to client/routes.js index 5f0893d3..81d220f5 100644 --- a/shared/routes.js +++ b/client/routes.js @@ -1,11 +1,10 @@ import { Route, IndexRoute } from 'react-router' import React from 'react' -import App from './containers/App' -import IDEView from './containers/IDEView/IDEView' -import LoginView from './containers/LoginView/LoginView' -import SignupView from './containers/SignupView/SignupView' -import ProjectView from './containers/ProjectView/ProjectView' -import { getUser } from './redux/actions/user'; +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' const routes = (store) => { return ( diff --git a/shared/redux/store/configureStore.js b/client/store.js similarity index 71% rename from shared/redux/store/configureStore.js rename to client/store.js index a380e383..0ad45f29 100644 --- a/shared/redux/store/configureStore.js +++ b/client/store.js @@ -1,6 +1,6 @@ import { createStore, applyMiddleware, compose } from 'redux' import thunk from 'redux-thunk' -import rootReducer from '../reducers' +import rootReducer from './redux/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('../reducers', () => { - const nextRootReducer = require('../reducers').default + module.hot.accept('./redux/reducers', () => { + const nextRootReducer = require('./redux/reducers').default store.replaceReducer(nextRootReducer) }) } diff --git a/shared/containers/ProjectView/ProjectView.jsx b/shared/containers/ProjectView/ProjectView.jsx deleted file mode 100644 index f9a43451..00000000 --- a/shared/containers/ProjectView/ProjectView.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react' -import * as ProjectActions from '../../redux/actions/project' -import { bindActionCreators } from 'redux' -import { connect } from 'react-redux' - -const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; - -class ProjectView extends React.Component { - render() { - return ( -
-

{this.props.project.name}

-

- {this.props.file.content} -

-
- ); - } - - componentDidMount() { - const id = this.props.params.project_id - this.props.getProject(id); - } -} - -function mapStateToProps(state) { - return { - file: state.file, - ide: state.ide, - user: state.user, - project: state.project - } -} - -function mapDispatchToProps(dispatch) { - return bindActionCreators(ProjectActions, dispatch); -} - -export default connect(mapStateToProps, mapDispatchToProps)(ProjectView); -