mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
Add comment toggling
This commit is contained in:
parent
c6a9085d81
commit
086012f802
4 changed files with 58 additions and 8 deletions
|
@ -6,5 +6,7 @@
|
||||||
"preview.penExtensionChip": "Pen",
|
"preview.penExtensionChip": "Pen",
|
||||||
"preview.speechExtensionChip": "Google Speech",
|
"preview.speechExtensionChip": "Google Speech",
|
||||||
"preview.translateExtensionChip": "Google Translate",
|
"preview.translateExtensionChip": "Google Translate",
|
||||||
"preview.videoMotionChip": "Video Motion"
|
"preview.videoMotionChip": "Video Motion",
|
||||||
|
"preview.comments.turnOff": "Turn off commenting",
|
||||||
|
"preview.comments.turnedOff": "Sorry, comment posting has been turned off for this project."
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const injectIntl = require('react-intl').injectIntl;
|
const injectIntl = require('react-intl').injectIntl;
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
const intlShape = require('react-intl').intlShape;
|
const intlShape = require('react-intl').intlShape;
|
||||||
|
const FormattedMessage = require('react-intl').FormattedMessage;
|
||||||
|
|
||||||
const MediaQuery = require('react-responsive').default;
|
const MediaQuery = require('react-responsive').default;
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const Formsy = require('formsy-react').default;
|
const Formsy = require('formsy-react').default;
|
||||||
|
@ -76,6 +78,7 @@ const PreviewPresentation = ({
|
||||||
onAddToStudioClicked,
|
onAddToStudioClicked,
|
||||||
onAddToStudioClosed,
|
onAddToStudioClosed,
|
||||||
onToggleStudio,
|
onToggleStudio,
|
||||||
|
onToggleComments,
|
||||||
onSeeInside,
|
onSeeInside,
|
||||||
onUpdate
|
onUpdate
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -317,16 +320,37 @@ const PreviewPresentation = ({
|
||||||
<div className="comments-container">
|
<div className="comments-container">
|
||||||
<FlexRow className="comments-header">
|
<FlexRow className="comments-header">
|
||||||
<h4>Comments</h4>
|
<h4>Comments</h4>
|
||||||
{/* TODO: Add toggle comments component and logic*/}
|
{userOwnsProject ? (
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
checked={!projectInfo.comments_allowed}
|
||||||
|
className="comments-allowed-input"
|
||||||
|
type="checkbox"
|
||||||
|
onChange={onToggleComments}
|
||||||
|
/>
|
||||||
|
<FormattedMessage id="preview.comments.turnOff" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</FlexRow>
|
</FlexRow>
|
||||||
|
|
||||||
<FlexRow className="comments-root-reply">
|
<FlexRow className="comments-root-reply">
|
||||||
{isLoggedIn &&
|
{projectInfo.comments_allowed ? (
|
||||||
<ComposeComment
|
isLoggedIn ? (
|
||||||
projectId={projectId}
|
<ComposeComment
|
||||||
onAddComment={onAddComment}
|
projectId={projectId}
|
||||||
/>
|
onAddComment={onAddComment}
|
||||||
}
|
/>
|
||||||
|
) : (
|
||||||
|
/* TODO add box for signing in to leave a comment */
|
||||||
|
null
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<div className="comments-turned-off">
|
||||||
|
<FormattedMessage id="preview.comments.turnedOff" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</FlexRow>
|
</FlexRow>
|
||||||
|
|
||||||
<FlexRow className="comments-list">
|
<FlexRow className="comments-list">
|
||||||
|
@ -399,6 +423,7 @@ PreviewPresentation.propTypes = {
|
||||||
onReportClose: PropTypes.func.isRequired,
|
onReportClose: PropTypes.func.isRequired,
|
||||||
onReportSubmit: PropTypes.func.isRequired,
|
onReportSubmit: PropTypes.func.isRequired,
|
||||||
onSeeInside: PropTypes.func,
|
onSeeInside: PropTypes.func,
|
||||||
|
onToggleComments: PropTypes.func,
|
||||||
onToggleStudio: PropTypes.func,
|
onToggleStudio: PropTypes.func,
|
||||||
onUpdate: PropTypes.func,
|
onUpdate: PropTypes.func,
|
||||||
originalInfo: projectShape,
|
originalInfo: projectShape,
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Preview extends React.Component {
|
||||||
'handleSeeInside',
|
'handleSeeInside',
|
||||||
'handleUpdateProjectTitle',
|
'handleUpdateProjectTitle',
|
||||||
'handleUpdate',
|
'handleUpdate',
|
||||||
|
'handleToggleComments',
|
||||||
'initCounts',
|
'initCounts',
|
||||||
'pushHistory',
|
'pushHistory',
|
||||||
'renderLogin',
|
'renderLogin',
|
||||||
|
@ -167,6 +168,14 @@ class Preview extends React.Component {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handleToggleComments () {
|
||||||
|
this.props.updateProject(
|
||||||
|
this.props.projectInfo.id,
|
||||||
|
{comments_allowed: !this.props.projectInfo.comments_allowed},
|
||||||
|
this.props.user.username,
|
||||||
|
this.props.user.token
|
||||||
|
);
|
||||||
|
}
|
||||||
handleAddComment (comment, topLevelCommentId) {
|
handleAddComment (comment, topLevelCommentId) {
|
||||||
this.props.handleAddComment(comment, topLevelCommentId);
|
this.props.handleAddComment(comment, topLevelCommentId);
|
||||||
}
|
}
|
||||||
|
@ -356,6 +365,7 @@ class Preview extends React.Component {
|
||||||
onReportClose={this.handleReportClose}
|
onReportClose={this.handleReportClose}
|
||||||
onReportSubmit={this.handleReportSubmit}
|
onReportSubmit={this.handleReportSubmit}
|
||||||
onSeeInside={this.handleSeeInside}
|
onSeeInside={this.handleSeeInside}
|
||||||
|
onToggleComments={this.handleToggleComments}
|
||||||
onToggleStudio={this.handleToggleStudio}
|
onToggleStudio={this.handleToggleStudio}
|
||||||
onUpdate={this.handleUpdate}
|
onUpdate={this.handleUpdate}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -189,6 +189,19 @@ $stage-width: 480px;
|
||||||
.comment-bubble {
|
.comment-bubble {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comments-turned-off {
|
||||||
|
border: 1px solid $ui-blue-25percent;
|
||||||
|
border-radius: .5rem;
|
||||||
|
padding: 1.5rem 0;
|
||||||
|
background: $ui-blue-10percent;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comments-allowed-input {
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.remix-button,
|
.remix-button,
|
||||||
|
|
Loading…
Reference in a new issue