Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
37851083
Commit
37851083
authored
May 06, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Promoted and added curators should go at the end of the list
parent
be088b95
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
src/redux/infinite-list.js
src/redux/infinite-list.js
+4
-3
src/views/studio/lib/studio-member-actions.js
src/views/studio/lib/studio-member-actions.js
+2
-2
test/unit/redux/infinite-list.test.js
test/unit/redux/infinite-list.test.js
+8
-5
No files found.
src/redux/infinite-list.js
View file @
37851083
...
...
@@ -76,10 +76,11 @@ const InfiniteList = key => {
...
state
,
items
:
state
.
items
.
filter
((
_
,
i
)
=>
i
!==
action
.
index
)
};
case
`
${
key
}
_
PREPEND
`
:
case
`
${
key
}
_
CREATE
`
:
return
{
...
state
,
items
:
[
action
.
item
].
concat
(
state
.
items
)
items
:
action
.
atEnd
?
state
.
items
.
concat
([
action
.
item
])
:
[
action
.
item
].
concat
(
state
.
items
)
};
case
`
${
key
}
_ERROR`
:
return
{
...
...
@@ -94,7 +95,7 @@ const InfiniteList = key => {
};
const
actions
=
{
create
:
item
=>
({
type
:
`
${
key
}
_PREPEND`
,
item
}),
create
:
(
item
,
atEnd
=
false
)
=>
({
type
:
`
${
key
}
_CREATE`
,
item
,
atEnd
}),
remove
:
index
=>
({
type
:
`
${
key
}
_REMOVE`
,
index
}),
replace
:
(
index
,
item
)
=>
({
type
:
`
${
key
}
_REPLACE`
,
index
,
item
}),
error
:
error
=>
({
type
:
`
${
key
}
_ERROR`
,
error
}),
...
...
src/views/studio/lib/studio-member-actions.js
View file @
37851083
...
...
@@ -139,7 +139,7 @@ const promoteCurator = username => ((dispatch, getState) => new Promise((resolve
const
index
=
curatorList
.
findIndex
(
v
=>
v
.
username
===
username
);
const
curatorItem
=
curatorList
[
index
];
if
(
index
!==
-
1
)
dispatch
(
curators
.
actions
.
remove
(
index
));
dispatch
(
managers
.
actions
.
create
(
curatorItem
));
dispatch
(
managers
.
actions
.
create
(
curatorItem
,
true
));
return
resolve
();
});
}));
...
...
@@ -163,7 +163,7 @@ const acceptInvitation = () => ((dispatch, getState) => new Promise((resolve, re
if
(
userError
)
return
reject
(
userError
);
// Note: this assumes that the user items from the curator endpoint
// are the same structure as the single user data returned from /users/:username
dispatch
(
curators
.
actions
.
create
(
userBody
));
dispatch
(
curators
.
actions
.
create
(
userBody
,
true
));
dispatch
(
setRoles
({
invited
:
false
,
curator
:
true
}));
return
resolve
();
});
...
...
test/unit/redux/infinite-list.test.js
View file @
37851083
...
...
@@ -93,15 +93,18 @@ describe('Infinite List redux module', () => {
});
describe
(
'
CREATE
'
,
()
=>
{
let
action
;
beforeEach
(()
=>
{
action
=
module
.
actions
.
create
(
7
);
});
test
(
'
prepends the given item
'
,
()
=>
{
test
(
'
prepends the given item by default
'
,
()
=>
{
const
action
=
module
.
actions
.
create
(
7
);
initialState
.
items
=
[
8
,
9
,
10
,
11
];
const
newState
=
module
.
reducer
(
initialState
,
action
);
expect
(
newState
.
items
).
toEqual
([
7
,
8
,
9
,
10
,
11
]);
});
test
(
'
appends the given item if given `atEnd` arg
'
,
()
=>
{
const
action
=
module
.
actions
.
create
(
7
,
true
);
initialState
.
items
=
[
8
,
9
,
10
,
11
];
const
newState
=
module
.
reducer
(
initialState
,
action
);
expect
(
newState
.
items
).
toEqual
([
8
,
9
,
10
,
11
,
7
]);
});
});
describe
(
'
ERROR
'
,
()
=>
{
...
...
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