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
acc88069
Commit
acc88069
authored
May 14, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow curators to remove themselves
parent
31655d7f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
8 deletions
+22
-8
src/redux/studio-permissions.js
src/redux/studio-permissions.js
+10
-2
src/views/studio/studio-member-tile.jsx
src/views/studio/studio-member-tile.jsx
+3
-3
test/unit/redux/studio-permissions.test.js
test/unit/redux/studio-permissions.test.js
+9
-3
No files found.
src/redux/studio-permissions.js
View file @
acc88069
...
...
@@ -31,7 +31,15 @@ const selectCanEditOpenToAll = state => isManager(state);
const
selectShowCuratorInvite
=
state
=>
!!
state
.
studio
.
invited
;
const
selectCanInviteCurators
=
state
=>
isManager
(
state
);
const
selectCanRemoveCurators
=
state
=>
isManager
(
state
)
||
selectIsAdmin
(
state
);
const
selectCanRemoveCurator
=
(
state
,
username
)
=>
{
// Admins/managers can remove any curators
if
(
isManager
(
state
)
||
selectIsAdmin
(
state
))
return
true
;
// Curators can remove themselves
if
(
selectUsername
(
state
)
===
username
)
{
return
true
;
}
return
false
;
};
const
selectCanRemoveManager
=
(
state
,
managerId
)
=>
(
selectIsAdmin
(
state
)
||
isManager
(
state
))
&&
managerId
!==
state
.
studio
.
owner
;
const
selectCanPromoteCurators
=
state
=>
isManager
(
state
);
...
...
@@ -63,7 +71,7 @@ export {
selectCanEditOpenToAll
,
selectShowCuratorInvite
,
selectCanInviteCurators
,
selectCanRemoveCurator
s
,
selectCanRemoveCurator
,
selectCanRemoveManager
,
selectCanPromoteCurators
,
selectCanRemoveProject
...
...
src/views/studio/studio-member-tile.jsx
View file @
acc88069
...
...
@@ -6,7 +6,7 @@ import classNames from 'classnames';
import
{
FormattedMessage
}
from
'
react-intl
'
;
import
{
selectCanRemoveCurator
s
,
selectCanRemoveManager
,
selectCanPromoteCurators
selectCanRemoveCurator
,
selectCanRemoveManager
,
selectCanPromoteCurators
}
from
'
../../redux/studio-permissions
'
;
import
{
promoteCurator
,
...
...
@@ -109,8 +109,8 @@ const ManagerTile = connect(
)(
StudioMemberTile
);
const
CuratorTile
=
connect
(
state
=>
({
canRemove
:
selectCanRemoveCurator
s
(
stat
e
),
(
state
,
ownProps
)
=>
({
canRemove
:
selectCanRemoveCurator
(
state
,
ownProps
.
usernam
e
),
canPromote
:
selectCanPromoteCurators
(
state
)
}),
{
...
...
test/unit/redux/studio-permissions.test.js
View file @
acc88069
...
...
@@ -11,7 +11,7 @@ import {
selectCanEditOpenToAll
,
selectShowCuratorInvite
,
selectCanInviteCurators
,
selectCanRemoveCurator
s
,
selectCanRemoveCurator
,
selectCanRemoveManager
,
selectCanPromoteCurators
,
selectCanRemoveProject
...
...
@@ -287,7 +287,7 @@ describe('studio members', () => {
describe
(
'
can remove curators
'
,
()
=>
{
test
.
each
([
[
'
admin
'
,
true
],
[
'
curator
'
,
false
],
[
'
curator
'
,
false
],
// except themselves, see test below
[
'
manager
'
,
true
],
[
'
creator
'
,
true
],
[
'
logged in
'
,
false
],
...
...
@@ -295,7 +295,13 @@ describe('studio members', () => {
[
'
logged out
'
,
false
]
])(
'
%s: %s
'
,
(
role
,
expected
)
=>
{
setStateByRole
(
role
);
expect
(
selectCanRemoveCurators
(
state
)).
toBe
(
expected
);
expect
(
selectCanRemoveCurator
(
state
,
'
others-username
'
)).
toBe
(
expected
);
});
test
(
'
curators can remove themselves
'
,
()
=>
{
setStateByRole
(
'
curator
'
);
const
loggedInUsername
=
selectUsername
(
state
);
expect
(
selectCanRemoveCurator
(
state
,
loggedInUsername
)).
toBe
(
true
);
});
});
...
...
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