mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-20 11:26:52 -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) ||
|
isCurator(state) ||
|
||||||
(selectIsSocial(state) && state.studio.openToAll);
|
(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 = {
|
module.exports = {
|
||||||
getInitialState,
|
getInitialState,
|
||||||
studioReducer,
|
studioReducer,
|
||||||
|
@ -144,5 +147,6 @@ module.exports = {
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
selectCanEditInfo,
|
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 TopLevelComment from '../preview/comment/top-level-comment.jsx';
|
||||||
import studioCommentActions from '../../redux/studio-comment-actions.js';
|
import studioCommentActions from '../../redux/studio-comment-actions.js';
|
||||||
|
|
||||||
|
import {selectShowCommentComposer} from '../../redux/studio.js';
|
||||||
|
|
||||||
const StudioComments = ({
|
const StudioComments = ({
|
||||||
comments,
|
comments,
|
||||||
getTopLevelComments,
|
getTopLevelComments,
|
||||||
|
@ -81,9 +83,7 @@ export default connect(
|
||||||
comments: state.comments.comments,
|
comments: state.comments.comments,
|
||||||
moreCommentsToLoad: state.comments.moreCommentsToLoad,
|
moreCommentsToLoad: state.comments.moreCommentsToLoad,
|
||||||
replies: state.comments.replies,
|
replies: state.comments.replies,
|
||||||
|
shouldShowCommentComposer: selectShowCommentComposer(state)
|
||||||
// TODO permissions like this to a selector for testing
|
|
||||||
shouldShowCommentComposer: !!state.session.session.user // is logged in
|
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
getTopLevelComments: studioCommentActions.getTopLevelComments,
|
getTopLevelComments: studioCommentActions.getTopLevelComments,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import {
|
import {
|
||||||
getInitialState as getInitialStudioState,
|
getInitialState as getInitialStudioState,
|
||||||
selectCanEditInfo,
|
selectCanEditInfo,
|
||||||
selectCanAddProjects
|
selectCanAddProjects,
|
||||||
|
selectShowCommentComposer
|
||||||
} from '../../../src/redux/studio';
|
} from '../../../src/redux/studio';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -75,4 +76,14 @@ describe('studio selectors', () => {
|
||||||
expect(selectCanAddProjects(state)).toBe(false);
|
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