Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-17555 Finish upgrading react-intl #4615

Merged
merged 16 commits into from
Jan 16, 2020
Merged

MM-17555 Finish upgrading react-intl #4615

merged 16 commits into from
Jan 16, 2020

Conversation

hmhealey
Copy link
Member

@hmhealey hmhealey commented Jan 3, 2020

This is the final PR to update to the new version of react-intl. Most of it should be nonfunctional stuff like updating snapshots and tests, but there's a few important things I wanted to call out:

  1. The biggest change that I didn't expect is that the version of react-bootstrap's OverlayTrigger that we use doesn't pass context correctly, so I had to make a custom version of OverlayTrigger to make it so that modals and popovers (like the profile popover) could be translated correctly. This change was merged as a separate PR.
  2. This is using @cometkim's new versions of shallowWithIntl and mountWithIntl, but I removed the step of them that unwraps calls to React.forwardRef since it wasn't necessary and it caused some problems when we were trying to test components that used forwardRef when it wasn't from injectIntl
  3. Related to the above, shallowWithIntl is only needed for testing components that use injectIntl, so I've removed it from all tests where it wasn't needed. Similarly, we no longer need to .dive into most components when testing them. This change was merged in a separate PR.
  4. React-intl now uses React.forwardRef to pass refs into injectIntl components. This was the big source of issues last time that we attempted this upgrade, but I think I've gone through and either tested or removed everywhere we did this

Ticket Link

https://mattermost.atlassian.net/browse/MM-17555

@hmhealey hmhealey added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jan 3, 2020
@hmhealey hmhealey added this to the v5.20.0 milestone Jan 3, 2020
@enahum
Copy link
Contributor

enahum commented Jan 7, 2020

@hmhealey can you push this PR to be tested first before I do the review, it is a very large PR and I would rather review it after having confirmation that nothing is broken.

@cometkim
Copy link
Collaborator

cometkim commented Jan 8, 2020

Not only OverlayTrigger, but also Tooltips have same context issue as well. it completely destroys the context API usage and causes memory leaks in VDOM. Wouldn't it be better to upgrade react-bootstrap first, even if it spends more time?

@hmhealey
Copy link
Member Author

hmhealey commented Jan 8, 2020

@enahum I'll see if I can do that, although we're in the release cycle right now, so it might be difficult. If it can't be reviewed right now, I'll look at breaking up this PR some more.

@cometkim I could implement a custom Tooltip replacement like OverlayTrigger, but what do you mean by it causing memory leaks? I wasn't aware of anything like that

@cometkim
Copy link
Collaborator

cometkim commented Jan 8, 2020

@hmhealey never mind. I suspected that because elements are duplicated in the inspector and never removed. It seems to be a bug in the inspector.

@hmhealey hmhealey added Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) and removed 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jan 8, 2020
@hmhealey hmhealey added Work in Progress Not yet ready for review and removed Work in Progress Not yet ready for review labels Jan 8, 2020
@hmhealey
Copy link
Member Author

hmhealey commented Jan 8, 2020

I'm going to break this up into a few more PRs wherever possible. I'll re-add reviewers once those PRs are in

@hmhealey
Copy link
Member Author

hmhealey commented Jan 8, 2020

@cometkim Have you found any specific instances where the Tooltip isn't passing the context correctly? It seems to be working fine everywhere I've checked

@hmhealey hmhealey added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jan 10, 2020
@hmhealey
Copy link
Member Author

This is ready for review again now that some of the large, distracting changes have been merged separately.

For dev reviewers, if you filter out the changes to the .snap files in GitHub, it'll make your live's a lot easier since there's a lot of renaming going on caused by react-intl renaming InjectIntl to injectIntl as the component's display name

Copy link
Member

@jespino jespino left a comment

Choose a reason for hiding this comment

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

LGTM

@jespino
Copy link
Member

jespino commented Jan 11, 2020

@hmhealey test are failing, probably related to the merge done

@jgilliam17 jgilliam17 added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Jan 13, 2020
@mattermod
Copy link
Contributor

Mattermost test server updated with git commit 4bd5bd9fadea827a4f46f25a63337cf202bd8ba6.

Access here: https://mattermost-webapp-pr-4615.test.mattermost.cloud

Copy link
Contributor

@enahum enahum left a comment

Choose a reason for hiding this comment

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

LGTM, one question as it seems weird, but not a blocker as long as it works

@@ -704,8 +704,8 @@ class CreateComment extends React.PureComponent {
if (index !== -1) {
uploadsInProgress.splice(index, 1);

if (this.refs.fileUpload && this.refs.fileUpload.getWrappedInstance() && this.refs.fileUpload.getWrappedInstance().getWrappedInstance()) {
this.refs.fileUpload.getWrappedInstance().getWrappedInstance().cancelUpload(id);
if (this.refs.fileUpload && this.refs.fileUpload.getWrappedInstance()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need getWrappedInstance even by using forwardRef ? that seems strange

Copy link
Member Author

Choose a reason for hiding this comment

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

The remaining getWrappedInstance is actually from connect. If that gets updated to use React.forwardRef, then we can remove the second getWrappedInstance

@enahum
Copy link
Contributor

enahum commented Jan 16, 2020

@hmhealey PR needs updating, @jgilliam17 please try and test the PR soon ;)

Copy link
Contributor

@jgilliam17 jgilliam17 left a comment

Choose a reason for hiding this comment

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

Tested, looks good to merge.

  • Verified Localizations, checked popovers and modals opened by the app
  • Verified invalid slash command trigger error
  • Verified using Alt + arrows to switch channels
  • Verified profile popover opens as expected
  • Able to log in/logout without any issues

@jgilliam17 jgilliam17 added QA Review Done and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Jan 16, 2020
@mattermod
Copy link
Contributor

Test server destroyed

@hmhealey hmhealey added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Jan 16, 2020
@hmhealey hmhealey merged commit 7b65d4e into master Jan 16, 2020
@hmhealey hmhealey deleted the mm17555-final branch January 16, 2020 20:15
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation QA Review Done
Projects
None yet
7 participants