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
b0ac4018
Commit
b0ac4018
authored
Oct 16, 2018
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use admin routes to include all comments when loading page
parent
b7b7b079
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
src/redux/preview.js
src/redux/preview.js
+7
-5
src/views/preview/preview.jsx
src/views/preview/preview.jsx
+9
-4
No files found.
src/redux/preview.js
View file @
b0ac4018
...
@@ -337,10 +337,11 @@ module.exports.getFavedStatus = (id, username, token) => (dispatch => {
...
@@ -337,10 +337,11 @@ module.exports.getFavedStatus = (id, username, token) => (dispatch => {
});
});
});
});
module
.
exports
.
getTopLevelComments
=
(
id
,
offset
)
=>
(
dispatch
=>
{
module
.
exports
.
getTopLevelComments
=
(
id
,
offset
,
isAdmin
,
token
)
=>
(
dispatch
=>
{
dispatch
(
module
.
exports
.
setFetchStatus
(
'
comments
'
,
module
.
exports
.
Status
.
FETCHING
));
dispatch
(
module
.
exports
.
setFetchStatus
(
'
comments
'
,
module
.
exports
.
Status
.
FETCHING
));
api
({
api
({
uri
:
`/comments/project/
${
id
}
`
,
uri
:
`
${
isAdmin
?
'
/admin
'
:
''
}
/comments/project/
${
id
}
`
,
authentication
:
isAdmin
?
token
:
null
,
params
:
{
offset
:
offset
||
0
}
params
:
{
offset
:
offset
||
0
}
},
(
err
,
body
)
=>
{
},
(
err
,
body
)
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -355,16 +356,17 @@ module.exports.getTopLevelComments = (id, offset) => (dispatch => {
...
@@ -355,16 +356,17 @@ module.exports.getTopLevelComments = (id, offset) => (dispatch => {
}
}
dispatch
(
module
.
exports
.
setFetchStatus
(
'
comments
'
,
module
.
exports
.
Status
.
FETCHED
));
dispatch
(
module
.
exports
.
setFetchStatus
(
'
comments
'
,
module
.
exports
.
Status
.
FETCHED
));
dispatch
(
module
.
exports
.
setComments
(
body
));
dispatch
(
module
.
exports
.
setComments
(
body
));
dispatch
(
module
.
exports
.
getReplies
(
id
,
body
.
map
(
comment
=>
comment
.
id
)));
dispatch
(
module
.
exports
.
getReplies
(
id
,
body
.
map
(
comment
=>
comment
.
id
)
,
isAdmin
,
token
));
});
});
});
});
module
.
exports
.
getReplies
=
(
projectId
,
commentIds
)
=>
(
dispatch
=>
{
module
.
exports
.
getReplies
=
(
projectId
,
commentIds
,
isAdmin
,
token
)
=>
(
dispatch
=>
{
dispatch
(
module
.
exports
.
setFetchStatus
(
'
replies
'
,
module
.
exports
.
Status
.
FETCHING
));
dispatch
(
module
.
exports
.
setFetchStatus
(
'
replies
'
,
module
.
exports
.
Status
.
FETCHING
));
const
fetchedReplies
=
{};
const
fetchedReplies
=
{};
async
.
eachLimit
(
commentIds
,
10
,
(
parentId
,
callback
)
=>
{
async
.
eachLimit
(
commentIds
,
10
,
(
parentId
,
callback
)
=>
{
api
({
api
({
uri
:
`/comments/project/
${
projectId
}
/
${
parentId
}
`
uri
:
`
${
isAdmin
?
'
/admin
'
:
''
}
/comments/project/
${
projectId
}
/
${
parentId
}
`
,
authentication
:
isAdmin
?
token
:
null
},
(
err
,
body
)
=>
{
},
(
err
,
body
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
callback
(
`Error fetching comment replies:
${
err
}
`
);
return
callback
(
`Error fetching comment replies:
${
err
}
`
);
...
...
src/views/preview/preview.jsx
View file @
b0ac4018
...
@@ -81,7 +81,8 @@ class Preview extends React.Component {
...
@@ -81,7 +81,8 @@ class Preview extends React.Component {
if
(
this
.
props
.
user
)
{
if
(
this
.
props
.
user
)
{
const
username
=
this
.
props
.
user
.
username
;
const
username
=
this
.
props
.
user
.
username
;
const
token
=
this
.
props
.
user
.
token
;
const
token
=
this
.
props
.
user
.
token
;
this
.
props
.
getTopLevelComments
(
this
.
state
.
projectId
,
this
.
props
.
comments
.
length
);
this
.
props
.
getTopLevelComments
(
this
.
state
.
projectId
,
this
.
props
.
comments
.
length
,
this
.
props
.
isAdmin
,
token
);
this
.
props
.
getProjectInfo
(
this
.
state
.
projectId
,
token
);
this
.
props
.
getProjectInfo
(
this
.
state
.
projectId
,
token
);
this
.
props
.
getRemixes
(
this
.
state
.
projectId
,
token
);
this
.
props
.
getRemixes
(
this
.
state
.
projectId
,
token
);
this
.
props
.
getProjectStudios
(
this
.
state
.
projectId
,
token
);
this
.
props
.
getProjectStudios
(
this
.
state
.
projectId
,
token
);
...
@@ -269,7 +270,8 @@ class Preview extends React.Component {
...
@@ -269,7 +270,8 @@ class Preview extends React.Component {
}
}
}
}
handleLoadMore
()
{
handleLoadMore
()
{
this
.
props
.
getTopLevelComments
(
this
.
state
.
projectId
,
this
.
props
.
comments
.
length
);
this
.
props
.
getTopLevelComments
(
this
.
state
.
projectId
,
this
.
props
.
comments
.
length
,
this
.
props
.
isAdmin
,
this
.
props
.
user
&&
this
.
props
.
user
.
token
);
}
}
handleLoveToggle
()
{
handleLoveToggle
()
{
this
.
props
.
setLovedStatus
(
this
.
props
.
setLovedStatus
(
...
@@ -447,6 +449,7 @@ Preview.propTypes = {
...
@@ -447,6 +449,7 @@ Preview.propTypes = {
handleOpenRegistration
:
PropTypes
.
func
,
handleOpenRegistration
:
PropTypes
.
func
,
handleReportComment
:
PropTypes
.
func
,
handleReportComment
:
PropTypes
.
func
,
handleToggleLoginOpen
:
PropTypes
.
func
,
handleToggleLoginOpen
:
PropTypes
.
func
,
isAdmin
:
PropTypes
.
bool
,
isEditable
:
PropTypes
.
bool
,
isEditable
:
PropTypes
.
bool
,
isLoggedIn
:
PropTypes
.
bool
,
isLoggedIn
:
PropTypes
.
bool
,
isShared
:
PropTypes
.
bool
,
isShared
:
PropTypes
.
bool
,
...
@@ -532,6 +535,7 @@ const mapStateToProps = state => {
...
@@ -532,6 +535,7 @@ const mapStateToProps = state => {
Object
.
keys
(
state
.
session
.
session
.
user
).
length
>
0
;
Object
.
keys
(
state
.
session
.
session
.
user
).
length
>
0
;
const
isLoggedIn
=
state
.
session
.
status
===
sessionActions
.
Status
.
FETCHED
&&
const
isLoggedIn
=
state
.
session
.
status
===
sessionActions
.
Status
.
FETCHED
&&
userPresent
;
userPresent
;
const
isAdmin
=
isLoggedIn
&&
state
.
session
.
session
.
permissions
.
admin
;
const
authorPresent
=
projectInfoPresent
&&
state
.
preview
.
projectInfo
.
author
&&
const
authorPresent
=
projectInfoPresent
&&
state
.
preview
.
projectInfo
.
author
&&
Object
.
keys
(
state
.
preview
.
projectInfo
.
author
).
length
>
0
;
Object
.
keys
(
state
.
preview
.
projectInfo
.
author
).
length
>
0
;
const
userOwnsProject
=
isLoggedIn
&&
authorPresent
&&
const
userOwnsProject
=
isLoggedIn
&&
authorPresent
&&
...
@@ -554,6 +558,7 @@ const mapStateToProps = state => {
...
@@ -554,6 +558,7 @@ const mapStateToProps = state => {
((
authorPresent
&&
state
.
preview
.
projectInfo
.
author
.
username
===
state
.
session
.
session
.
user
.
username
)
||
((
authorPresent
&&
state
.
preview
.
projectInfo
.
author
.
username
===
state
.
session
.
session
.
user
.
username
)
||
state
.
permissions
.
admin
===
true
),
state
.
permissions
.
admin
===
true
),
isLoggedIn
:
isLoggedIn
,
isLoggedIn
:
isLoggedIn
,
isAdmin
:
isAdmin
,
// if we don't have projectInfo, assume it's shared until we know otherwise
// if we don't have projectInfo, assume it's shared until we know otherwise
isShared
:
!
projectInfoPresent
||
state
.
preview
.
projectInfo
.
is_published
,
isShared
:
!
projectInfoPresent
||
state
.
preview
.
projectInfo
.
is_published
,
loved
:
state
.
preview
.
loved
,
loved
:
state
.
preview
.
loved
,
...
@@ -623,8 +628,8 @@ const mapDispatchToProps = dispatch => ({
...
@@ -623,8 +628,8 @@ const mapDispatchToProps = dispatch => ({
dispatch
(
previewActions
.
leaveStudio
(
studioId
,
id
,
token
));
dispatch
(
previewActions
.
leaveStudio
(
studioId
,
id
,
token
));
}
}
},
},
getTopLevelComments
:
(
id
,
offset
)
=>
{
getTopLevelComments
:
(
id
,
offset
,
isAdmin
,
token
)
=>
{
dispatch
(
previewActions
.
getTopLevelComments
(
id
,
offset
));
dispatch
(
previewActions
.
getTopLevelComments
(
id
,
offset
,
isAdmin
,
token
));
},
},
getFavedStatus
:
(
id
,
username
,
token
)
=>
{
getFavedStatus
:
(
id
,
username
,
token
)
=>
{
dispatch
(
previewActions
.
getFavedStatus
(
id
,
username
,
token
));
dispatch
(
previewActions
.
getFavedStatus
(
id
,
username
,
token
));
...
...
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