-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix expand active order in ReviewChapters #267
Conversation
Will push up a test and prod files shortly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might there be similar problems with SubmitController, getPageKeys, or getActiveChapters since they use the old order? Should there be a getExpandedActivePages
defined to prevent someone calling these in the wrong order?
src/js/review/ReviewChapters.jsx
Outdated
@@ -125,8 +125,8 @@ function mapStateToProps(state, ownProps) { | |||
const chapters = chapterNames.map(chapterName => { | |||
const pages = pagesByChapter[chapterName]; | |||
|
|||
const activePages = getActivePages(pages, formData); | |||
const expandedPages = expandArrayPages(activePages, formData); | |||
let expandedPages = expandArrayPages(pages, formData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why let
here and not const
? You can always nest the expandArrayPages()
in the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nesting seemed less readable than this, but I'm happy to change it if you'd prefer.
@dmethvin-gov Yeah, looks like those need changing and also the helper function seems like a good idea. |
@@ -106,7 +104,7 @@ class ReviewChapters extends React.Component { | |||
} | |||
} | |||
|
|||
function mapStateToProps(state, ownProps) { | |||
export function mapStateToProps(state, ownProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how you all feel about this. We made the changes in here to put more code in mapStateToProps because it's more testable, but in order to test it directly, we need to export it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More testing is always good. In this case it's testing a lot of implementation and plumbing details so not ideal, but the test is clearly marked so if it breaks during a refactor it should be clear why.
@dmethvin-gov Should be ready for another look. |
This duo of calls seems to be everywhere, here's another one in FormNav. Can you look around and see if I missed any others? Would it be possible to not export one or both of the two individual functions, are they used separately for any reason? |
I found the FormNav one when I took another pass through, but didn't see any others. I did see some uses of the functions on their own, but I didn't look too deeply at if that was valid. I will take another look at that on Monday. |
@dmethvin-gov I looked through for uses of just I think all this code was missing because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, otherwise LGTM!
*/ | ||
export function transformForSubmit(formConfig, form, replacer = stringifyFormReplacer) { | ||
const expandedPages = expandArrayPages(createFormPageList(formConfig), form.data); | ||
const activePages = getActivePages(expandedPages, form.data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not using getActiveExpandedPages
here if it's doing these same 2 checks in this order? Because we need to calculate expandedPages
separately for the next function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought it was useful to used the expandedPage array for both of the following function calls and make it clear that we're using the same base data to get the active and inactive page lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's what it seemed like. Feel free to merge this when you're ready @jbalboni!
@annekainicUSDS I think you'll have to merge it, I don't have write access here. |
@jbalboni Oops sorry! Will merge now. |
) Fix expand active order (cherry picked from commit b667241) Add build files (cherry picked from commit 7b8b325) Add tests and export (cherry picked from commit 56c8743) Add helper function (cherry picked from commit 31fd754) Fix typo (cherry picked from commit e999396) Fix bad change (cherry picked from commit ccd28fa) Run prod build (cherry picked from commit 4fb0362) Update nav with new helper Update transform to handle pagePerItem depends functions (cherry picked from commit 5ece651) Cleanup usds#267 PR cherry pick (dmethvin-gov)
This swaps the order of
getActivePages
andexpandArrayPages
to matchrouting.js
.<Addresses/Closes> #266
Types of changes
Checklist:
npm run lint
.npm run build
.npm test
.