From 4df4ea893026959449a36906c23f00b003b21e5b Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 25 Jul 2016 16:58:38 -0400 Subject: [PATCH 1/2] Show an error to logged out users When logged out users visit the complete registration view, show them an error rather than a spinner. --- .../studentcompleteregistration.jsx | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/views/studentcompleteregistration/studentcompleteregistration.jsx b/src/views/studentcompleteregistration/studentcompleteregistration.jsx index 03a2e515a..76c58101b 100644 --- a/src/views/studentcompleteregistration/studentcompleteregistration.jsx +++ b/src/views/studentcompleteregistration/studentcompleteregistration.jsx @@ -90,30 +90,33 @@ var StudentCompleteRegistration = intl.injectIntl(React.createClass({ var demographicsDescription = this.props.intl.formatMessage({ id: 'registration.studentPersonalStepDescription'}); var registrationErrors = this.state.registrationErrors; - var sessionFetched = this.props.session.status === sessionStatus.FETCHED; - if (sessionFetched && - !(this.props.session.session.permissions.student && - this.props.session.session.flags.must_complete_registration)) { + if (this.props.session.status === sessionStatus.FETCHED && !( + this.props.session.session.permissions && + this.props.session.session.permissions.student && + this.props.session.session.flags.must_complete_registration) + ) { registrationErrors = { __all__: this.props.intl.formatMessage({id: 'registration.mustBeNewStudent'}) }; } return ( - {sessionFetched && this.state.classroom ? - (registrationErrors ? - -
    - {Object.keys(registrationErrors).map(function (field) { - var label = field + ': '; - if (field === '__all__') { - label = ''; - } - return (
  • {label}{registrationErrors[field]}
  • ); - })} -
-
- : + {registrationErrors ? ( + +
    + {Object.keys(registrationErrors).map(function (field) { + var label = field + ': '; + if (field === '__all__') { + label = ''; + } + return (
  • {label}{registrationErrors[field]}
  • ); + })} +
+
+ ) : ( + this.state.waiting || !this.state.classroom ? ( + + ) : ( ) - : - - } + )}
); } From 74f56d42c5b5f7cb0054f93214ac71e308e7ff24 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 25 Jul 2016 16:59:55 -0400 Subject: [PATCH 2/2] Explicitly show a spinner while loading class data To make this view work consistently with the complete registration view --- src/views/studentregistration/studentregistration.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/studentregistration/studentregistration.jsx b/src/views/studentregistration/studentregistration.jsx index bbfd7f719..142c4f65c 100644 --- a/src/views/studentregistration/studentregistration.jsx +++ b/src/views/studentregistration/studentregistration.jsx @@ -35,10 +35,12 @@ var StudentRegistration = intl.injectIntl(React.createClass({ }); }, componentDidMount: function () { + this.setState({waiting: true}); api({ uri: '/classrooms/' + this.props.classroomId, params: {token: this.props.classroomToken} }, function (err, body, res) { + this.setState({waiting: false}); if (err) { return this.setState({ registrationError: this.props.intl.formatMessage({