Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
ee116d60
Commit
ee116d60
authored
Oct 26, 2018
by
Hannah Stepanek
Committed by
Robert Knight
Oct 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add service.groups setting to filter groups
parent
6783b96d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
groups.js
src/sidebar/services/groups.js
+7
-0
groups-test.js
src/sidebar/services/test/groups-test.js
+40
-0
No files found.
src/sidebar/services/groups.js
View file @
ee116d60
...
@@ -48,6 +48,13 @@ function groups($rootScope, store, api, isSidebar, localStorage, serviceUrl, ses
...
@@ -48,6 +48,13 @@ function groups($rootScope, store, api, isSidebar, localStorage, serviceUrl, ses
* @return {Promise<Group[]>}
* @return {Promise<Group[]>}
*/
*/
function
filterGroups
(
groups
,
isLoggedIn
,
directLinkedAnnotationId
)
{
function
filterGroups
(
groups
,
isLoggedIn
,
directLinkedAnnotationId
)
{
// 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
(
svc
&&
svc
.
groups
)
{
const
focusedGroups
=
groups
.
filter
(
g
=>
svc
.
groups
.
includes
(
g
.
id
));
return
Promise
.
resolve
(
focusedGroups
);
}
// Logged-in users always see the "Public" group.
// Logged-in users always see the "Public" group.
if
(
isLoggedIn
)
{
if
(
isLoggedIn
)
{
return
Promise
.
resolve
(
groups
);
return
Promise
.
resolve
(
groups
);
...
...
src/sidebar/services/test/groups-test.js
View file @
ee116d60
...
@@ -253,6 +253,46 @@ describe('groups', function() {
...
@@ -253,6 +253,46 @@ describe('groups', function() {
});
});
});
});
});
});
[{
description
:
'shows service groups'
,
services
:
[{
groups
:
[
'abc123'
]}],
expected
:
[
'abc123'
],
},{
description
:
'only shows service groups that exist'
,
services
:
[{
groups
:
[
'abc123'
,
'no_exist'
]}],
expected
:
[
'abc123'
],
},{
description
:
'shows no groups if no service groups exist'
,
services
:
[{
groups
:
[
'no_exist'
]}],
expected
:
[],
},{
description
:
'shows all groups if service is null'
,
services
:
null
,
expected
:
[
'__world__'
,
'abc123'
],
},{
description
:
'shows all groups if service groups does not exist'
,
services
:
[{}],
expected
:
[
'__world__'
,
'abc123'
],
}].
forEach
(({
description
,
services
,
expected
})
=>
{
it
(
description
,
()
=>
{
fakeSettings
.
services
=
services
;
const
svc
=
service
();
// Create groups response from server.
const
groups
=
[{
name
:
'Public'
,
id
:
'__world__'
},
{
name
:
'ABC'
,
id
:
'abc123'
}];
fakeApi
.
groups
.
list
.
returns
(
Promise
.
resolve
({
token
:
'1234'
,
data
:
groups
,
}));
return
svc
.
load
().
then
(
groups
=>
{
let
displayedGroups
=
groups
.
map
(
g
=>
g
.
id
);
assert
.
deepEqual
(
displayedGroups
,
expected
);
});
});
});
});
});
describe
(
'#get'
,
function
()
{
describe
(
'#get'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment