Skip to content

Move students: success and error notifications#22190

Merged
maddiedierker merged 29 commits into
stagingfrom
move-students-pt4
May 4, 2018
Merged

Move students: success and error notifications#22190
maddiedierker merged 29 commits into
stagingfrom
move-students-pt4

Conversation

@maddiedierker

@maddiedierker maddiedierker commented May 4, 2018

Copy link
Copy Markdown
Contributor

This is PR no. 4 for rewriting the 'move students' functionality in React. For context, check out my previous PR or the spec.

This implements success and error notification functionality. Because success notifications live in the parent component (ManageStudentsTable), the code to render those notifications will be in the next (and final!) PR that hooks up the new 'move students' dialog to the 'manage students' tab.

Errors, on the other hand, are rendered in the 'move students' dialog itself using error text returned from the server.

Examples

screen shot 2018-05-03 at 5 04 24 pm

screen shot 2018-05-03 at 5 03 34 pm

@caleybrock caleybrock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

{
name: 'Move students dialog',
description: 'Ability to move students in a certain section to a different section or teacher',
description: 'Dialog when an error has occurred',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice addition

@islemaster islemaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excited_totally_wicked

sections={sections}
updateStudentTransfer={() => console.log('updating...')}
transferStudents={() => console.log('transferring...')}
cancelStudentTransfer={() => console.log('cancelling...')}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a storybook "actions" addon designed for stubbing callbacks like this, that logs to the onscreen console (not the developer console) and reports any arguments passed to the callback as well. Example:

import {action} from '@storybook/addon-actions';
export default storybook => {
return storybook
.storiesOf('MakerToolkit/ConfirmEnableMakerDialog', module)
.add('overview', () => {
return (
<ConfirmEnableMakerDialog
isOpen
handleConfirm={action('Confirm')}
handleCancel={action('Cancel')}
/>
);
});
};

{...DEFAULT_PROPS}
updateStudentTransfer={updateStudentTransfer}
transferStudents={transferStudents}
cancelStudentTransfer={cancelStudentTransfer}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to compose DEFAULT_PROPS and the spy callbacks in your beforeEach function, since you pass them in every single test.

);

wrapper.find('Button').simulate('click');
expect(cancelStudentTransfer.callCount).to.equal(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip: We've already got the sinon-chai assertions enabled so you can make assertions about spies and stubs like this:

expect(cancelStudentTransfer).not.to.have.been.called;
expect(cancelStudentTransfer).to.have.been.calledOnce;

@caleybrock

Copy link
Copy Markdown
Contributor

A little suggestion you can feel free to do later or not take if it's already discussed in the spec. For these cases it feels like the error message would make more sense to have right under where you entered the section.

@maddiedierker maddiedierker requested a review from nkiruka May 4, 2018 16:30
@maddiedierker

Copy link
Copy Markdown
Contributor Author

@caleybrock re: error message placement, i think you have a good point. poorva and i discussed the other day and decided to put the error at the top of the modal since the error won't always have to do with the section input--it could be a more general failure (although it'll usually be the former, so it might make sense to move it at some point...)

@maddiedierker maddiedierker merged commit f534170 into staging May 4, 2018
@maddiedierker maddiedierker deleted the move-students-pt4 branch May 4, 2018 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants