Commit c23ceaa8 authored by Hannah Stepanek's avatar Hannah Stepanek

Add direct-linked group to the store

parent 2ddb5369
......@@ -36,6 +36,7 @@ const debugMiddleware = require('./debug-middleware');
const activity = require('./modules/activity');
const annotations = require('./modules/annotations');
const directLinkedGroup = require('./modules/direct-linked-group');
const frames = require('./modules/frames');
const links = require('./modules/links');
const groups = require('./modules/groups');
......@@ -86,6 +87,7 @@ function store($rootScope, settings) {
const modules = [
activity,
annotations,
directLinkedGroup,
frames,
links,
groups,
......
'use strict';
const util = require('../util');
function init() {
return {
/**
* Indicates that an error occured in retrieving/showing the direct linked group.
* This could be because:
* - the group does not exist
* - the user does not have permission
* - the group is out of scope for the given page
* @type {boolean}
*/
directLinkedGroupFetchFailed: false,
};
}
const update = {
UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED(state, action) {
return {
directLinkedGroupFetchFailed: action.directLinkedGroupFetchFailed,
};
},
};
const actions = util.actionTypes(update);
/**
* Set the direct linked group fetch failure to true.
*/
function setDirectLinkedGroupFetchFailed() {
return {
type: actions.UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED,
directLinkedGroupFetchFailed: true,
};
}
/**
* Clear the direct linked group fetch failure.
*/
function clearDirectLinkedGroupFetchFailed() {
return {
type: actions.UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED,
directLinkedGroupFetchFailed: false,
};
}
module.exports = {
init,
update,
actions: {
setDirectLinkedGroupFetchFailed,
clearDirectLinkedGroupFetchFailed,
},
selectors: {},
};
'use strict';
const createStore = require('../../create-store');
const directLinkedGroup = require('../direct-linked-group');
describe('sidebar/store/modules/direct-linked-group', () => {
let store;
beforeEach(() => {
store = createStore([directLinkedGroup]);
});
it('sets directLinkedGroupFetchFailed to true', () => {
store.setDirectLinkedGroupFetchFailed();
assert.isTrue(store.getState().directLinkedGroupFetchFailed);
});
it('sets directLinkedGroupFetchFailed to false', () => {
store.setDirectLinkedGroupFetchFailed();
store.clearDirectLinkedGroupFetchFailed();
assert.isFalse(store.getState().directLinkedGroupFetchFailed);
});
});
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