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

99 lines
3.5 KiB
React
Raw Normal View History

2018-09-24 10:58:39 -04:00
const FormattedDate = require('react-intl').FormattedDate;
const FormattedMessage = require('react-intl').FormattedMessage;
2018-09-24 10:58:39 -04:00
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('./add-to-studio.jsx');
2018-09-24 10:58:39 -04:00
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 ? (
<FormattedDate
value={Date.parse(props.shareDate)}
day="2-digit"
month="short"
year="numeric"
/>
) : 'Unshared'}
{/* eslint-enable react/jsx-sort-props */}
</div>
<FlexRow className="action-buttons">
{props.canAddToStudio &&
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
>
<FormattedMessage id="addToStudio.title" />
</Button>
{props.addToStudioOpen && (
<AddToStudioModal
isOpen
isAdmin={props.isAdmin}
key="add-to-studio-modal"
userOwnsProject={props.userOwnsProject}
onRequestClose={props.onAddToStudioClosed}
onToggleStudio={props.onToggleStudio}
/>
)}
2018-09-24 10:58:39 -04:00
</React.Fragment>
}
<Button
className="action-button copy-link-button"
onClick={props.onCopyProjectLink}
>
<FormattedMessage id="general.copyLink" />
</Button>
{(props.canReport) &&
<React.Fragment>
<Button
className="action-button report-button"
key="report-button"
onClick={props.onReportClicked}
>
<FormattedMessage id="general.report" />
</Button>
{props.reportOpen && (
<ReportModal
isOpen
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,
canAddToStudio: PropTypes.bool,
canReport: PropTypes.bool,
isAdmin: PropTypes.bool,
2018-09-25 17:16:02 -04:00
onAddToStudioClicked: PropTypes.func,
onAddToStudioClosed: PropTypes.func,
onCopyProjectLink: 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,
userOwnsProject: PropTypes.bool
2018-09-24 10:58:39 -04:00
};
module.exports = Subactions;