mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Merge pull request #615 from mewtaylor/bugfix/teacher-banner-login
[Bugfix] Add permissions dispatch for `WillReceiveProps`
This commit is contained in:
commit
fa5551ac0d
4 changed files with 11 additions and 9 deletions
|
@ -259,14 +259,14 @@ var Navigation = React.createClass({
|
||||||
<FormattedMessage id="general.myStuff" />
|
<FormattedMessage id="general.myStuff" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{this.props.session.session.permissions.educator ? [
|
{this.props.permissions.educator ? [
|
||||||
<li>
|
<li>
|
||||||
<a href="/educators/classes/">
|
<a href="/educators/classes/">
|
||||||
<FormattedMessage id="general.myClasses" />
|
<FormattedMessage id="general.myClasses" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
] : []}
|
] : []}
|
||||||
{this.props.session.session.permissions.student ? [
|
{this.props.permissions.student ? [
|
||||||
<li>
|
<li>
|
||||||
<a href={'/classes/' + this.props.session.session.user.classroomId + '/'}>
|
<a href={'/classes/' + this.props.session.session.user.classroomId + '/'}>
|
||||||
<FormattedMessage id="general.myClass" />
|
<FormattedMessage id="general.myClass" />
|
||||||
|
@ -335,7 +335,8 @@ var Navigation = React.createClass({
|
||||||
|
|
||||||
var mapStateToProps = function (state) {
|
var mapStateToProps = function (state) {
|
||||||
return {
|
return {
|
||||||
session: state.session
|
session: state.session,
|
||||||
|
permissions: state.permissions
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ var ReactDOM = require('react-dom');
|
||||||
var StoreProvider = require('react-redux').Provider;
|
var StoreProvider = require('react-redux').Provider;
|
||||||
|
|
||||||
var IntlProvider = require('./intl.jsx').IntlProvider;
|
var IntlProvider = require('./intl.jsx').IntlProvider;
|
||||||
|
var permissionsActions = require('../redux/permissions.js');
|
||||||
var sessionActions = require('../redux/session.js');
|
var sessionActions = require('../redux/session.js');
|
||||||
var reducer = require('../redux/reducer.js');
|
var reducer = require('../redux/reducer.js');
|
||||||
|
|
||||||
|
@ -42,7 +43,8 @@ var render = function (jsx, element) {
|
||||||
element
|
element
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get initial session
|
// Get initial session & permissions
|
||||||
|
store.dispatch(permissionsActions.getPermissions());
|
||||||
store.dispatch(sessionActions.refreshSession());
|
store.dispatch(sessionActions.refreshSession());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ var keyMirror = require('keymirror');
|
||||||
var defaults = require('lodash.defaults');
|
var defaults = require('lodash.defaults');
|
||||||
|
|
||||||
var api = require('../lib/api');
|
var api = require('../lib/api');
|
||||||
|
var permissionsActions = require('./permissions.js');
|
||||||
var tokenActions = require('./token.js');
|
var tokenActions = require('./token.js');
|
||||||
|
|
||||||
var Types = keyMirror({
|
var Types = keyMirror({
|
||||||
|
@ -75,6 +76,9 @@ module.exports.refreshSession = function () {
|
||||||
dispatch(tokenActions.getToken());
|
dispatch(tokenActions.getToken());
|
||||||
dispatch(module.exports.setSession(body));
|
dispatch(module.exports.setSession(body));
|
||||||
dispatch(module.exports.setStatus(module.exports.Status.FETCHED));
|
dispatch(module.exports.setStatus(module.exports.Status.FETCHED));
|
||||||
|
|
||||||
|
// get the permissions from the updated session
|
||||||
|
dispatch(permissionsActions.getPermissions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ var omit = require('lodash.omit');
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
|
||||||
var api = require('../../lib/api');
|
var api = require('../../lib/api');
|
||||||
var permissionsActions = require('../../redux/permissions.js');
|
|
||||||
var render = require('../../lib/render.jsx');
|
var render = require('../../lib/render.jsx');
|
||||||
var sessionActions = require('../../redux/session.js');
|
var sessionActions = require('../../redux/session.js');
|
||||||
var shuffle = require('../../lib/shuffle.js').shuffle;
|
var shuffle = require('../../lib/shuffle.js').shuffle;
|
||||||
|
@ -62,10 +61,6 @@ var Splash = injectIntl(React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
componentWillMount: function () {
|
|
||||||
// Determine whether to show the teacher banner or not
|
|
||||||
this.props.dispatch(permissionsActions.getPermissions());
|
|
||||||
},
|
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
this.getFeaturedGlobal();
|
this.getFeaturedGlobal();
|
||||||
if (this.props.session.session.user) {
|
if (this.props.session.session.user) {
|
||||||
|
|
Loading…
Reference in a new issue