Merge pull request #2777 from LLK/develop

Merge develop into release branch 02-13-2019
This commit is contained in:
Paul Kaplan 2019-02-13 19:19:34 -05:00 committed by GitHub
commit fd95283cf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 26 deletions

View file

@ -98,7 +98,7 @@
"react-responsive": "3.0.0",
"react-slick": "0.16.0",
"react-string-replace": "0.4.1",
"scratch-gui": "0.1.0-prerelease.20190207214203",
"scratch-gui": "0.1.0-prerelease.20190213213304",
"react-telephone-input": "4.3.4",
"redux": "3.5.2",
"redux-thunk": "2.0.1",

View file

@ -2,6 +2,7 @@ const keyMirror = require('keymirror');
const defaults = require('lodash.defaults');
const api = require('../lib/api');
const jar = require('../lib/jar');
const log = require('../lib/log.js');
const sessionActions = require('./session.js');
@ -138,16 +139,20 @@ module.exports.handleLogIn = (formData, callback) => (dispatch => {
});
});
module.exports.handleLogOut = () => (dispatch => {
api({
host: '',
method: 'post',
uri: '/accounts/logout/',
useCsrf: true
}, err => {
if (err) log.error(err);
dispatch(module.exports.setLoginOpen(false));
dispatch(module.exports.setAccountNavOpen(false));
window.location = '/';
module.exports.handleLogOut = () => (() => {
// POST to /accounts/logout using a dummy form instead of XHR. This ensures
// logout only happens AFTER onbeforeunload has the chance to prevent nagivation.
jar.use('scratchcsrftoken', '/csrf_token/', (err, csrftoken) => {
if (err) return log.error('Error while retrieving CSRF token', err);
const form = document.createElement('form');
form.setAttribute('method', 'POST');
form.setAttribute('action', '/accounts/logout/');
const csrfField = document.createElement('input');
csrfField.setAttribute('type', 'hidden');
csrfField.setAttribute('name', 'csrfmiddlewaretoken');
csrfField.setAttribute('value', csrftoken);
form.appendChild(csrfField);
document.body.appendChild(form);
form.submit();
});
});

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

@ -410,6 +410,9 @@ class Preview extends React.Component {
this.setState({isProjectLoaded: true});
}
pushHistory (push) {
// Do not push history for projects without a real ID
if (this.state.projectId === '0') return;
// update URI to match mode
const idPath = this.state.projectId ? `${this.state.projectId}/` : '';
let modePath = '';
@ -829,6 +832,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