Commit 4157859d authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Rename exports in `src/sidebar/store/modules`

This is the convention that I followed to export objects in the
`src/sidebar/store/modules`:  name of the file plus the word `Module`. For example, `direct-linked.js` exports `directLinkedModule`.
parent c3e2a91b
import { createStore } from './create-store';
import { debugMiddleware } from './debug-middleware';
import { activity } from './modules/activity';
import { annotations } from './modules/annotations';
import { defaults } from './modules/defaults';
import { directLinked } from './modules/direct-linked';
import { drafts } from './modules/drafts';
import { filters } from './modules/filters';
import { framesModule as frames } from './modules/frames';
import { groups } from './modules/groups';
import { links } from './modules/links';
import { realTimeUpdates } from './modules/real-time-updates';
import { routeModule as route } from './modules/route';
import { selection } from './modules/selection';
import { session } from './modules/session';
import { sidebarPanels } from './modules/sidebar-panels';
import { toastMessages } from './modules/toast-messages';
import { viewer } from './modules/viewer';
import { activityModule } from './modules/activity';
import { annotationsModule } from './modules/annotations';
import { defaultsModule } from './modules/defaults';
import { directLinkedModule } from './modules/direct-linked';
import { draftsModule } from './modules/drafts';
import { filtersModule } from './modules/filters';
import { framesModule } from './modules/frames';
import { groupsModule } from './modules/groups';
import { linksModule } from './modules/links';
import { realTimeUpdatesModule } from './modules/real-time-updates';
import { routeModule } from './modules/route';
import { selectionModule } from './modules/selection';
import { sessionModule } from './modules/session';
import { sidebarPanelsModule } from './modules/sidebar-panels';
import { toastMessagesModule } from './modules/toast-messages';
import { viewerModule } from './modules/viewer';
/**
* @template M
......@@ -23,22 +23,22 @@ import { viewer } from './modules/viewer';
*/
/**
* @typedef {StoreFromModule<activity> &
* StoreFromModule<annotations> &
* StoreFromModule<defaults> &
* StoreFromModule<directLinked> &
* StoreFromModule<drafts> &
* StoreFromModule<filters> &
* StoreFromModule<frames> &
* StoreFromModule<groups> &
* StoreFromModule<links> &
* StoreFromModule<realTimeUpdates> &
* StoreFromModule<route> &
* StoreFromModule<selection> &
* StoreFromModule<session> &
* StoreFromModule<sidebarPanels> &
* StoreFromModule<toastMessages> &
* StoreFromModule<viewer>
* @typedef {StoreFromModule<activityModule> &
* StoreFromModule<annotationsModule> &
* StoreFromModule<defaultsModule> &
* StoreFromModule<directLinkedModule> &
* StoreFromModule<draftsModule> &
* StoreFromModule<filtersModule> &
* StoreFromModule<framesModule> &
* StoreFromModule<groupsModule> &
* StoreFromModule<linksModule> &
* StoreFromModule<realTimeUpdatesModule> &
* StoreFromModule<routeModule> &
* StoreFromModule<selectionModule> &
* StoreFromModule<sessionModule> &
* StoreFromModule<sidebarPanelsModule> &
* StoreFromModule<toastMessagesModule> &
* StoreFromModule<viewerModule>
* } SidebarStore
*/
......@@ -59,22 +59,22 @@ export function createSidebarStore(settings) {
const middleware = [debugMiddleware];
const modules = [
activity,
annotations,
defaults,
directLinked,
drafts,
filters,
frames,
links,
groups,
realTimeUpdates,
route,
selection,
session,
sidebarPanels,
toastMessages,
viewer,
activityModule,
annotationsModule,
defaultsModule,
directLinkedModule,
draftsModule,
filtersModule,
framesModule,
linksModule,
groupsModule,
realTimeUpdatesModule,
routeModule,
selectionModule,
sessionModule,
sidebarPanelsModule,
toastMessagesModule,
viewerModule,
];
return /** @type {SidebarStore} */ (
createStore(modules, [settings], middleware)
......
......@@ -190,7 +190,7 @@ function isSavingAnnotation(state, annotation) {
/** @typedef {import('../../../types/api').Annotation} Annotation */
export const activity = createStoreModule(initialState, {
export const activityModule = createStoreModule(initialState, {
reducers,
namespace: 'activity',
......
......@@ -559,7 +559,7 @@ function savedAnnotations(state) {
});
}
export const annotations = createStoreModule(initialState, {
export const annotationsModule = createStoreModule(initialState, {
namespace: 'annotations',
reducers,
actionCreators: {
......
......@@ -49,7 +49,7 @@ function getDefaults(state) {
return state;
}
export const defaults = createStoreModule(initialState, {
export const defaultsModule = createStoreModule(initialState, {
namespace: 'defaults',
reducers,
actionCreators: {
......
......@@ -142,7 +142,7 @@ function directLinkedGroupFetchFailed(state) {
return state.directLinkedGroupFetchFailed;
}
export const directLinked = createStoreModule(initialState, {
export const directLinkedModule = createStoreModule(initialState, {
namespace: 'directLinked',
reducers,
actionCreators: {
......
......@@ -186,7 +186,7 @@ const unsavedAnnotations = createSelector(
drafts => drafts.filter(d => !d.annotation.id).map(d => d.annotation)
);
export const drafts = createStoreModule(initialState, {
export const draftsModule = createStoreModule(initialState, {
namespace: 'drafts',
reducers,
actionCreators: {
......
......@@ -279,7 +279,7 @@ function hasAppliedFilter(state) {
return !!(state.query || Object.keys(getFilters(state)).length);
}
export const filters = createStoreModule(initialState, {
export const filtersModule = createStoreModule(initialState, {
namespace: 'filters',
reducers,
actionCreators: {
......
......@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
import * as util from '../util';
import { createStoreModule } from '../create-store';
import { session } from './session';
import { sessionModule } from './session';
/**
* @typedef {import('../../../types/api').Group} Group
......@@ -235,7 +235,7 @@ const getInScopeGroups = createSelector(
const getMyGroups = createSelector(
/** @param {{ groups: State, session: SessionState }} rootState */
rootState => filteredGroups(rootState.groups),
rootState => session.selectors.isLoggedIn(rootState.session),
rootState => sessionModule.selectors.isLoggedIn(rootState.session),
(groups, loggedIn) => {
// If logged out, the Public group still has isMember set to true so only
// return groups with membership in logged in state.
......@@ -261,7 +261,7 @@ const getCurrentlyViewingGroups = createSelector(
}
);
export const groups = createStoreModule(initialState, {
export const groupsModule = createStoreModule(initialState, {
namespace: 'groups',
reducers,
actionCreators: {
......
......@@ -51,7 +51,7 @@ function getLink(state, linkName, params = {}) {
return url;
}
export const links = createStoreModule(initialState, {
export const linksModule = createStoreModule(initialState, {
namespace: 'links',
reducers,
actionCreators: {
......
......@@ -12,9 +12,9 @@ import { createSelector } from 'reselect';
import { createStoreModule } from '../create-store';
import { actionTypes } from '../util';
import { annotations } from './annotations';
import { groups } from './groups';
import { routeModule as route } from './route';
import { annotationsModule } from './annotations';
import { groupsModule } from './groups';
import { routeModule } from './route';
const initialState = {
/**
......@@ -112,8 +112,8 @@ function receiveRealTimeUpdates({
const routeState = getState().route;
if (
ann.group === groups.selectors.focusedGroupId(groupState) ||
route.selectors.route(routeState) !== 'sidebar'
ann.group === groupsModule.selectors.focusedGroupId(groupState) ||
routeModule.selectors.route(routeState) !== 'sidebar'
) {
pendingUpdates[/** @type {string} */ (ann.id)] = ann;
}
......@@ -130,7 +130,7 @@ function receiveRealTimeUpdates({
// new annotation (saved in pendingUpdates and removed above), that has
// not yet been loaded.
const annotationsState = getState().annotations;
if (annotations.selectors.annotationExists(annotationsState, id)) {
if (annotationsModule.selectors.annotationExists(annotationsState, id)) {
pendingDeletions[id] = true;
}
});
......@@ -193,7 +193,7 @@ function hasPendingDeletion(state, id) {
return state.pendingDeletions.hasOwnProperty(id);
}
export const realTimeUpdates = createStoreModule(initialState, {
export const realTimeUpdatesModule = createStoreModule(initialState, {
namespace: 'realTimeUpdates',
reducers,
actionCreators: {
......
......@@ -381,7 +381,7 @@ const sortKeys = createSelector(
}
);
export const selection = createStoreModule(initialState, {
export const selectionModule = createStoreModule(initialState, {
namespace: 'selection',
reducers,
......
......@@ -117,7 +117,7 @@ function profile(state) {
return state.profile;
}
export const session = createStoreModule(initialState, {
export const sessionModule = createStoreModule(initialState, {
namespace: 'session',
reducers,
......
......@@ -121,7 +121,7 @@ function isSidebarPanelOpen(state, panelName) {
return state.activePanelName === panelName;
}
export const sidebarPanels = createStoreModule(initialState, {
export const sidebarPanelsModule = createStoreModule(initialState, {
namespace: 'sidebarPanels',
reducers,
......
import { createStore } from '../../create-store';
import { activity } from '../activity';
import { activityModule } from '../activity';
describe('sidebar/store/modules/activity', () => {
let store;
beforeEach(() => {
store = createStore([activity]);
store = createStore([activityModule]);
});
describe('hasFetchedAnnotations', () => {
......
import * as fixtures from '../../../test/annotation-fixtures';
import * as metadata from '../../../helpers/annotation-metadata';
import { createStore } from '../../create-store';
import { annotations } from '../annotations';
import { routeModule as route } from '../route';
import { annotationsModule } from '../annotations';
import { routeModule } from '../route';
function createTestStore() {
return createStore([annotations, route], [{}]);
return createStore([annotationsModule, routeModule], [{}]);
}
// Tests for some of the functionality in this store module are currently in
......
import { createStore } from '../../create-store';
import { defaults } from '../defaults';
import { defaultsModule } from '../defaults';
describe('store/modules/defaults', () => {
let store;
beforeEach(() => {
store = createStore([defaults]);
store = createStore([defaultsModule]);
});
describe('actions', () => {
......
import { createStore } from '../../create-store';
import { directLinked } from '../direct-linked';
import { directLinkedModule } from '../direct-linked';
describe('sidebar/store/modules/direct-linked', () => {
let store;
......@@ -11,7 +11,7 @@ describe('sidebar/store/modules/direct-linked', () => {
beforeEach(() => {
fakeSettings = {};
store = createStore([directLinked], [fakeSettings]);
store = createStore([directLinkedModule], [fakeSettings]);
});
describe('setDirectLinkedGroupFetchFailed', () => {
......@@ -35,7 +35,7 @@ describe('sidebar/store/modules/direct-linked', () => {
it('sets directLinkedAnnotationId to settings.annotations during store init', () => {
fakeSettings.annotations = 'ann-id';
store = createStore([directLinked], [fakeSettings]);
store = createStore([directLinkedModule], [fakeSettings]);
assert.equal(store.directLinkedAnnotationId(), 'ann-id');
});
......@@ -51,7 +51,7 @@ describe('sidebar/store/modules/direct-linked', () => {
it('sets directLinkedGroupId to settings.group during store init', () => {
fakeSettings.group = 'group-id';
store = createStore([directLinked], [fakeSettings]);
store = createStore([directLinkedModule], [fakeSettings]);
assert.equal(store.directLinkedGroupId(), 'group-id');
});
......
import { createStore } from '../../create-store';
import { annotations } from '../annotations';
import { drafts } from '../drafts';
import { annotationsModule } from '../annotations';
import { draftsModule } from '../drafts';
import { Draft } from '../drafts';
import { selection } from '../selection';
import { selectionModule } from '../selection';
import { immutable } from '../../../util/immutable';
const fixtures = immutable({
......@@ -31,7 +31,10 @@ describe('store/modules/drafts', () => {
let store;
beforeEach(() => {
store = createStore([drafts, annotations, selection], [{}]);
store = createStore(
[draftsModule, annotationsModule, selectionModule],
[{}]
);
});
describe('Draft', () => {
......
import { createStore } from '../../create-store';
import { filters } from '../filters';
import { selection } from '../selection';
import { filtersModule } from '../filters';
import { selectionModule } from '../selection';
describe('sidebar/store/modules/filters', () => {
let store;
......@@ -11,7 +11,7 @@ describe('sidebar/store/modules/filters', () => {
};
beforeEach(() => {
store = createStore([filters, selection], fakeSettings);
store = createStore([filtersModule, selectionModule], fakeSettings);
});
describe('actions', () => {
......@@ -88,7 +88,7 @@ describe('sidebar/store/modules/filters', () => {
it('disables focus mode if there is a conflicting filter key', () => {
store = createStore(
[filters],
[filtersModule],
[{ focus: { user: { username: 'somebody' } } }]
);
......@@ -286,7 +286,7 @@ describe('sidebar/store/modules/filters', () => {
describe('getFocusFilters', () => {
it('returns any set focus filters', () => {
store = createStore(
[filters],
[filtersModule],
[
{
focus: {
......@@ -313,7 +313,7 @@ describe('sidebar/store/modules/filters', () => {
it('returns true if user-focused mode is active', () => {
store = createStore(
[filters],
[filtersModule],
[{ focus: { user: { username: 'somebody' } } }]
);
......@@ -338,7 +338,7 @@ describe('sidebar/store/modules/filters', () => {
it('returns false if user-focused mode is configured but inactive', () => {
store = createStore(
[filters],
[filtersModule],
[{ focus: { user: { username: 'somebody' } } }]
);
store.toggleFocusMode(false);
......
import { createStore } from '../../create-store';
import { framesModule as frames } from '../frames';
import { framesModule } from '../frames';
describe('sidebar/store/modules/frames', () => {
let store;
beforeEach(() => {
// Setup a store for tests.
store = createStore([frames]);
store = createStore([framesModule]);
});
describe('#connectFrame', () => {
......
import { createStore } from '../../create-store';
import { groups } from '../groups';
import { session } from '../session';
import { groupsModule } from '../groups';
import { sessionModule } from '../session';
import { immutable } from '../../../util/immutable';
describe('sidebar/store/modules/groups', () => {
......@@ -73,7 +73,7 @@ describe('sidebar/store/modules/groups', () => {
beforeEach(() => {
// The empty second argument (settings) needed here because of the
// dependency on the `session` module
store = createStore([groups, session], [{}]);
store = createStore([groupsModule, sessionModule], [{}]);
});
describe('filterGroups', () => {
......
import { createStore } from '../../create-store';
import { links } from '../links';
import { linksModule } from '../links';
describe('sidebar/store/modules/links', () => {
let store;
beforeEach(() => {
store = createStore([links]);
store = createStore([linksModule]);
});
function addLinks() {
......
import { createStore } from '../../create-store';
import { annotations } from '../annotations';
import { groups } from '../groups';
import { realTimeUpdates, $imports } from '../real-time-updates';
import { selection } from '../selection';
import { annotationsModule } from '../annotations';
import { groupsModule } from '../groups';
import { realTimeUpdatesModule, $imports } from '../real-time-updates';
import { selectionModule } from '../selection';
const { removeAnnotations } = annotations.actionCreators;
const { focusGroup } = groups.actionCreators;
const { removeAnnotations } = annotationsModule.actionCreators;
const { focusGroup } = groupsModule.actionCreators;
describe('sidebar/store/modules/real-time-updates', () => {
let fakeAnnotationExists;
......@@ -31,18 +31,18 @@ describe('sidebar/store/modules/real-time-updates', () => {
});
store = createStore(
[realTimeUpdates, annotations, selection],
[realTimeUpdatesModule, annotationsModule, selectionModule],
[fakeSettings]
);
$imports.$mock({
'./annotations': {
annotations: {
annotationsModule: {
selectors: { annotationExists: fakeAnnotationExists },
},
},
'./groups': {
groups: {
groupsModule: {
selectors: { focusedGroupId: fakeFocusedGroupId },
},
},
......
import { createStore } from '../../create-store';
import { routeModule as route } from '../route';
import { routeModule } from '../route';
describe('store/modules/route', () => {
let store;
beforeEach(() => {
store = createStore([route]);
store = createStore([routeModule]);
});
it('sets initial route to `null`', () => {
......
import { createStore } from '../../create-store';
import { annotations } from '../annotations';
import { filters } from '../filters';
import { selection } from '../selection';
import { routeModule as route } from '../route';
import { annotationsModule } from '../annotations';
import { filtersModule } from '../filters';
import { selectionModule } from '../selection';
import { routeModule } from '../route';
import * as fixtures from '../../../test/annotation-fixtures';
describe('sidebar/store/modules/selection', () => {
......@@ -14,7 +14,10 @@ describe('sidebar/store/modules/selection', () => {
};
beforeEach(() => {
store = createStore([annotations, filters, selection, route], fakeSettings);
store = createStore(
[annotationsModule, filtersModule, selectionModule, routeModule],
fakeSettings
);
});
describe('setForcedVisible', () => {
......
import { createStore } from '../../create-store';
import { session } from '../session';
import { sessionModule } from '../session';
describe('sidebar/store/modules/session', () => {
let fakeSettings;
......@@ -7,7 +7,7 @@ describe('sidebar/store/modules/session', () => {
beforeEach(() => {
fakeSettings = {};
store = createStore([session], [fakeSettings]);
store = createStore([sessionModule], [fakeSettings]);
});
describe('#updateProfile', () => {
......@@ -21,7 +21,7 @@ describe('sidebar/store/modules/session', () => {
describe('#defaultAuthority', () => {
it('returns the default authority from the settings', () => {
fakeSettings.authDomain = 'foo.com';
store = createStore([session], [fakeSettings]);
store = createStore([sessionModule], [fakeSettings]);
assert.equal(store.defaultAuthority(), 'foo.com');
});
......
import { createStore } from '../../create-store';
import { sidebarPanels } from '../sidebar-panels';
import { sidebarPanelsModule } from '../sidebar-panels';
describe('sidebar/store/modules/sidebar-panels', () => {
let store;
......@@ -9,7 +9,7 @@ describe('sidebar/store/modules/sidebar-panels', () => {
};
beforeEach(() => {
store = createStore([sidebarPanels]);
store = createStore([sidebarPanelsModule]);
});
describe('#initialState', () => {
......
import { createStore } from '../../create-store';
import { toastMessages } from '../toast-messages';
import { toastMessagesModule } from '../toast-messages';
describe('store/modules/toast-messages', () => {
let store;
let fakeToastMessage;
beforeEach(() => {
store = createStore([toastMessages]);
store = createStore([toastMessagesModule]);
fakeToastMessage = {
id: 'myToast',
type: 'anyType',
......
import { createStore } from '../../create-store';
import { viewer } from '../viewer';
import { viewerModule } from '../viewer';
describe('store/modules/viewer', () => {
let store;
beforeEach(() => {
store = createStore([viewer]);
store = createStore([viewerModule]);
});
describe('hasSidebarOpened', () => {
......
......@@ -112,7 +112,7 @@ function hasMessage(state, type, text) {
});
}
export const toastMessages = createStoreModule(initialState, {
export const toastMessagesModule = createStoreModule(initialState, {
namespace: 'toastMessages',
reducers,
actionCreators: {
......
......@@ -43,7 +43,7 @@ function hasSidebarOpened(state) {
return state.sidebarHasOpened;
}
export const viewer = createStoreModule(initialState, {
export const viewerModule = createStoreModule(initialState, {
namespace: 'viewer',
reducers,
actionCreators: {
......
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