mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Fix TODO and add selector for studio comment capability
This commit is contained in:
parent
dc460fffde
commit
8267dcf16a
3 changed files with 20 additions and 5 deletions
|
@ -133,6 +133,9 @@ const selectCanAddProjects = state =>
|
|||
isCurator(state) ||
|
||||
(selectIsSocial(state) && state.studio.openToAll);
|
||||
|
||||
// This isn't "canComment" since they could be muted, but comment composer handles that
|
||||
const selectShowCommentComposer = state => selectIsSocial(state);
|
||||
|
||||
module.exports = {
|
||||
getInitialState,
|
||||
studioReducer,
|
||||
|
@ -144,5 +147,6 @@ module.exports = {
|
|||
|
||||
// Selectors
|
||||
selectCanEditInfo,
|
||||
selectCanAddProjects
|
||||
selectCanAddProjects,
|
||||
selectShowCommentComposer
|
||||
};
|
||||
|
|
|
@ -9,6 +9,8 @@ import ComposeComment from '../preview/comment/compose-comment.jsx';
|
|||
import TopLevelComment from '../preview/comment/top-level-comment.jsx';
|
||||
import studioCommentActions from '../../redux/studio-comment-actions.js';
|
||||
|
||||
import {selectShowCommentComposer} from '../../redux/studio.js';
|
||||
|
||||
const StudioComments = ({
|
||||
comments,
|
||||
getTopLevelComments,
|
||||
|
@ -81,9 +83,7 @@ export default connect(
|
|||
comments: state.comments.comments,
|
||||
moreCommentsToLoad: state.comments.moreCommentsToLoad,
|
||||
replies: state.comments.replies,
|
||||
|
||||
// TODO permissions like this to a selector for testing
|
||||
shouldShowCommentComposer: !!state.session.session.user // is logged in
|
||||
shouldShowCommentComposer: selectShowCommentComposer(state)
|
||||
}),
|
||||
{
|
||||
getTopLevelComments: studioCommentActions.getTopLevelComments,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import {
|
||||
getInitialState as getInitialStudioState,
|
||||
selectCanEditInfo,
|
||||
selectCanAddProjects
|
||||
selectCanAddProjects,
|
||||
selectShowCommentComposer
|
||||
} from '../../../src/redux/studio';
|
||||
|
||||
import {
|
||||
|
@ -75,4 +76,14 @@ describe('studio selectors', () => {
|
|||
expect(selectCanAddProjects(state)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('studio comments', () => {
|
||||
test('show comment composer only for social users', () => {
|
||||
expect(selectShowCommentComposer(state)).toBe(false);
|
||||
state.session = sessions.user1;
|
||||
expect(selectShowCommentComposer(state)).toBe(false);
|
||||
state.session = sessions.user1Social;
|
||||
expect(selectShowCommentComposer(state)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue