Skip to content

Move students: Add redux, UI tweaks, refactoring#22138

Merged
maddiedierker merged 21 commits into
stagingfrom
move-students-pt3
May 3, 2018
Merged

Move students: Add redux, UI tweaks, refactoring#22138
maddiedierker merged 21 commits into
stagingfrom
move-students-pt3

Conversation

@maddiedierker

@maddiedierker maddiedierker commented May 1, 2018

Copy link
Copy Markdown
Contributor

This is the third in a series of PRs to rewrite 'move students' in React. Previous PR here, spec here, and Axisoft ticket here.

These changes include:

  • Add transferStudents to redux
  • UI tweaks: disable 'Move students' button until the following conditions are met (images at very bottom of comment to illustrate):
    1. at least 1 student is chosen
    2. a section is chosen from the dropdown (if moving to a section owned by the same teacher), OR a section code is input (if moving to a section owned by a different teacher)
  • Refactor state to manageStudentsRedux that previously lived in the MoveStudents component (includes some renaming for clarity in context of reducer rather than component)
  • Refactor MoveStudents unit tests to test event simulation rather than output of helper methods (these are basically totally rewritten, so I'm sorry that the diff is confusing)

Conditions to enable 'Move students' button:
screen shot 2018-05-01 at 3 11 04 pm
screen shot 2018-05-01 at 3 10 48 pm

What's left?

  • Add success/error/information notifications after moving students
  • Sort students alphabetically on initial modal open
  • Style tweaks
  • Update storybook
  • Incorporate /sections/transfers endpoint changes and UI changes once new 'move students' is ready
  • Remove old code
  • & feedback!

@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.

Just a few little comments, but overall, this looks great! I particularly like the use of redux - I think it makes it clear how everything is working together.

import BaseDialog from '../BaseDialog';
import DialogFooter from "../teacherDashboard/DialogFooter";
import {sectionsNameAndId} from '@cdo/apps/templates/teacherDashboard/teacherSectionsRedux';
import {updateStudentTransfer, transferStudents, OTHER_TEACHER, COPY_STUDENTS, blankStudentTransfer} from './manageStudentsRedux';

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.

nit: This line is too long, break up into multiple.

header: {
label: i18n.name(),
props: {
id: 'name-header',

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.

nit: when these are for testing only, we typically prepend with uitest like this:

className="uitest-set-up-sections"

export const transferStudents = () => {
return (dispatch, getState) => {
const state = getState();
const currentSectionCode = sectionCode(state, state.manageStudents.sectionId);

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.

Given our original concern, might be good to have a comment here pointing out we are pulling information from another part of the redux state tree.

@maddiedierker

Copy link
Copy Markdown
Contributor Author

all good points, @caleybrock! i've updated my PR with your feedback, and fixed the storybook for this component since it caused some tests in circleci to fail

@davidsbailey davidsbailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

great progress Maddie! A few misc comments below.

// OTHER_TEACHER - value determines whether students will be moved to a section owned by a different teacher
// COPY_STUDENTS - value determines whether students will be copied to the new section or moved (and subsequently removed from current section)
export const OTHER_TEACHER = "otherTeacher";
export const COPY_STUDENTS = "copy";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: life might be easier in some future debugging session if this value is "copyStudents" rather than just "copy"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, it would be more consistent with our style to write the comment closer to each constant, e.g.:

// Constants around moving students to another section.

// whether students will be moved to a section owned by a different teacher
export const OTHER_TEACHER = "otherTeacher";

// ...
export const COPY_STUDENTS = "copyStudents";

export const COPY_STUDENTS = "copy";

/** Initial state for manageStudents.transferData redux store.
* studentIds - student ids selected to be moved to another section

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For multi-line comments we follow the style shown here, with comment starting on the next line, and aligning with the first *, and ending with */ like this:

/**
 * Initial state...
 * ...
 */

I know it's no fun to receive arbitrary style corrections, but we believe it'll make our code more readable if we follow our style guide closely.

import {expect} from '../../../util/configuredChai';
import {UnconnectedMoveStudents as MoveStudents, DEFAULT_STATE} from '@cdo/apps/templates/manageStudents/MoveStudents';
import sinon from 'sinon';
import {blankStudentTransfer} from '@cdo/apps/templates/manageStudents/manageStudentsRedux';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice reuse!

@maddiedierker

Copy link
Copy Markdown
Contributor Author

@davidsbailey thank you! i agree about having a cohesive style, so i don't mind stylistic nits at all 😃

updateStudentTransfer(transferData) {
dispatch(updateStudentTransfer(transferData));
},
transferStudents(studentIds, currentSectionCode, newSectionCode, copyStudents) {

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.

I think these params aren't needed.

@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.

Awesome test coverage!

@maddiedierker maddiedierker merged commit 8ab8c39 into staging May 3, 2018
@maddiedierker maddiedierker deleted the move-students-pt3 branch May 3, 2018 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants