2019-01-23 10:28:08 -05:00
|
|
|
const injectIntl = require('react-intl').injectIntl;
|
|
|
|
const PropTypes = require('prop-types');
|
|
|
|
const React = require('react');
|
|
|
|
const FormattedMessage = require('react-intl').FormattedMessage;
|
|
|
|
|
|
|
|
// Allow embedding html in banner messages coming from the server
|
|
|
|
const embedCensorMessage = message => (
|
|
|
|
// eslint-disable-next-line react/no-danger
|
|
|
|
<span dangerouslySetInnerHTML={{__html: message}} />
|
|
|
|
);
|
|
|
|
|
|
|
|
const communityGuidelinesLink = (
|
|
|
|
<a href="/community_guidelines/">
|
|
|
|
<FormattedMessage id="project.communityGuidelines" />
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
|
2019-02-11 13:00:35 -05:00
|
|
|
const CensoredMessage = ({censoredByCommunity, messageHTML, reshareable}) => (
|
2019-01-23 10:28:08 -05:00
|
|
|
<React.Fragment>
|
|
|
|
{/* if message HTML is provided, set innerHTML with it */}
|
2019-02-11 13:00:35 -05:00
|
|
|
{messageHTML ? embedCensorMessage(messageHTML) :
|
|
|
|
(censoredByCommunity ? (
|
|
|
|
<React.Fragment>
|
|
|
|
<FormattedMessage id="project.communityCensoredMessage" />
|
|
|
|
<br />
|
|
|
|
<br />
|
2019-01-23 10:28:08 -05:00
|
|
|
<FormattedMessage
|
2019-02-11 13:00:35 -05:00
|
|
|
id="project.willReviewCensoredMessage"
|
2019-01-23 10:28:08 -05:00
|
|
|
values={{communityGuidelinesLink: communityGuidelinesLink}}
|
|
|
|
/>
|
2019-02-11 13:00:35 -05:00
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
|
|
|
// if message is blank or missing, use default
|
|
|
|
<React.Fragment>
|
|
|
|
<FormattedMessage id="project.defaultCensoredMessage" />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
{reshareable ? (
|
|
|
|
<FormattedMessage
|
|
|
|
id="project.tempCensoredMessage"
|
|
|
|
values={{communityGuidelinesLink: communityGuidelinesLink}}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<FormattedMessage id="project.permCensoredMessage" />
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
|
|
|
))
|
|
|
|
}
|
2019-01-23 10:28:08 -05:00
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
|
|
|
|
CensoredMessage.propTypes = {
|
2019-02-11 13:00:35 -05:00
|
|
|
censoredByCommunity: PropTypes.bool,
|
2019-01-23 10:28:08 -05:00
|
|
|
messageHTML: PropTypes.string,
|
|
|
|
reshareable: PropTypes.bool
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = injectIntl(CensoredMessage);
|