mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
refactored censored message into component, removed autocensor message
This commit is contained in:
parent
971b3dc2d1
commit
696bfa117e
2 changed files with 52 additions and 45 deletions
45
src/views/preview/censored-message.jsx
Normal file
45
src/views/preview/censored-message.jsx
Normal file
|
@ -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
|
||||||
|
<span dangerouslySetInnerHTML={{__html: message}} />
|
||||||
|
);
|
||||||
|
|
||||||
|
const communityGuidelinesLink = (
|
||||||
|
<a href="/community_guidelines/">
|
||||||
|
<FormattedMessage id="project.communityGuidelines" />
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
|
||||||
|
const CensoredMessage = ({messageHTML, reshareable}) => (
|
||||||
|
<React.Fragment>
|
||||||
|
{/* if message HTML is provided, set innerHTML with it */}
|
||||||
|
{messageHTML ? embedCensorMessage(messageHTML) : (
|
||||||
|
// 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>
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
|
CensoredMessage.propTypes = {
|
||||||
|
messageHTML: PropTypes.string,
|
||||||
|
reshareable: PropTypes.bool
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = injectIntl(CensoredMessage);
|
|
@ -17,6 +17,7 @@ const FlexRow = require('../../components/flex-row/flex-row.jsx');
|
||||||
const Button = require('../../components/forms/button.jsx');
|
const Button = require('../../components/forms/button.jsx');
|
||||||
const Avatar = require('../../components/avatar/avatar.jsx');
|
const Avatar = require('../../components/avatar/avatar.jsx');
|
||||||
const Banner = require('./banner.jsx');
|
const Banner = require('./banner.jsx');
|
||||||
|
const CensoredMessage = require('./censored-message.jsx');
|
||||||
const ModInfo = require('./mod-info.jsx');
|
const ModInfo = require('./mod-info.jsx');
|
||||||
const RemixCredit = require('./remix-credit.jsx');
|
const RemixCredit = require('./remix-credit.jsx');
|
||||||
const RemixList = require('./remix-list.jsx');
|
const RemixList = require('./remix-list.jsx');
|
||||||
|
@ -131,12 +132,6 @@ const PreviewPresentation = ({
|
||||||
const showNotesAndCredits = editable || projectInfo.description ||
|
const showNotesAndCredits = editable || projectInfo.description ||
|
||||||
(!projectInfo.instructions && !projectInfo.description); // show if both are empty
|
(!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
|
|
||||||
<span dangerouslySetInnerHTML={{__html: message}} />
|
|
||||||
);
|
|
||||||
|
|
||||||
let banner;
|
let banner;
|
||||||
if (visibilityInfo.deleted) { // If both censored and deleted, prioritize deleted banner
|
if (visibilityInfo.deleted) { // If both censored and deleted, prioritize deleted banner
|
||||||
banner = (<Banner
|
banner = (<Banner
|
||||||
|
@ -144,45 +139,12 @@ const PreviewPresentation = ({
|
||||||
message={<FormattedMessage id="project.deletedBanner" />}
|
message={<FormattedMessage id="project.deletedBanner" />}
|
||||||
/>);
|
/>);
|
||||||
} else if (visibilityInfo.censored) {
|
} else if (visibilityInfo.censored) {
|
||||||
let censoredMessage;
|
const censoredMessage = (
|
||||||
if (visibilityInfo.message) { // if message is present, set innerHTML with it
|
<CensoredMessage
|
||||||
censoredMessage = embedCensorMessage(visibilityInfo.message);
|
messageHTML={visibilityInfo.messageHTML}
|
||||||
} else { // if message is blank or missing, use default
|
reshareable={visibilityInfo.reshareable}
|
||||||
const communityGuidelinesLink = (
|
|
||||||
<a href="/community_guidelines/">
|
|
||||||
<FormattedMessage id="project.communityGuidelines" />
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
if (visibilityInfo.censoredByCommunity) {
|
|
||||||
censoredMessage = (
|
|
||||||
<React.Fragment>
|
|
||||||
<FormattedMessage id="project.communityCensoredMessage" />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<FormattedMessage
|
|
||||||
id="project.willReviewCensoredMessage"
|
|
||||||
values={{communityGuidelinesLink: communityGuidelinesLink}}
|
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
censoredMessage = (
|
|
||||||
<React.Fragment>
|
|
||||||
<FormattedMessage id="project.defaultCensoredMessage" />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{visibilityInfo.reshareable ? (
|
|
||||||
<FormattedMessage
|
|
||||||
id="project.tempCensoredMessage"
|
|
||||||
values={{communityGuidelinesLink: communityGuidelinesLink}}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<FormattedMessage id="project.permCensoredMessage" />
|
|
||||||
)}
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
banner = (<Banner
|
banner = (<Banner
|
||||||
className="banner-danger"
|
className="banner-danger"
|
||||||
message={censoredMessage}
|
message={censoredMessage}
|
||||||
|
|
Loading…
Reference in a new issue