Make share banner actually share projects

This commit is contained in:
Paul Kaplan 2018-10-16 11:38:26 -04:00
parent 29a6a27f46
commit 21a7f1227e
4 changed files with 26 additions and 10 deletions

View file

@ -9,5 +9,7 @@
"preview.videoMotionChip": "Video Motion", "preview.videoMotionChip": "Video Motion",
"preview.comments.header": "Comments", "preview.comments.header": "Comments",
"preview.comments.turnOff": "Turn off commenting", "preview.comments.turnOff": "Turn off commenting",
"preview.comments.turnedOff": "Sorry, comment posting has been turned off for this project." "preview.comments.turnedOff": "Sorry, comment posting has been turned off for this project.",
"preview.share.notShared": "This project is not shared — so only you can see it. Click share to let everyone see it!",
"preview.share.shareButton": "Share"
} }

View file

@ -81,12 +81,16 @@ const PreviewPresentation = ({
onToggleStudio, onToggleStudio,
onToggleComments, onToggleComments,
onSeeInside, onSeeInside,
onShare,
onUpdate onUpdate
}) => { }) => {
const shareDate = ((projectInfo.history && projectInfo.history.shared)) ? projectInfo.history.shared : ''; const shareDate = ((projectInfo.history && projectInfo.history.shared)) ? projectInfo.history.shared : '';
return ( return (
<div className="preview"> <div className="preview">
<ShareBanner shared={isShared} /> <ShareBanner
shared={isShared}
onShare={onShare}
/>
{ projectInfo && projectInfo.author && projectInfo.author.id && ( { projectInfo && projectInfo.author && projectInfo.author.id && (
<Formsy onKeyPress={onKeyPress}> <Formsy onKeyPress={onKeyPress}>
<div className="inner"> <div className="inner">
@ -427,6 +431,7 @@ PreviewPresentation.propTypes = {
onReportComment: PropTypes.func.isRequired, onReportComment: PropTypes.func.isRequired,
onReportSubmit: PropTypes.func.isRequired, onReportSubmit: PropTypes.func.isRequired,
onSeeInside: PropTypes.func, onSeeInside: PropTypes.func,
onShare: PropTypes.func,
onToggleComments: PropTypes.func, onToggleComments: PropTypes.func,
onToggleStudio: PropTypes.func, onToggleStudio: PropTypes.func,
onUpdate: PropTypes.func, onUpdate: PropTypes.func,

View file

@ -47,6 +47,7 @@ class Preview extends React.Component {
'handleAddToStudioClick', 'handleAddToStudioClick',
'handleAddToStudioClose', 'handleAddToStudioClose',
'handleSeeInside', 'handleSeeInside',
'handleShare',
'handleUpdateProjectTitle', 'handleUpdateProjectTitle',
'handleUpdate', 'handleUpdate',
'handleToggleComments', 'handleToggleComments',
@ -291,7 +292,12 @@ class Preview extends React.Component {
this.props.setPlayer(false); this.props.setPlayer(false);
} }
handleShare () { handleShare () {
// This is just a placeholder, but enables the button in the editor this.props.updateProject(
this.props.projectInfo.id,
{isPublished: true},
this.props.user.username,
this.props.user.token
);
} }
handleUpdate (jsonData) { handleUpdate (jsonData) {
this.props.updateProject( this.props.updateProject(
@ -370,6 +376,7 @@ class Preview extends React.Component {
onReportComment={this.handleReportComment} onReportComment={this.handleReportComment}
onReportSubmit={this.handleReportSubmit} onReportSubmit={this.handleReportSubmit}
onSeeInside={this.handleSeeInside} onSeeInside={this.handleSeeInside}
onShare={this.handleShare}
onToggleComments={this.handleToggleComments} onToggleComments={this.handleToggleComments}
onToggleStudio={this.handleToggleStudio} onToggleStudio={this.handleToggleStudio}
onUpdate={this.handleUpdate} onUpdate={this.handleUpdate}
@ -525,10 +532,7 @@ const mapStateToProps = state => {
state.permissions.admin === true), state.permissions.admin === true),
isLoggedIn: isLoggedIn, isLoggedIn: isLoggedIn,
// 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 || ( isShared: !projectInfoPresent || state.preview.projectInfo.is_published,
state.preview.projectInfo.history &&
state.preview.projectInfo.history.shared &&
state.preview.projectInfo.history.shared.length > 0),
loved: state.preview.loved, loved: state.preview.loved,
original: state.preview.original, original: state.preview.original,
parent: state.preview.parent, parent: state.preview.parent,

View file

@ -1,5 +1,6 @@
const PropTypes = require('prop-types'); const PropTypes = require('prop-types');
const React = require('react'); const React = require('react');
const FormattedMessage = require('react-intl').FormattedMessage;
const FlexRow = require('../../components/flex-row/flex-row.jsx'); const FlexRow = require('../../components/flex-row/flex-row.jsx');
const Button = require('../../components/forms/button.jsx'); const Button = require('../../components/forms/button.jsx');
@ -12,10 +13,13 @@ const ShareBanner = props => {
<div className="inner"> <div className="inner">
<FlexRow className="preview-row"> <FlexRow className="preview-row">
<span className="share-text"> <span className="share-text">
This project is not shared so only you can see it. Click share to let everyone see it! <FormattedMessage id="preview.share.notShared" />
</span> </span>
<Button className="button share-button"> <Button
Share className="button share-button"
onClick={props.onShare}
>
<FormattedMessage id="preview.share.shareButton" />
</Button> </Button>
</FlexRow> </FlexRow>
</div> </div>
@ -24,6 +28,7 @@ const ShareBanner = props => {
}; };
ShareBanner.propTypes = { ShareBanner.propTypes = {
onShare: PropTypes.func,
shared: PropTypes.bool.isRequired shared: PropTypes.bool.isRequired
}; };