Skip to content
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

[WIP] Upgrade antd to 4.24.8 #1261

Closed
wants to merge 15 commits into from

Conversation

mszabo-wikia
Copy link
Contributor

Which problem is this PR solving?

Short description of the changes

Initial upgrade work for the antd v4 migration.

Notable changes:

  • AntD v4 uses individual icon imports rather than a generic Icon component with a string type. This way, it doesn't have to include the full SVG sprite, only the used icons, reducing the gzipped bundle size by ~110 kB. The migration is done mostly automatically by @ant-design/codemod-v4 except for some dynamic icon usages that were updated by hand in 4b79a68.
  • AntD v4 requires a newer version of React typings, which also required an explicit Yarn resolution to avoid pulling in other versions of the typings.
  • React refs for AntD Input components need a typing update.
  • The NumberInput component now guarantees to return number | null, so some custom type-checking code related to that can be removed.
  • Typings changed around the Table component around row selection and sorting logic, requiring appropriate updates. In particular, sorting by multiple sortable columns now reports all columns that are active in sorting, so event handling code must also accept an array.
  • The trace search form needs a workaround to function with redux-form, as AntD Forms no longer expose an onSubmit event that this library could hook into. For now, this is done by attaching the submit callback directly to the submit button instead as a click handler (which, somehow, still catches Enter keypresses on the search form).

Known issues

  • There are some visual regressions that will need styling fixes.
  • Tests need updating.

@mszabo-wikia
Copy link
Contributor Author

mszabo-wikia commented Mar 12, 2023

Looking at redux-form, this library does not actually seem very useful. Redux itself recommends not to put form state in the Redux store, which the author of this library also seems to have come to agree with. Out of all forms in the project using this library, only the trace search form sets destroyOnUnmount: false to actually persist the form data even after the form itself is unmounted, and even there the form state can be reconstructed from URL parameters, which the mapping logic already does. Nothing else seems to be operating on the raw form data other than the respective form components, either.

It could be potentially worth it (as a separate project) to just remove this.

@yurishkuro
Copy link
Member

@mszabo-wikia does redux-form need to be tackled in this PR or incidentally related? I opened another issue #1260 for Redux upgrade, it probably makes sense to tackle all Redux-related changed there (assuming they can be decoupled)

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

I would prefer to go through all visual changes to make sure they are still sensible for Jaeger UI. Although, just the icon changes seem fine to accept on code review, if that's the extent.

.gitignore Outdated
@@ -13,11 +13,14 @@ coverage
.nyc_output
junit.xml

# IDE-related files and directories
Copy link
Member

Choose a reason for hiding this comment

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

Some people insist that these should be handled via the user's local workspace settings, e.g. adding

[core]
        excludesfile = /Users/{your home}/.gitignore_global

to ~/.gitconfig and then defining global ignore rules.

But I personally do not mind these being in .gitignore since they prevent them from being checked in accidentally (although I'm likely biased because vscode and idea are very common, if this was more exotic IDE then ...).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I didn't know about the global option, that makes sense. I'll probably rebase away this commit since I only added it in the first place to be able to run the codemod, which wouldn't start with uncommitted files present.

return (
<Form layout="vertical" onSubmit={handleSubmit}>
Copy link
Member

Choose a reason for hiding this comment

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

When the handler was previously on the form itself, what did it mean? Could one submit the form by hitting Enter from any field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty much. Surprisingly though, that still works for me locally even with the handler moved to the submit button.

@@ -174,7 +174,7 @@ export default class TraceSpanView extends Component<Props, State> {
return (
<div>
<h3 className="title--TraceSpanView"> Trace Tabular View</h3>
<Row type="flex" style={{ marginTop: '8px' }}>
Copy link
Member

Choose a reason for hiding this comment

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

what did type="flex" do? Seems important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prop was removed and it seems it's no longer needed. In v3, it was used to control whether to set display: flex on the row but in v4 this seems to be unconditional.

@mszabo-wikia
Copy link
Contributor Author

I think redux-form need not be changed in this PR—the submit button event handler seems like a reasonable workaround for now, and the other forms don't seem to be using handleSubmit in this problematic way.

For the visual regressions, the main issue I noticed so far is a header size bug due to some Menu component updates; this should be fixable with some CSS. The icons should be the same as their design shouldn't have changed as far as I see, only the way they are referenced.

Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
@mszabo-wikia
Copy link
Contributor Author

Closing this as there is great work ongoing in #1636 and followups.

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.

2 participants