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
f18182dc
Commit
f18182dc
authored
Apr 09, 2019
by
Hannah Stepanek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sortGroups to maintain old group menu order
parent
5f478ff4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
groups.js
src/sidebar/services/groups.js
+16
-1
groups-test.js
src/sidebar/services/test/groups-test.js
+16
-0
No files found.
src/sidebar/services/groups.js
View file @
f18182dc
...
@@ -16,6 +16,7 @@ const DEFAULT_ORGANIZATION = {
...
@@ -16,6 +16,7 @@ const DEFAULT_ORGANIZATION = {
const
events
=
require
(
'../events'
);
const
events
=
require
(
'../events'
);
const
{
awaitStateChange
}
=
require
(
'../util/state-util'
);
const
{
awaitStateChange
}
=
require
(
'../util/state-util'
);
const
{
combineGroups
}
=
require
(
'../util/groups'
);
const
{
combineGroups
}
=
require
(
'../util/groups'
);
const
memoize
=
require
(
'../util/memoize'
);
const
serviceConfig
=
require
(
'../service-config'
);
const
serviceConfig
=
require
(
'../service-config'
);
// @ngInject
// @ngInject
...
@@ -190,11 +191,25 @@ function groups(
...
@@ -190,11 +191,25 @@ function 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
()
{
function
all
()
{
if
(
features
.
flagEnabled
(
'community_groups'
))
{
if
(
features
.
flagEnabled
(
'community_groups'
))
{
return
store
.
allGroups
();
return
store
.
allGroups
();
}
}
return
s
tore
.
getInScopeGroups
(
);
return
s
ortGroups
(
store
.
getInScopeGroups
()
);
}
}
// Return the full object for the group with the given id.
// Return the full object for the group with the given id.
...
...
src/sidebar/services/test/groups-test.js
View file @
f18182dc
...
@@ -163,6 +163,22 @@ describe('groups', function() {
...
@@ -163,6 +163,22 @@ describe('groups', function() {
assert
.
deepEqual
(
svc
.
all
(),
dummyGroups
);
assert
.
deepEqual
(
svc
.
all
(),
dummyGroups
);
assert
.
called
(
fakeStore
.
getInScopeGroups
);
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
()
{
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