scratch-www/src/views/preview/subactions.jsx

90 lines
3.1 KiB
React
Raw Normal View History

2018-09-24 10:58:39 -04:00
const FormattedDate = require('react-intl').FormattedDate;
const PropTypes = require('prop-types');
const React = require('react');
const FlexRow = require('../../components/flex-row/flex-row.jsx');
const Button = require('../../components/forms/button.jsx');
const AddToStudioModal = require('../../components/modal/addtostudio/container.jsx');
const ReportModal = require('../../components/modal/report/modal.jsx');
require('./subactions.scss');
const Subactions = props => (
<FlexRow className="subactions">
<div className="share-date">
<div className="copyleft">&copy;</div>
{' '}
{/* eslint-disable react/jsx-sort-props */}
{props.shareDate === null ?
'Unshared' :
<FormattedDate
value={Date.parse(props.shareDate)}
day="2-digit"
month="short"
year="numeric"
/>
}
{/* eslint-enable react/jsx-sort-props */}
</div>
<FlexRow className="action-buttons">
{(props.isLoggedIn && props.userOwnsProject) &&
2018-09-24 10:58:39 -04:00
<React.Fragment>
<Button
className="action-button studio-button"
key="add-to-studio-button"
onClick={props.onAddToStudioClicked}
2018-09-24 10:58:39 -04:00
>
Add to Studio
2018-09-24 10:58:39 -04:00
</Button>,
<AddToStudioModal
isOpen={props.addToStudioOpen}
key="add-to-studio-modal"
studios={props.studios}
onRequestClose={props.onAddToStudioClosed}
onToggleStudio={props.onToggleStudio}
2018-09-24 10:58:39 -04:00
/>
</React.Fragment>
}
<Button className="action-button copy-link-button">
Copy Link
</Button>
{(props.isLoggedIn && !props.userOwnsProject) &&
<React.Fragment>
<Button
className="action-button report-button"
key="report-button"
onClick={props.onReportClicked}
>
Report
</Button>,
<ReportModal
isOpen={props.reportOpen}
key="report-modal"
type="project"
onReport={props.onReportSubmit}
onRequestClose={props.onReportClose}
/>
</React.Fragment>
}
2018-09-24 10:58:39 -04:00
</FlexRow>
</FlexRow>
);
2018-09-24 10:58:39 -04:00
Subactions.propTypes = {
2018-09-25 17:16:02 -04:00
addToStudioOpen: PropTypes.bool,
isLoggedIn: PropTypes.bool,
onAddToStudioClicked: PropTypes.func,
onAddToStudioClosed: PropTypes.func,
2018-09-24 10:58:39 -04:00
onReportClicked: PropTypes.func.isRequired,
onReportClose: PropTypes.func.isRequired,
onReportSubmit: PropTypes.func.isRequired,
2018-09-25 17:16:02 -04:00
onToggleStudio: PropTypes.func,
reportOpen: PropTypes.bool,
shareDate: PropTypes.string,
2018-09-25 17:16:02 -04:00
studios: PropTypes.arrayOf(PropTypes.object),
userOwnsProject: PropTypes.bool
2018-09-24 10:58:39 -04:00
};
module.exports = Subactions;