const FormattedDate = require('react-intl').FormattedDate;
const injectIntl = require('react-intl').injectIntl;
const PropTypes = require('prop-types');
const React = require('react');
const Formsy = require('formsy-react').default;
const classNames = require('classnames');
const approx = require('approximate-number');
const GUI = require('scratch-gui').default;
const IntlGUI = injectIntl(GUI);
const decorateText = require('../../lib/decorate-text.jsx');
const FlexRow = require('../../components/flex-row/flex-row.jsx');
const Button = require('../../components/forms/button.jsx');
const Avatar = require('../../components/avatar/avatar.jsx');
const CappedNumber = require('../../components/cappednumber/cappednumber.jsx');
const ShareBanner = require('./share-banner.jsx');
const RemixCredit = require('./remix-credit.jsx');
const RemixList = require('./remix-list.jsx');
const StudioList = require('./studio-list.jsx');
const InplaceInput = require('../../components/forms/inplace-input.jsx');
const AddToStudioModal = require('../../components/modal/addtostudio/container.jsx');
const ReportModal = require('../../components/modal/report/modal.jsx');
const TopLevelComment = require('./comment/top-level-comment.jsx');
const ExtensionChip = require('./extension-chip.jsx');
const projectShape = require('./projectshape.jsx').projectShape;
require('./preview.scss');
const PreviewPresentation = ({
backpackOptions,
comments,
editable,
extensions,
faved,
favoriteCount,
isFullScreen,
isLoggedIn,
isShared,
loved,
loveCount,
originalInfo,
parentInfo,
projectId,
projectInfo,
remixes,
reportOpen,
replies,
addToStudioOpen,
projectStudios,
studios,
userOwnsProject,
onFavoriteClicked,
onLoadMore,
onLoveClicked,
onReportClicked,
onReportClose,
onReportSubmit,
onAddToStudioClicked,
onAddToStudioClosed,
onToggleStudio,
onSeeInside,
onUpdate
}) => {
const shareDate = ((projectInfo.history && projectInfo.history.shared)) ? projectInfo.history.shared : '';
return (
{ projectInfo && projectInfo.author && projectInfo.author.id && (
{/* TODO: Hide Remix button for now until implemented */}
{(!userOwnsProject && false) &&
}
{/* eslint-disable max-len */}
Instructions
{editable ?
:
{decorateText(projectInfo.instructions)}
}
Notes and Credits
{editable ?
:
{decorateText(projectInfo.description)}
}
{/* eslint-enable max-len */}
{approx(loveCount, {decimal: false})}
{approx(favoriteCount, {decimal: false})}
{approx(projectInfo.stats.remixes, {decimal: false})}
©
{' '}
{/* eslint-disable react/jsx-sort-props */}
{shareDate === null ?
'Unshared' :
}
{/* eslint-enable react/jsx-sort-props */}
{(isLoggedIn && userOwnsProject) &&
,
}
{(isLoggedIn && !userOwnsProject) &&
,
}
{extensions && extensions.map(extension => (
))}
Comments
{/* TODO: Add toggle comments component and logic*/}
{comments.map(comment => (
))}
{comments.length < projectInfo.stats.comments &&
}
)}
);
};
PreviewPresentation.propTypes = {
addToStudioOpen: PropTypes.bool,
backpackOptions: PropTypes.shape({
host: PropTypes.string,
visible: PropTypes.bool
}),
comments: PropTypes.arrayOf(PropTypes.object),
editable: PropTypes.bool,
extensions: PropTypes.arrayOf(PropTypes.object),
faved: PropTypes.bool,
favoriteCount: PropTypes.number,
isFullScreen: PropTypes.bool,
isLoggedIn: PropTypes.bool,
isShared: PropTypes.bool,
loveCount: PropTypes.number,
loved: PropTypes.bool,
onAddToStudioClicked: PropTypes.func,
onAddToStudioClosed: PropTypes.func,
onFavoriteClicked: PropTypes.func,
onLoadMore: PropTypes.func,
onLoveClicked: PropTypes.func,
onReportClicked: PropTypes.func.isRequired,
onReportClose: PropTypes.func.isRequired,
onReportSubmit: PropTypes.func.isRequired,
onSeeInside: PropTypes.func,
onToggleStudio: PropTypes.func,
onUpdate: PropTypes.func,
originalInfo: projectShape,
parentInfo: projectShape,
projectId: PropTypes.string,
projectInfo: projectShape,
projectStudios: PropTypes.arrayOf(PropTypes.object),
remixes: PropTypes.arrayOf(PropTypes.object),
replies: PropTypes.objectOf(PropTypes.array),
reportOpen: PropTypes.bool,
studios: PropTypes.arrayOf(PropTypes.object),
userOwnsProject: PropTypes.bool
};
module.exports = injectIntl(PreviewPresentation);