mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -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" />
|
||||
</a>
|
||||
</li>
|
||||
{this.props.session.session.permissions.educator ? [
|
||||
{this.props.permissions.educator ? [
|
||||
<li>
|
||||
<a href="/educators/classes/">
|
||||
<FormattedMessage id="general.myClasses" />
|
||||
</a>
|
||||
</li>
|
||||
] : []}
|
||||
{this.props.session.session.permissions.student ? [
|
||||
{this.props.permissions.student ? [
|
||||
<li>
|
||||
<a href={'/classes/' + this.props.session.session.user.classroomId + '/'}>
|
||||
<FormattedMessage id="general.myClass" />
|
||||
|
@ -335,7 +335,8 @@ var Navigation = React.createClass({
|
|||
|
||||
var mapStateToProps = function (state) {
|
||||
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 IntlProvider = require('./intl.jsx').IntlProvider;
|
||||
var permissionsActions = require('../redux/permissions.js');
|
||||
var sessionActions = require('../redux/session.js');
|
||||
var reducer = require('../redux/reducer.js');
|
||||
|
||||
|
@ -42,7 +43,8 @@ var render = function (jsx, element) {
|
|||
element
|
||||
);
|
||||
|
||||
// Get initial session
|
||||
// Get initial session & permissions
|
||||
store.dispatch(permissionsActions.getPermissions());
|
||||
store.dispatch(sessionActions.refreshSession());
|
||||
};
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ var keyMirror = require('keymirror');
|
|||
var defaults = require('lodash.defaults');
|
||||
|
||||
var api = require('../lib/api');
|
||||
var permissionsActions = require('./permissions.js');
|
||||
var tokenActions = require('./token.js');
|
||||
|
||||
var Types = keyMirror({
|
||||
|
@ -75,6 +76,9 @@ module.exports.refreshSession = function () {
|
|||
dispatch(tokenActions.getToken());
|
||||
dispatch(module.exports.setSession(body));
|
||||
dispatch(module.exports.setStatus(module.exports.Status.FETCHED));
|
||||
|
||||
// get the permissions from the updated session
|
||||
dispatch(permissionsActions.getPermissions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ var omit = require('lodash.omit');
|
|||
var React = require('react');
|
||||
|
||||
var api = require('../../lib/api');
|
||||
var permissionsActions = require('../../redux/permissions.js');
|
||||
var render = require('../../lib/render.jsx');
|
||||
var sessionActions = require('../../redux/session.js');
|
||||
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 () {
|
||||
this.getFeaturedGlobal();
|
||||
if (this.props.session.session.user) {
|
||||
|
|
Loading…
Reference in a new issue