Commit 3c9d3448 authored by Hannah Stepanek's avatar Hannah Stepanek

Add getInScopeGroups to group store

getInScopeGroups returns the list of groups for the old groups
menu. Aka: only groups that are in scope are returned.
parent 3ce41b10
...@@ -158,6 +158,17 @@ const getCurrentlyViewingGroups = memoize(state => { ...@@ -158,6 +158,17 @@ const getCurrentlyViewingGroups = memoize(state => {
); );
}); });
/**
* Return groups that are scoped to the uri. This is used to return the groups
* that show up in the old groups menu. This should be removed once the new groups
* menu is permanent.
*
* @return {Group[]}
*/
const getInScopeGroups = memoize(state => {
return state.groups.filter(g => g.isScopedToUri);
});
module.exports = { module.exports = {
init, init,
update, update,
...@@ -171,6 +182,7 @@ module.exports = { ...@@ -171,6 +182,7 @@ module.exports = {
getCurrentlyViewingGroups, getCurrentlyViewingGroups,
getFeaturedGroups, getFeaturedGroups,
getMyGroups, getMyGroups,
getInScopeGroups,
focusedGroup, focusedGroup,
focusedGroupId, focusedGroupId,
}, },
......
...@@ -134,6 +134,13 @@ describe('sidebar.store.modules.groups', () => { ...@@ -134,6 +134,13 @@ describe('sidebar.store.modules.groups', () => {
}); });
}); });
describe('getInScopeGroups', () => {
it('returns all groups that are in scope', () => {
store.loadGroups([publicGroup, privateGroup, restrictedOutOfScopeGroup]);
assert.deepEqual(store.getInScopeGroups(), [publicGroup, privateGroup]);
});
});
describe('getGroup', () => { describe('getGroup', () => {
it('returns the group with the given ID', () => { it('returns the group with the given ID', () => {
store.loadGroups([publicGroup, privateGroup]); store.loadGroups([publicGroup, privateGroup]);
......
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