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
6b4bab02
Commit
6b4bab02
authored
Jun 14, 2021
by
picklesrus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move logic about whether session is fetched into selectors
parent
17307cac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
19 deletions
+31
-19
src/redux/studio-permissions.js
src/redux/studio-permissions.js
+7
-2
src/views/studio/studio-comments.jsx
src/views/studio/studio-comments.jsx
+24
-17
No files found.
src/redux/studio-permissions.js
View file @
6b4bab02
const
{
selectUserId
,
selectIsAdmin
,
selectIsSocial
,
selectIsLoggedIn
,
selectUsername
,
selectIsMuted
}
=
require
(
'
./session
'
);
selectIsLoggedIn
,
selectUsername
,
selectIsMuted
,
selectHasFetchedSession
,
selectStudioCommentsGloballyEnabled
}
=
require
(
'
./session
'
);
// Fine-grain selector helpers - not exported, use the higher level selectors below
const
isCreator
=
state
=>
selectUserId
(
state
)
===
state
.
studio
.
owner
;
...
...
@@ -71,7 +72,9 @@ const selectShowProjectMuteError = state => selectIsMuted(state) &&
isCurator
(
state
)
||
(
selectIsSocial
(
state
)
&&
state
.
studio
.
openToAll
));
const
selectShowCuratorMuteError
=
state
=>
selectIsMuted
(
state
)
&&
(
isManager
(
state
)
||
selectIsAdmin
(
state
));
const
selectShowCommentsGloballyOffError
=
state
=>
selectHasFetchedSession
(
state
)
&&
!
selectStudioCommentsGloballyEnabled
(
state
);
const
selectShowCommentsList
=
state
=>
selectHasFetchedSession
&&
selectStudioCommentsGloballyEnabled
(
state
);
export
{
selectCanEditInfo
,
selectCanAddProjects
,
...
...
@@ -89,6 +92,8 @@ export {
selectCanRemoveManager
,
selectCanPromoteCurators
,
selectCanRemoveProject
,
selectShowCommentsList
,
selectShowCommentsGloballyOffError
,
selectShowEditMuteError
,
selectShowProjectMuteError
,
selectShowCuratorMuteError
...
...
src/views/studio/studio-comments.jsx
View file @
6b4bab02
...
...
@@ -10,14 +10,16 @@ import TopLevelComment from '../preview/comment/top-level-comment.jsx';
import
studioCommentActions
from
'
../../redux/studio-comment-actions.js
'
;
import
StudioCommentsAllowed
from
'
./studio-comments-allowed.jsx
'
;
import
StudioCommentsNotAllowed
from
'
./studio-comments-not-allowed.jsx
'
;
import
{
selectIsAdmin
,
selectHasFetchedSession
,
selectStudioCommentsGloballyEnabled
}
from
'
../../redux/session
'
;
import
{
selectIsAdmin
,
selectHasFetchedSession
}
from
'
../../redux/session
'
;
import
{
selectShowCommentComposer
,
selectCanDeleteComment
,
selectCanDeleteCommentWithoutConfirm
,
selectCanReportComment
,
selectCanRestoreComment
,
selectCanEditCommentsAllowed
selectCanEditCommentsAllowed
,
selectShowCommentsList
,
selectShowCommentsGloballyOffError
}
from
'
../../redux/studio-permissions
'
;
import
{
selectStudioCommentsAllowed
}
from
'
../../redux/studio.js
'
;
...
...
@@ -32,7 +34,8 @@ const StudioComments = ({
replies
,
postURI
,
shouldShowCommentComposer
,
studioCommentsGloballyEnabled
,
shouldShowCommentsList
,
shouldShowCommentsGloballyOffError
,
canDeleteComment
,
canDeleteCommentWithoutConfirm
,
canEditCommentsAllowed
,
...
...
@@ -75,7 +78,20 @@ const StudioComments = ({
<
h2
><
FormattedMessage
id=
"studio.commentsHeader"
/></
h2
>
{
canEditCommentsAllowed
&&
<
StudioCommentsAllowed
/>
}
</
div
>
{
!
hasFetchedSession
||
studioCommentsGloballyEnabled
?
{
shouldShowCommentsGloballyOffError
&&
<
div
>
<
CommentingStatus
>
<
p
>
<
FormattedMessage
id=
"studio.comments.turnedOffGlobally"
/>
</
p
>
</
CommentingStatus
>
<
img
className=
"studio-comment-placholder-img"
src=
"/images/comments/comment-placeholder.png"
/>
</
div
>
}
{
shouldShowCommentsList
&&
<
div
>
{
shouldShowCommentComposer
?
(
commentsAllowed
?
...
...
@@ -123,17 +139,6 @@ const StudioComments = ({
<
FormattedMessage
id=
"general.loadMore"
/>
</
Button
>
}
</
div
>
:
<
div
>
<
CommentingStatus
>
<
p
>
<
FormattedMessage
id=
"studio.comments.turnedOffGlobally"
/>
</
p
>
</
CommentingStatus
>
<
img
className=
"studio-comment-placholder-img"
src=
"/images/comments/comment-placeholder.png"
/>
</
div
>
}
</
div
>
...
...
@@ -150,7 +155,8 @@ StudioComments.propTypes = {
moreCommentsToLoad
:
PropTypes
.
bool
,
replies
:
PropTypes
.
shape
({}),
shouldShowCommentComposer
:
PropTypes
.
bool
,
studioCommentsGloballyEnabled
:
PropTypes
.
bool
,
shouldShowCommentsGloballyOffError
:
PropTypes
.
bool
,
shouldShowCommentsList
:
PropTypes
.
bool
,
canDeleteComment
:
PropTypes
.
bool
,
canDeleteCommentWithoutConfirm
:
PropTypes
.
bool
,
canEditCommentsAllowed
:
PropTypes
.
bool
,
...
...
@@ -177,7 +183,8 @@ export default connect(
replies
:
state
.
comments
.
replies
,
commentsAllowed
:
selectStudioCommentsAllowed
(
state
),
shouldShowCommentComposer
:
selectShowCommentComposer
(
state
),
studioCommentsGloballyEnabled
:
selectStudioCommentsGloballyEnabled
(
state
),
shouldShowCommentsGloballyOffError
:
selectShowCommentsGloballyOffError
(
state
),
shouldShowCommentsList
:
selectShowCommentsList
(
state
),
canDeleteComment
:
selectCanDeleteComment
(
state
),
canDeleteCommentWithoutConfirm
:
selectCanDeleteCommentWithoutConfirm
(
state
),
canEditCommentsAllowed
:
selectCanEditCommentsAllowed
(
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