-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
ui: Upgrade React version and react-dependent libraries #43846
Conversation
const ossName = getComponentName(OSSComponent); | ||
const cclName = getComponentName(CCLComponent); | ||
|
||
class LicenseSwap extends React.Component<TProps & OwnProps> { | ||
class LicenseSwap extends React.Component<TProps & OwnProps & any> { |
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.
Following hack with &any type is required to make changes related to types only and do not rewrite component logic.
cd8f3e5
to
9198891
Compare
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.
Thanks for this huge undertaking @koorosh! My only major concern is whether the restructuring the mapDispatchToProps
is necessary. See my comments for the approach I looked at.
@@ -180,7 +180,7 @@ export class CachedDataReducer<TRequest, TResponseMessage> { | |||
* state given the global state object | |||
*/ | |||
refresh = <S>(req?: TRequest, stateAccessor = (state: any, _req: TRequest) => state.cachedData[this.actionNamespace]) => { | |||
return (dispatch: Dispatch<S>, getState: () => any) => { | |||
return (dispatch: Dispatch<Action, TResponseMessage>, getState: () => S) => { |
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.
I noticed that in the rest of the PR that everywhere refreshNodes
was used we needed to add the arrow function + bindActionCreators
wrapping.
I tried adding a ThunkAction<any, S, any>
type to the refresh
function like below and it seemed to remove the need for the arrow function wrapping in the connect
function, would you mind trying out?
refresh = <S>(req?: TRequest,
stateAccessor = (state: any, _req: TRequest) => state.cachedData[this.actionNamespace]):
ThunkAction<any, S, any> => {
return (dispatch: Dispatch<Action, S>, getState: () => S) => {
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.
Awesome, it makes code much cleaner! Thanks!
@@ -178,9 +176,9 @@ const eventBoxConnected = connect( | |||
eventsValid: eventsValidSelector(state), | |||
}; | |||
}, | |||
{ | |||
() => ({ |
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.
I think this is unnecessary and the one below.
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.
Agree. Removed unnecessary function wrappers across all project
2f6d900
to
478a7d9
Compare
With current changes, react is upgraded to latest version (16.12.0) and following libraries are upgraded as well: react-redux, redux, redux-saga. These upgrades of major versions has required to do some code adjustments to properly migrate to newest versions. - redux. Provide valid type arguments for Dispatch type. - redux-saga. Changed import and usage of 'delay' function. - react-redux. `connect` function failed to correctly resolve returned type for `mapDispatchToProps` argument. As result it is provided as a function instead of object argument. This hack allows implicitly resolve types. - `CachedDataReducer` class is extended with one more optional type argument to specify the list of allowed `actionNamespace` literals instead of `string`. It was necessary to have strictly defined CachedDataReducer interface. - `normalizeConnectedComponent` function is used to do simple mapping from react's ExoticComponent to valid react component. This resolves issue of providing ConnectedComponents (which are ExoticComponent's, not regular react components) to Route component which has strict type validation of component types. Release note: None
Release note: None
- tests command is disabled for now because current state doesn't contain all fixes to run tests without failure. - Decommissioned Node History page was added so code has to be adjusted. Release note: None
Redux Actions for some components (ClusterOverview, NodesLogs, Statements page, and Node Maps) were not properly binded. As result component were not provided with data, and weren't rendered. To fix this, actions are wrapped with 'bindActionCreators' helper. Release note: None
- Issue: nfl/react-helmet#373 - Workaround: nfl/react-helmet#373 (comment) Release note: None
- get rid of unnecessary wrapping action creators with bindActionCreators function - define correct return type for cachedDataReducer.refresh action Release note: None
Release note: None
Remove useless function wrapper for action creator object Release note: None
c5d6e00
to
7f94c61
Compare
Release note: None
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. Thanks for the updates!
bors r+ |
43846: ui: Upgrade React version and react-dependent libraries r=dhartunian a=Koorosh - Has to merged after: #43685 - Depends on cockroachdb/yarn-vendored#13 Current PR has affected a lot of files but most of changes are almost the same and do not affect business logic. With current changes, react is upgraded to latest version (16.12.0) and following libraries are upgraded as well: react-redux, redux, redux-saga. These upgrades of major versions has required to do some code adjustments to properly migrate to newest versions. - redux. Provide valid type arguments for Dispatch type. - redux-saga. Changed import and usage of 'delay' function. - react-redux. `connect` function failed to correctly resolve returned type for `mapDispatchToProps` argument. As result it is provided as a function instead of object argument. This hack allows implicitly resolve types. - `CachedDataReducer` class is extended with one more optional type argument to specify the list of allowed `actionNamespace` literals instead of `string`. It was necessary to have strictly defined CachedDataReducer interface. - `normalizeConnectedComponent` function is used to do simple mapping from react's ExoticComponent to valid react component. This resolves issue of providing ConnectedComponents (which are ExoticComponent's, not regular react components) to Route component which has strict type validation of component types. Co-authored-by: Andrii Vorobiov <[email protected]>
Build succeeded |
44078: ui: Tests on react-routing components r=dhartunian a=Koorosh Depends on PR: #43846 `yarn-vendor` PR has to be merged: cockroachdb/yarn-vendored#15 Current PR includes minimal changes to functionality (only those which are required to isolate or get access to individual components under tests): - `src/index.tsx` file has been refactored into two parts: rendering to DOM and independent `App` component; - <Helmet> component (`react-helmet` library) has been refactored to avoid known issue during tests execution (nfl/react-helmet#373) - old version of react-router and `connect` component in tandem do not work well because connected component aren't valid react components. As result validation for correct routing was done by re-exporting wrapped components (instead of connected). It allowed to simplify testing with `enzyme#find` function which requires valid react component as an argument; - Tests are grouped in suites per route to maintain related tests per route; - There is two kinds of tests which test correct rendering of component for specific test and another test which validates correct redirection for routes; - Tests can be refactored to be constructed from configuration to reduce repeated tests, but it will be actual after migrating to latest version of react-router lib. 44545: sqlbase: add table generator for edge case datums r=rohany a=rohany Part of work for #44322. This PR adds a testing utility to generate a table full of edge case datums to test a variety of things in the future. Release note: None Co-authored-by: Andrii Vorobiov <[email protected]> Co-authored-by: Rohan Yadav <[email protected]>
Current PR has affected a lot of files but most of changes are almost the same
and do not affect business logic.
With current changes, react is upgraded to latest version (16.12.0) and
following libraries are upgraded as well: react-redux, redux, redux-saga.
These upgrades of major versions has required to do some code adjustments
to properly migrate to newest versions.
connect
function failed to correctly resolve returned typefor
mapDispatchToProps
argument. As result it is provided as a functioninstead of object argument. This hack allows implicitly resolve types.
CachedDataReducer
class is extended with one more optional type argumentto specify the list of allowed
actionNamespace
literals instead ofstring
.It was necessary to have strictly defined CachedDataReducer interface.
normalizeConnectedComponent
function is used to do simple mapping fromreact's ExoticComponent to valid react component. This resolves issue of
providing ConnectedComponents (which are ExoticComponent's, not regular react
components) to Route component which has strict type validation of component types.