Commit 8bb28c60 authored by Robert Knight's avatar Robert Knight

Restructure Redux store directory tree

Following the plan outlined in #687, restructure the Redux store as
follows:

 - Move the entry point from `services/annotation-ui.js` to `store/index.js`
 - Move the modules which define bundles of reducers, action creators
   and selectors to `store/modules/{module-name}.js`
 - Move related utility code to `store/{module-name}.js`
parent d3a567fa
......@@ -56,7 +56,7 @@ describe('sidebar.components.sidebar-content', function () {
before(function () {
angular.module('h', [])
.service('annotationUI', require('../../services/annotation-ui'))
.service('annotationUI', require('../../store'))
.component('sidebarContent', proxyquire('../sidebar-content',
noCallThru({
angular: angular,
......
......@@ -184,9 +184,10 @@ module.exports = angular.module('h', [
.directive('spinner', require('./directive/spinner'))
.directive('windowScroll', require('./directive/window-scroll'))
.service('annotationUI', require('./store'))
.service('analytics', require('./services/analytics'))
.service('annotationMapper', require('./services/annotation-mapper'))
.service('annotationUI', require('./services/annotation-ui'))
.service('api', require('./services/api'))
.service('apiRoutes', require('./services/api-routes'))
.service('auth', require('./services/oauth-auth'))
......
......@@ -21,7 +21,7 @@ describe('annotationMapper', function() {
};
angular.module('app', [])
.service('annotationMapper', require('../annotation-mapper'))
.service('annotationUI', require('../annotation-ui'))
.service('annotationUI', require('../../store'))
.value('api', fakeApi)
.value('settings', {});
angular.mock.module('app');
......
......@@ -37,15 +37,15 @@ var redux = require('redux');
var thunk = require('redux-thunk').default;
var reducers = require('../reducers');
var annotationsReducer = require('../reducers/annotations');
var framesReducer = require('../reducers/frames');
var linksReducer = require('../reducers/links');
var selectionReducer = require('../reducers/selection');
var sessionReducer = require('../reducers/session');
var viewerReducer = require('../reducers/viewer');
var util = require('../reducers/util');
var annotationsReducer = require('./modules/annotations');
var framesReducer = require('./modules/frames');
var linksReducer = require('./modules/links');
var selectionReducer = require('./modules/selection');
var sessionReducer = require('./modules/session');
var viewerReducer = require('./modules/viewer');
var util = require('./util');
var debugMiddleware = require('../reducers/debug-middleware');
var debugMiddleware = require('./debug-middleware');
/**
* Redux middleware which triggers an Angular change-detection cycle
......@@ -72,8 +72,11 @@ function angularDigestMiddleware($rootScope) {
};
}
/**
* Create the Redux store for the application.
*/
// @ngInject
module.exports = function ($rootScope, settings) {
function store($rootScope, settings) {
var enhancer = redux.applyMiddleware(
// The `thunk` middleware handles actions which are functions.
// This is used to implement actions which have side effects or are
......@@ -119,4 +122,6 @@ module.exports = function ($rootScope, settings) {
), store.getState);
return Object.assign(store, actionCreators, selectors);
};
}
module.exports = store;
......@@ -5,12 +5,12 @@
'use strict';
var arrayUtil = require('../util/array-util');
var metadata = require('../annotation-metadata');
var uiConstants = require('../ui-constants');
var arrayUtil = require('../../util/array-util');
var metadata = require('../../annotation-metadata');
var uiConstants = require('../../ui-constants');
var selection = require('./selection');
var util = require('./util');
var util = require('../util');
/**
* Return a copy of `current` with all matching annotations in `annotations`
......
'use strict';
var util = require('./util');
var util = require('../util');
function init() {
return {
......
......@@ -3,7 +3,7 @@
/**
* This module defines the main update function (or 'reducer' in Redux's
* terminology) that handles app state updates. For an overview of how state
* management in Redux works, see the comments at the top of `annotation-ui.js`
* management in Redux works, see the comments at the top of `store/index.js`
*
* Each sub-module in this folder defines:
*
......@@ -23,7 +23,7 @@ var links = require('./links');
var selection = require('./selection');
var session = require('./session');
var viewer = require('./viewer');
var util = require('./util');
var util = require('../util');
function init(settings) {
return Object.assign(
......
......@@ -12,11 +12,11 @@
var immutable = require('seamless-immutable');
var toSet = require('../util/array-util').toSet;
var uiConstants = require('../ui-constants');
var tabs = require('../tabs');
var toSet = require('../../util/array-util').toSet;
var uiConstants = require('../../ui-constants');
var tabs = require('../../tabs');
var util = require('./util');
var util = require('../util');
/**
......
'use strict';
var util = require('./util');
var util = require('../util');
function init() {
return {
......
......@@ -5,9 +5,9 @@ var redux = require('redux');
var thunk = require('redux-thunk').default;
var annotations = require('../annotations');
var fixtures = require('../../test/annotation-fixtures');
var util = require('../util');
var unroll = require('../../../shared/test/util').unroll;
var fixtures = require('../../../test/annotation-fixtures');
var util = require('../../util');
var unroll = require('../../../../shared/test/util').unroll;
var { actions, selectors } = annotations;
......
......@@ -2,8 +2,8 @@
var frames = require('../frames');
var session = require('../session');
var util = require('../util');
var unroll = require('../../../shared/test/util').unroll;
var util = require('../../util');
var unroll = require('../../../../shared/test/util').unroll;
var actions = frames.actions;
var update = util.createReducer(frames.update);
......
......@@ -2,7 +2,7 @@
var session = require('../session');
var util = require('../util');
var util = require('../../util');
var { init, actions, selectors } = session;
var update = util.createReducer(session.update);
......
......@@ -2,7 +2,7 @@
var viewer = require('../viewer');
var util = require('../util');
var util = require('../../util');
var { init, actions, selectors } = viewer;
var update = util.createReducer(viewer.update);
......
'use strict';
var util = require('./util');
var util = require('../util');
/**
* This module defines actions and state related to the display mode of the
......
......@@ -2,7 +2,7 @@
var immutable = require('seamless-immutable');
var annotationUIFactory = require('../annotation-ui');
var annotationUIFactory = require('../index');
var annotationFixtures = require('../../test/annotation-fixtures');
var metadata = require('../../annotation-metadata');
var unroll = require('../../../shared/test/util').unroll;
......
......@@ -44,7 +44,7 @@ describe('annotation threading', function () {
};
angular.module('app', [])
.service('annotationUI', require('../../services/annotation-ui'))
.service('annotationUI', require('../../store'))
.service('drafts', require('../../services/drafts'))
.service('rootThread', require('../../services/root-thread'))
.service('searchFilter', require('../../services/search-filter'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment