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
6253e71d
Commit
6253e71d
authored
Aug 17, 2021
by
Eric Rosenbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change name of isHost selector helper
parent
0f4fba78
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
src/redux/studio-permissions.js
src/redux/studio-permissions.js
+6
-6
No files found.
src/redux/studio-permissions.js
View file @
6253e71d
...
@@ -3,12 +3,12 @@ const {selectUserId, selectIsAdmin, selectIsSocial,
...
@@ -3,12 +3,12 @@ const {selectUserId, selectIsAdmin, selectIsSocial,
selectHasFetchedSession
,
selectStudioCommentsGloballyEnabled
}
=
require
(
'
./session
'
);
selectHasFetchedSession
,
selectStudioCommentsGloballyEnabled
}
=
require
(
'
./session
'
);
// Fine-grain selector helpers - not exported, use the higher level selectors below
// Fine-grain selector helpers - not exported, use the higher level selectors below
const
is
Creator
=
state
=>
selectUserId
(
state
)
===
state
.
studio
.
owner
;
const
is
Host
=
state
=>
selectUserId
(
state
)
===
state
.
studio
.
owner
;
const
isCurator
=
state
=>
state
.
studio
.
curator
;
const
isCurator
=
state
=>
state
.
studio
.
curator
;
const
isManager
=
state
=>
state
.
studio
.
manager
||
is
Creator
(
state
);
const
isManager
=
state
=>
state
.
studio
.
manager
||
is
Host
(
state
);
// Action-based permissions selectors
// Action-based permissions selectors
const
selectCanEditInfo
=
state
=>
!
selectIsMuted
(
state
)
&&
(
selectIsAdmin
(
state
)
||
is
Creator
(
state
));
const
selectCanEditInfo
=
state
=>
!
selectIsMuted
(
state
)
&&
(
selectIsAdmin
(
state
)
||
is
Host
(
state
));
const
selectCanAddProjects
=
state
=>
const
selectCanAddProjects
=
state
=>
!
selectIsMuted
(
state
)
&&
!
selectIsMuted
(
state
)
&&
(
isManager
(
state
)
||
(
isManager
(
state
)
||
...
@@ -35,7 +35,7 @@ const selectCanDeleteCommentWithoutConfirm = state => selectIsAdmin(state);
...
@@ -35,7 +35,7 @@ const selectCanDeleteCommentWithoutConfirm = state => selectIsAdmin(state);
const
selectCanFollowStudio
=
state
=>
selectIsLoggedIn
(
state
);
const
selectCanFollowStudio
=
state
=>
selectIsLoggedIn
(
state
);
// Matching existing behavior, only admin/creator is allowed to toggle comments.
// Matching existing behavior, only admin/creator is allowed to toggle comments.
const
selectCanEditCommentsAllowed
=
state
=>
!
selectIsMuted
(
state
)
&&
(
selectIsAdmin
(
state
)
||
is
Creator
(
state
));
const
selectCanEditCommentsAllowed
=
state
=>
!
selectIsMuted
(
state
)
&&
(
selectIsAdmin
(
state
)
||
is
Host
(
state
));
const
selectCanEditOpenToAll
=
state
=>
!
selectIsMuted
(
state
)
&&
isManager
(
state
);
const
selectCanEditOpenToAll
=
state
=>
!
selectIsMuted
(
state
)
&&
isManager
(
state
);
const
selectShowCuratorInvite
=
state
=>
!
selectIsMuted
(
state
)
&&
!!
state
.
studio
.
invited
;
const
selectShowCuratorInvite
=
state
=>
!
selectIsMuted
(
state
)
&&
!!
state
.
studio
.
invited
;
...
@@ -61,7 +61,7 @@ const selectCanTransfer = (state, managerId) => {
...
@@ -61,7 +61,7 @@ const selectCanTransfer = (state, managerId) => {
if
(
state
.
studio
.
classroomId
!==
null
)
return
false
;
if
(
state
.
studio
.
classroomId
!==
null
)
return
false
;
if
(
state
.
studio
.
managers
>
1
)
{
// If there is more than one manager,
if
(
state
.
studio
.
managers
>
1
)
{
// If there is more than one manager,
if
(
managerId
===
state
.
studio
.
owner
)
{
// and the selected manager is the current owner/host,
if
(
managerId
===
state
.
studio
.
owner
)
{
// and the selected manager is the current owner/host,
if
(
is
Creator
(
state
))
return
true
;
// Owner/host can transfer
if
(
is
Host
(
state
))
return
true
;
// Owner/host can transfer
if
(
selectIsAdmin
(
state
))
return
true
;
// Admin can transfer
if
(
selectIsAdmin
(
state
))
return
true
;
// Admin can transfer
}
}
}
}
...
@@ -87,7 +87,7 @@ const selectCanRemoveProject = (state, creatorUsername, actorId) => {
...
@@ -87,7 +87,7 @@ const selectCanRemoveProject = (state, creatorUsername, actorId) => {
// We should only show the mute errors to muted users who have any permissions related to the content
// We should only show the mute errors to muted users who have any permissions related to the content
// TODO these duplicate the behavior embedded in the non-muted parts of the selectors above, it would be good
// TODO these duplicate the behavior embedded in the non-muted parts of the selectors above, it would be good
// to extract this.
// to extract this.
const
selectShowEditMuteError
=
state
=>
selectIsMuted
(
state
)
&&
(
is
Creator
(
state
)
||
selectIsAdmin
(
state
));
const
selectShowEditMuteError
=
state
=>
selectIsMuted
(
state
)
&&
(
is
Host
(
state
)
||
selectIsAdmin
(
state
));
const
selectShowProjectMuteError
=
state
=>
selectIsMuted
(
state
)
&&
const
selectShowProjectMuteError
=
state
=>
selectIsMuted
(
state
)
&&
(
selectIsAdmin
(
state
)
||
(
selectIsAdmin
(
state
)
||
isManager
(
state
)
||
isManager
(
state
)
||
...
...
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