Unverified Commit effbfbea authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub

Merge pull request #2196 from paulkaplan/share-banner

Make share banner work on preview
parents 4124e265 9ce79dea
...@@ -9,5 +9,7 @@ ...@@ -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"
} }
...@@ -83,12 +83,15 @@ const PreviewPresentation = ({ ...@@ -83,12 +83,15 @@ 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} /> {!isShared && (
<ShareBanner 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">
...@@ -430,6 +433,7 @@ PreviewPresentation.propTypes = { ...@@ -430,6 +433,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,
......
...@@ -47,6 +47,7 @@ class Preview extends React.Component { ...@@ -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 { ...@@ -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(
...@@ -372,6 +378,7 @@ class Preview extends React.Component { ...@@ -372,6 +378,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}
...@@ -548,10 +555,7 @@ const mapStateToProps = state => { ...@@ -548,10 +555,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,
......
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');
require('./share-banner.scss'); require('./share-banner.scss');
const ShareBanner = props => { const ShareBanner = ({onShare}) => (
if (props.shared) return null; <div className="share-banner-outer">
return ( <FlexRow className="inner share-banner">
<div className="shareBanner"> <span className="share-text">
<div className="inner"> <FormattedMessage id="preview.share.notShared" />
<FlexRow className="preview-row"> </span>
<span className="share-text"> <Button
This project is not shared — so only you can see it. Click share to let everyone see it! className="button share-button"
</span> onClick={onShare}
<Button className="button share-button"> >
Share <FormattedMessage id="preview.share.shareButton" />
</Button> </Button>
</FlexRow> </FlexRow>
</div> </div>
</div> );
);
};
ShareBanner.propTypes = { ShareBanner.propTypes = {
shared: PropTypes.bool.isRequired onShare: PropTypes.func
}; };
module.exports = ShareBanner; module.exports = ShareBanner;
...@@ -2,19 +2,23 @@ ...@@ -2,19 +2,23 @@
$navigation-height: 50px; $navigation-height: 50px;
.shareBanner { .share-banner-outer {
background-color: $ui-orange-25percent; background-color: $ui-orange-25percent;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
color: $ui-orange; color: $ui-orange;
} }
.share-banner {
align-items: center;
justify-content: space-between;
}
.share-button { .share-button {
margin-top: 0;
background-color: $ui-orange; background-color: $ui-orange;
font-size: .875rem; font-size: .875rem;
font-weight: normal; font-weight: normal;
&:before { &:before {
display: inline-block; display: inline-block;
margin-right: .5rem; margin-right: .5rem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment