-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor(1576): Upgrade react-router packages and refactor related components #1506
refactor(1576): Upgrade react-router packages and refactor related components #1506
Conversation
c034753
to
9e91149
Compare
9e91149
to
db1e594
Compare
946352e
to
f7ff522
Compare
@dependabot rebase |
Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 5.3.0 to 6.2.1. - [Release notes](https://github.com/remix-run/react-router/releases) - [Commits](https://github.com/remix-run/react-router/commits/v6.2.1/packages/react-router-dom) --- updated-dependencies: - dependency-name: react-router-dom dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
f7ff522
to
fee4a9b
Compare
6413396
to
9591ea8
Compare
|
Additionally, a package we use |
…into dependabot/npm_and_yarn/tdrs-frontend/raft-tdp-main/react-router-dom-6.2.1
0a947d7
to
19ead36
Compare
…into dependabot/npm_and_yarn/tdrs-frontend/raft-tdp-main/react-router-dom-6.2.1
Codecov Report
@@ Coverage Diff @@
## raft-tdp-main #1506 +/- ##
=================================================
- Coverage 97.58% 97.31% -0.27%
=================================================
Files 80 80
Lines 1902 1902
Branches 249 249
=================================================
- Hits 1856 1851 -5
- Misses 22 24 +2
- Partials 24 27 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
/* istanbul ignore if */ | ||
if (menuRef.current.classList.contains('is-visible')) { | ||
e.preventDefault() | ||
console.log('is visible') |
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.
Is logging now handled elsewhere? Or was this unnecessary before?
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.
Logging to the console like this is generally unnecessary
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.
Found no issues locally, LGTM
@@ -144,7 +144,7 @@ function EditProfile() { | |||
} | |||
|
|||
if (requestedAccess && sttAssigned) { | |||
return <Redirect to="/request" /> | |||
return <Navigate to="/request" /> |
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.
All instances of Redirect
are converted to Navigate
@@ -450,15 +452,39 @@ describe('EditProfile', () => { | |||
], | |||
}, | |||
}) | |||
const wrapper = mount( | |||
|
|||
render( |
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.
Note that we are rewriting enzyme tests with react-testing-library everywhere possible when we encounter them
</PrivateRoute> | ||
} | ||
/> | ||
<Route |
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.
Route
can only exist as a child of Routes
now
const keyListenersMap = useMemo(() => { | ||
let tabIndex = 0 | ||
/* istanbul ignore next */ | ||
const handleTabKey = (e) => { | ||
/* istanbul ignore if */ | ||
if (menuRef.current.classList.contains('is-visible')) { | ||
e.preventDefault() | ||
const focusableMenuElements = [ | ||
...menuRef.current.querySelectorAll('button'), | ||
...menuRef.current.querySelectorAll('a'), | ||
] | ||
|
||
const firstElement = focusableMenuElements[0] | ||
const lastIndex = focusableMenuElements.length - 1 | ||
const lastElement = focusableMenuElements[lastIndex] | ||
const lastIndex = focusableMenuElements.length - 1 | ||
|
||
if (focusableMenuElements.includes(document.activeElement)) { | ||
if (!e.shiftKey && tabIndex >= lastIndex) { | ||
tabIndex = 0 | ||
} else if (e.shiftKey && tabIndex === 0) { | ||
tabIndex = lastIndex | ||
} else if (e.shiftKey) { | ||
tabIndex -= 1 | ||
if (focusableMenuElements.includes(document.activeElement)) { | ||
if (!e.shiftKey && tabIndex >= lastIndex) { | ||
tabIndex = 0 | ||
} else if (e.shiftKey && tabIndex === 0) { | ||
tabIndex = lastIndex | ||
} else if (e.shiftKey) { | ||
tabIndex -= 1 | ||
} else { | ||
tabIndex += 1 | ||
} | ||
} else { | ||
tabIndex += 1 | ||
tabIndex = 0 | ||
} | ||
} else { | ||
tabIndex = 0 | ||
|
||
focusableMenuElements[tabIndex].focus() | ||
} | ||
|
||
focusableMenuElements[tabIndex].focus() | ||
return false | ||
} | ||
|
||
return false | ||
} | ||
|
||
const keyListenersMap = new Map([[9, handleTabKey]]) | ||
return new Map([[9, handleTabKey]]) | ||
}, [menuRef]) | ||
|
||
/* istanbul ignore next */ | ||
useEffect(() => { | ||
function keyListener(e) { | ||
const listener = keyListenersMap.get(e.keyCode) | ||
return listener && listener(e) | ||
} | ||
|
||
document.addEventListener('keydown', keyListener) | ||
|
||
return () => document.removeEventListener('keydown', keyListener) | ||
}, []) | ||
}, [keyListenersMap]) |
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.
All of this is just refactored for clarity and to remove unneeded logic and linter warnings
@@ -15,39 +18,62 @@ describe('LoginCallback.js', () => { | |||
const store = mockStore({ | |||
auth: { authenticated: true, user: { email: 'hi@bye.com' } }, | |||
}) | |||
const wrapper = mount( | |||
|
|||
render( |
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.
Again, migrate from enzyme's mount
to render
) : null | ||
} | ||
|
||
PrivateRoute.propTypes = { |
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.
We need to move away from PropTypes as this is unhelpful noise.
<IdleTimer /> | ||
</PrivateTemplate> | ||
</Route> | ||
<PrivateTemplate title={title}> |
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.
Note we are no longer wrapping this with Route
, and it is handled higher up in the tree
<NoMatch /> | ||
</Route> | ||
</Switch> | ||
<Routes> |
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.
Switch
is now Routes
@@ -2,7 +2,7 @@ import React from 'react' | |||
import ReactDOM from 'react-dom' | |||
import axios from 'axios' | |||
|
|||
import { ConnectedRouter as Router } from 'connected-react-router' | |||
import { ReduxRouter as Router } from '@lagunovsky/redux-react-router' |
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.
The replacement for connected-react-router
has a very similar api and only requires a few additions to our root Router and Reducer below
…into dependabot/npm_and_yarn/tdrs-frontend/raft-tdp-main/react-router-dom-6.2.1
"file-type": "^16.5.3", | ||
"history": "^4.7.2", | ||
"history": "^5.2.0", |
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.
This was updated as the older version caused a conflict with the new one needed in react-router-dom
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.
lgtm @jorgegonzalez 👍🏾
…nd/raft-tdp-main/react-router-dom-6.2.1
Summary of Changes
This dependabot PR was co-opted for react-router upgrades and refactoring.
Pull request closes #1576
Acceptance criteria as stated in the issue
How to Test
List the steps to test the PR
These steps are generic, please adjust as necessary.
Deliverables
More details on how deliverables herein are assessed included here.
Deliverable 1: Accepted Features
Checklist of ACs:
react-router
andreact-router-dom
are ugraded to latest major versionlfrohlich
and/oradpennington
confirmed that ACs are met.Deliverable 2: Tested Code
CodeCov Report
comment in PR)CodeCov Report
comment in PR)Deliverable 3: Properly Styled Code
Deliverable 4: Accessible
iamjolly
andttran-hub
using Accessibility Insights reveal any errors introduced in this PR?n/a: no user facing changes
Deliverable 5: Deployed
Deliverable 6: Documented
Deliverable 7: Secure
Deliverable 8: User Research
Research product(s) clearly articulate(s):