show autocensored message if API indicates project was autocensored

This commit is contained in:
Ben Wheeler 2019-02-11 13:00:35 -05:00
parent 0d17d9cee1
commit 902367ef05
3 changed files with 32 additions and 14 deletions

View file

@ -15,29 +15,42 @@ const communityGuidelinesLink = (
</a>
);
const CensoredMessage = ({messageHTML, reshareable}) => (
const CensoredMessage = ({censoredByCommunity, 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 ? (
{messageHTML ? embedCensorMessage(messageHTML) :
(censoredByCommunity ? (
<React.Fragment>
<FormattedMessage id="project.communityCensoredMessage" />
<br />
<br />
<FormattedMessage
id="project.tempCensoredMessage"
id="project.willReviewCensoredMessage"
values={{communityGuidelinesLink: communityGuidelinesLink}}
/>
) : (
<FormattedMessage id="project.permCensoredMessage" />
)}
</React.Fragment>
)}
</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>
))
}
</React.Fragment>
);
CensoredMessage.propTypes = {
censoredByCommunity: PropTypes.bool,
messageHTML: PropTypes.string,
reshareable: PropTypes.bool
};

View file

@ -144,6 +144,7 @@ const PreviewPresentation = ({
} else if (visibilityInfo.censored) {
const censoredMessage = (
<CensoredMessage
censoredByCommunity={visibilityInfo.censoredByCommunity}
messageHTML={visibilityInfo.message}
reshareable={visibilityInfo.reshareable}
/>
@ -730,6 +731,8 @@ PreviewPresentation.propTypes = {
userOwnsProject: PropTypes.bool,
visibilityInfo: PropTypes.shape({
censored: PropTypes.bool,
censoredByAdmin: PropTypes.bool,
censoredByCommunity: PropTypes.bool,
message: PropTypes.string,
deleted: PropTypes.bool,
reshareable: PropTypes.bool

View file

@ -829,6 +829,8 @@ Preview.propTypes = {
userPresent: PropTypes.bool,
visibilityInfo: PropTypes.shape({
censored: PropTypes.bool,
censoredByAdmin: PropTypes.bool,
censoredByCommunity: PropTypes.bool,
message: PropTypes.string,
deleted: PropTypes.bool,
reshareable: PropTypes.bool