Unverified Commit 94aa005c authored by Sean Hammond's avatar Sean Hammond Committed by GitHub

Merge pull request #824 from hypothesis/support-groupids-in-groups-setting

Support groupids in `groups` config setting
parents 0a771592 f359af83
...@@ -51,7 +51,9 @@ function groups($rootScope, store, api, isSidebar, localStorage, serviceUrl, ses ...@@ -51,7 +51,9 @@ function groups($rootScope, store, api, isSidebar, localStorage, serviceUrl, ses
// If service groups are specified only return those. // If service groups are specified only return those.
// If a service group doesn't exist in the list of groups don't return it. // If a service group doesn't exist in the list of groups don't return it.
if (svc && svc.groups) { if (svc && svc.groups) {
const focusedGroups = groups.filter(g => svc.groups.includes(g.id)); const focusedGroups = groups.filter(g =>
svc.groups.includes(g.id) || svc.groups.includes(g.groupid)
);
return Promise.resolve(focusedGroups); return Promise.resolve(focusedGroups);
} }
......
...@@ -258,6 +258,10 @@ describe('groups', function() { ...@@ -258,6 +258,10 @@ describe('groups', function() {
description: 'shows service groups', description: 'shows service groups',
services: [{ groups: ['abc123']}], services: [{ groups: ['abc123']}],
expected: ['abc123'], expected: ['abc123'],
},{
description: 'also supports identifying service groups by groupid',
services: [{ groups: ['group:42@example.com']}],
expected: ['abc123'],
},{ },{
description: 'only shows service groups that exist', description: 'only shows service groups that exist',
services: [{ groups: ['abc123', 'no_exist']}], services: [{ groups: ['abc123', 'no_exist']}],
...@@ -269,18 +273,22 @@ describe('groups', function() { ...@@ -269,18 +273,22 @@ describe('groups', function() {
},{ },{
description: 'shows all groups if service is null', description: 'shows all groups if service is null',
services: null, services: null,
expected: ['__world__', 'abc123'], expected: ['__world__', 'abc123', 'def456'],
},{ },{
description: 'shows all groups if service groups does not exist', description: 'shows all groups if service groups does not exist',
services: [{}], services: [{}],
expected: ['__world__', 'abc123'], expected: ['__world__', 'abc123', 'def456'],
}].forEach(({ description, services, expected }) => { }].forEach(({ description, services, expected }) => {
it(description, () => { it(description, () => {
fakeSettings.services = services; fakeSettings.services = services;
const svc = service(); const svc = service();
// Create groups response from server. // Create groups response from server.
const groups = [{ name: 'Public', id: '__world__' }, { name: 'ABC', id: 'abc123'}]; const groups = [
{ name: 'Public', id: '__world__' },
{ name: 'ABC', id: 'abc123', groupid: 'group:42@example.com'},
{ name: 'DEF', id: 'def456', groupid: null},
];
fakeApi.groups.list.returns(Promise.resolve({ fakeApi.groups.list.returns(Promise.resolve({
token: '1234', token: '1234',
......
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