diff --git a/src/views/preview/censored-message.jsx b/src/views/preview/censored-message.jsx new file mode 100644 index 000000000..b8eb01f0e --- /dev/null +++ b/src/views/preview/censored-message.jsx @@ -0,0 +1,45 @@ +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 + +); + +const communityGuidelinesLink = ( + + + +); + +const CensoredMessage = ({messageHTML, reshareable}) => ( + + {/* if message HTML is provided, set innerHTML with it */} + {messageHTML ? embedCensorMessage(messageHTML) : ( + // if message is blank or missing, use default + + +
+
+ {reshareable ? ( + + ) : ( + + )} +
+ )} +
+); + +CensoredMessage.propTypes = { + messageHTML: PropTypes.string, + reshareable: PropTypes.bool +}; + +module.exports = injectIntl(CensoredMessage); diff --git a/src/views/preview/presentation.jsx b/src/views/preview/presentation.jsx index 8b8017208..8fdd9aebe 100644 --- a/src/views/preview/presentation.jsx +++ b/src/views/preview/presentation.jsx @@ -17,6 +17,7 @@ const FlexRow = require('../../components/flex-row/flex-row.jsx'); const Button = require('../../components/forms/button.jsx'); const Avatar = require('../../components/avatar/avatar.jsx'); const Banner = require('./banner.jsx'); +const CensoredMessage = require('./censored-message.jsx'); const ModInfo = require('./mod-info.jsx'); const RemixCredit = require('./remix-credit.jsx'); const RemixList = require('./remix-list.jsx'); @@ -131,12 +132,6 @@ const PreviewPresentation = ({ const showNotesAndCredits = editable || projectInfo.description || (!projectInfo.instructions && !projectInfo.description); // show if both are empty - // Allow embedding html in banner messages coming from the server - const embedCensorMessage = message => ( - // eslint-disable-next-line react/no-danger - - ); - let banner; if (visibilityInfo.deleted) { // If both censored and deleted, prioritize deleted banner banner = (} />); } else if (visibilityInfo.censored) { - let censoredMessage; - if (visibilityInfo.message) { // if message is present, set innerHTML with it - censoredMessage = embedCensorMessage(visibilityInfo.message); - } else { // if message is blank or missing, use default - const communityGuidelinesLink = ( - - - - ); - if (visibilityInfo.censoredByCommunity) { - censoredMessage = ( - - -
-
- -
- ); - } else { - censoredMessage = ( - - -
-
- {visibilityInfo.reshareable ? ( - - ) : ( - - )} -
- ); - } - } + const censoredMessage = ( + + ); banner = (