JoinColony / colonyDapp

Colony dApp client
49 stars 19 forks source link

Simplify the file structure! #840

Closed JamesLefrere closed 4 years ago

JamesLefrere commented 5 years ago

no-think

It's fair to say that the file structure of the app could be simplified a bit, such that:

The scope of this issue is to simplify the app file structure by moving components and redux towards the top level. We can keep minimal module separations for components, but we can put all of the redux stuff together.

Suggestion

Here's a suggestion for what the file structure could look like (NB this is ignoring several existing directories such as scripts for brevity's sake):

/*
 * src
 *   index.js
 *
 *   components
 *     app
 *       App.jsx
 *       GasStation
 *       ...routes
 *       ...everything
 *     core
 *       ActionForm
 *     pages
 *       ...just page components
 *
 *   data  (import resolution: `~data`)
 *     blueprints
 *     service
 *     ...etc
 *
 *   immutable (import resolution: `~immutable`)
 *     state
 *     ...records
 *
 *   lib (import resolution: `~lib`)
 *     colonyNetwork
 *     database
 *     ...etc
 *
 *   redux (import resolution: `~redux`)
 *     app
 *       index.js
 *       createReduxStore.js
 *       createRootReducerStore.js
 *       createPromiseListener.js
 *       history.js
 *
 *     actionCreators
 *       index.js
 *       colony.js
 *         // Contains all the action creators for actions prefixed with
 *         // the file name (capitalised), e.g. colonyFetch => COLONY_FETCH
 *       ...etc
 *
 *     actionTypes
 *       index.js
 *       colony.js
 *         // Contains all the actions prefixed with the file name
 *         // (capitalised), e.g. COLONY_FETCH, COLONY_CREATE, etc.
 *       ...etc
 *
 *     context
 *       index.js
 *       rootContext.js
 *       ...etc
 *
 *     reducers
 *       colonies.js
 *       colonyNames.js
 *       currentUserActivities.js
 *       currentUserProfile.js
 *       currentWallet.js
 *       domains.js
 *       tasks.js
 *       tokens.js
 *       transactions.js
 *       usernames.js
 *       users.js
 *
 *     sagas
 *       index.js
 *       setupUserContext.js // same as now
 *       wallet.js // same as now
 *       colony.js
 *         // Contains sagas taken by actions prefixed with the file name
 *         // (capitalised), e.g. `takeEvery(COLONY_FETCH, colonyFetchSaga)`
 *
 *     selectors
 *       // Each file mirrors the files in `reducers`
 *       index.js
 *       colonies.js
 *       colonyNames.js
 *       currentUserActivities.js
 *       currentUserProfile.js
 *       currentWallet.js
 *       domains.js
 *       tasks.js
 *       tokens.js
 *       transactions.js
 *       usernames.js
 *       users.js
 */

It might be preferable to tackle this issue after the state simplification #841 is completed.

rdig commented 4 years ago

This is not really relevant now, we can re-visit it at a later date