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
2b4b0506
Commit
2b4b0506
authored
Jun 25, 2019
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove "community_groups" feature flag checks from groups service
parent
2ca9f92c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
51 deletions
+4
-51
groups.js
src/sidebar/services/groups.js
+2
-20
groups-test.js
src/sidebar/services/test/groups-test.js
+2
-31
No files found.
src/sidebar/services/groups.js
View file @
2b4b0506
...
...
@@ -29,8 +29,7 @@ function groups(
serviceUrl
,
session
,
settings
,
auth
,
features
auth
)
{
const
svc
=
serviceConfig
(
settings
);
const
authority
=
svc
?
svc
.
authority
:
null
;
...
...
@@ -299,25 +298,8 @@ function groups(
return
groups
;
}
const
sortGroups
=
memoize
(
groups
=>
{
// Sort in the following order: scoped, public, private.
// This is for maintaining the order of the old groups menu so when
// the old groups menu is removed this can be removed.
const
worldGroups
=
groups
.
filter
(
g
=>
g
.
id
===
'__world__'
);
const
nonWorldScopedGroups
=
groups
.
filter
(
g
=>
g
.
id
!==
'__world__'
&&
[
'open'
,
'restricted'
].
includes
(
g
.
type
)
);
const
remainingGroups
=
groups
.
filter
(
g
=>
!
worldGroups
.
includes
(
g
)
&&
!
nonWorldScopedGroups
.
includes
(
g
)
);
return
nonWorldScopedGroups
.
concat
(
worldGroups
).
concat
(
remainingGroups
);
});
function
all
()
{
if
(
features
.
flagEnabled
(
'community_groups'
))
{
return
store
.
allGroups
();
}
return
sortGroups
(
store
.
getInScopeGroups
());
return
store
.
allGroups
();
}
// Return the full object for the group with the given id.
...
...
src/sidebar/services/test/groups-test.js
View file @
2b4b0506
...
...
@@ -41,7 +41,6 @@ const dummyGroups = [
describe
(
'groups'
,
function
()
{
let
fakeAuth
;
let
fakeFeatures
;
let
fakeStore
;
let
fakeIsSidebar
;
let
fakeSession
;
...
...
@@ -55,9 +54,6 @@ describe('groups', function() {
fakeAuth
=
{
tokenGetter
:
sinon
.
stub
().
returns
(
'1234'
),
};
fakeFeatures
=
{
flagEnabled
:
sinon
.
stub
().
returns
(
false
),
};
fakeStore
=
fakeReduxStore
(
{
...
...
@@ -146,42 +142,17 @@ describe('groups', function() {
fakeServiceUrl
,
fakeSession
,
fakeSettings
,
fakeAuth
,
fakeFeatures
fakeAuth
);
}
describe
(
'#all'
,
function
()
{
it
(
'returns all groups from store.allGroups
when community-groups feature flag is enabled
'
,
()
=>
{
it
(
'returns all groups from store.allGroups'
,
()
=>
{
const
svc
=
service
();
fakeStore
.
allGroups
=
sinon
.
stub
().
returns
(
dummyGroups
);
fakeFeatures
.
flagEnabled
.
withArgs
(
'community_groups'
).
returns
(
true
);
assert
.
deepEqual
(
svc
.
all
(),
dummyGroups
);
assert
.
called
(
fakeStore
.
allGroups
);
});
it
(
'returns all groups from store.getInScopeGroups when community-groups feature flag is disabled'
,
()
=>
{
const
svc
=
service
();
fakeStore
.
getInScopeGroups
=
sinon
.
stub
().
returns
(
dummyGroups
);
assert
.
deepEqual
(
svc
.
all
(),
dummyGroups
);
assert
.
called
(
fakeStore
.
getInScopeGroups
);
});
[[
0
,
1
,
2
,
3
],
[
2
,
0
,
1
,
3
],
[
0
,
3
,
1
,
2
]].
forEach
(
groupInputOrder
=>
{
it
(
'sorts the groups in the following order: scoped, public, private maintaining order within each category.'
,
()
=>
{
const
groups
=
[
{
id
:
0
,
type
:
'open'
},
{
id
:
1
,
type
:
'restricted'
},
{
id
:
'__world__'
,
type
:
'open'
},
{
id
:
3
,
type
:
'private'
},
];
const
svc
=
service
();
fakeStore
.
getInScopeGroups
=
sinon
.
stub
()
.
returns
(
groupInputOrder
.
map
(
id
=>
groups
[
id
]));
assert
.
deepEqual
(
svc
.
all
(),
groups
);
});
});
});
describe
(
'#load'
,
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