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

Upgrade antd to v4.15.6 #1748

Merged
merged 4 commits into from Sep 2, 2023
Merged

Conversation

anshgoyalevil
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Disabled the NavBar hover effect which was un-necessarily introduced
  • NavBar's height was increased internally. Fixed it to match previous height (48px)
  • The Monitor -> EmptyPage was using the offsets to align content to the center, but it is not required now, as it is a default behavior
  • SorterResult API is removed, so used lodash in place of that
  • CompareFn typedef is no longer required
  • Mocked the window.matchMedia, since some tests were using it
  • dataIndex now requires an array instead of nested string. Ex: "abc.def.ghi" -> ["abc", "def", "ghi"]
  • Tests are updated according to these changes
  • Snapshots are updated according to internal changes in components

How was this change tested?

  • Manually, and using automated testing

What's next?

  • In the next PRs, the antd would be upgraded to 4.20.0 (or higher), to minimise the changes in a single PR.
  • New type errors would be introduced thereby, like NumberInput lookback changes, etc.

Checklist

Signed-off-by: Ansh Goyal <anshgoyal1704@gmail.com>
Signed-off-by: Ansh Goyal <anshgoyal1704@gmail.com>
@@ -32,7 +32,7 @@ export default class MonitorATMEmptyState extends React.PureComponent {
return (
<Col>
<Row justify="center">
<Col span={8} offset={8}>
Copy link
Member

Choose a reason for hiding this comment

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

doesn't removing offset change the position of the column? When I see <Col span={8} offset={8}> I interpret it "start from column 8 and span columns 8-15"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously (in antd 3x), the <Col span={8}> was interpreted as, "The width of column should be 8 boxes out of the 24 boxes in a grid".
That offset property defines that those 8 boxes must start from the 9th box out of those 24 boxes so that basically centers the col.

In antd 4x, this behavior is controlled by <Row justify="center">. Don't know why it was not working previously in 3x, even though it existed before too.

Here's what the page looks like now:

image


if (!isEqual(activeSorters, tableSorting)) {
const lastColumn =
activeSorters[activeSorters.length - 1] ?? tableSorting[tableSorting.length - 1];
Copy link
Member

Choose a reason for hiding this comment

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

if both arrays are empty, isn't it possible to end up with lastColumn = undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But, I think, in that case, the onChange function wouldn't be called.
Whenever someone clicks the table header for sorting, the tableSorting or activeSorters would always return an array of size greater than or equal to 1.

onChange={(pagination, filters, { columnKey, order }) => {
if (!isEqual({ columnKey, order }, this.state.tableSorting)) {
const clickedColumn = tableTitles.get(columnKey || this.state.tableSorting.columnKey);
onChange={(pagination, filters, sorter) => {
Copy link
Member

Choose a reason for hiding this comment

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

what specifically is changing in antd that requires these modifications, which look more complicated than before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In antd 4x, sorting by multiple sortable columns now reports all columns that are active in sorting, so the event handling code must also accept an array.

});

it('hides navigation buttons when not navigable', () => {
wrapper.setProps({ navigable: false });
const button = wrapper.find('Button');
expect(button.length).toBe(1);
expect(button.prop('icon')).toBe('close');
expect(button.getElement(CloseOutlined)).toBeDefined();
Copy link
Member

Choose a reason for hiding this comment

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

can you not look it up by data-testid to avoid explicit dependency on ant icons?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, maybe it could be done that way too. I will try and update.

@@ -133,7 +133,7 @@ export default class TraceSpanView extends Component<Props, State> {
const columns: ColumnProps<Span>[] = [
{
title: 'Service Name',
dataIndex: 'process.serviceName',
dataIndex: ['process', 'serviceName'],
Copy link
Member

Choose a reason for hiding this comment

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

is this our own notation or something that antd component supports, like a nested indexing path into a data structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

antd dataIndex definition changes from 'xxx.yyy' to ['xxx', 'yyy'].
So basically, antd now want us to supply dataIndex path in the form of an array for nested indexing pathnames.

Here's a link to that: https://4x.ant.design/docs/react/migration-v4#:~:text=Nest%20dataIndex%20definition%20changes%20from%20%27xxx.yyy%27%20to%20%5B%27xxx%27%2C%20%27yyy%27%5D

return <Option key={name}>{name} </Option>;
return (
<Option value={name} key={name}>
{name}{' '}
Copy link
Member

Choose a reason for hiding this comment

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

just curious, what's the need for the extra space in the display string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously it was return <Option key={name}>{name} </Option>; (Notice an extra space after {name}).
So, on running yarn fmt, prettier detected that maybe that space is needed, and formatted it that way ({' '})

@@ -38,7 +38,7 @@ describe('<TraceSpanView>', () => {
it('does not explode', () => {
expect(wrapper).toBeDefined();
expect(wrapper.find('.title--TraceSpanView').length).toBe(1);
expect(wrapper.find('.span-view-table').length).toBe(3);
expect(wrapper.find('.span-view-table').length).toBe(2);
Copy link
Member

Choose a reason for hiding this comment

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

why is this count changing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the re-write of the Table in 4.x, there doesn't exist an extra withStore(Table) wrapper with the class name span-view-table.

Comment on lines +37 to +40

.ant-menu-item:hover {
background-color: transparent !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.

In antd 4x, the TopNav contains the hover effect by default, which is not what we had earlier.
This CSS property reverts that behavior.

Copy link
Member

Choose a reason for hiding this comment

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

don't understand this one. The About Jaeger menu also self-activates on hover.

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 About Jaeger menu also self-activates on hover.

I just checked the live build on the previous version (3.x) without any change. It showed the same behavior there too.
If that was a bug, I would fix it in next PR.

About that CSS change, here's how it behaves without it:

screen-capture.1.webm

With it:

screen-capture.2.webm

Copy link
Member

Choose a reason for hiding this comment

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

lgtm

Comment on lines -36 to -37
position: absolute;
bottom: 14px;
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 position of the Timeframe Selector needs to be relative to the Col beside it.

Due to position: absolute, the Selector was going to the bottom left corner, which is not the desired behavior.

bottom: 14px is removed because it is already at an appropriate distance from the col below it.

In Antd 3x:

In antd 4x, without changes:
image

With this change:
image

margin: 0 -7px;
margin: -3px -7px;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to center the Keyboard shortcut panel icon vertically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this:
image

With this:
image

'@layout-header-height': '64px',
'@layout-header-height': '48px',
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 Header's height was increased with 4.x upgrade. The resulting NavBar wasn't the one we had earlier. To revert this internal change, the height has to be decreased here.

Signed-off-by: Ansh Goyal <anshgoyal1704@gmail.com>
@yurishkuro
Copy link
Member

Code coverage drop is due to this:
image
Is this a flaky test or the result of the upgrade?

@@ -59,7 +59,7 @@ export default class MonitorATMEmptyState extends React.PureComponent {
)}
{this.config.alert && (
<Row justify="center">
Copy link
Member

Choose a reason for hiding this comment

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

is this correct that we have a row inside a row?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I am seeing, it's giving the expected result. Not sure 100% though, as there is not a strict guide about nested row and cols.

@anshgoyalevil
Copy link
Contributor Author

Code coverage drop is due to this: image Is this a flaky test or the result of the upgrade?

Don't know why but its giving 100 % coverage locally.

image

The issue's is not with the test, but the codecov. I have seen this behaviour in many places.

@yurishkuro yurishkuro merged commit 91969a7 into jaegertracing:main Sep 2, 2023
7 of 8 checks passed
@yurishkuro
Copy link
Member

🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳 🥳

@yurishkuro
Copy link
Member

I rebased #1636, which bumps antd even further - may fail on other issues

@anshgoyalevil
Copy link
Contributor Author

I rebased #1636, which bumps antd even further - may fail on other issues

Yes, antd requires another manual bump. The dependabot's PR would fail for now.

@yurishkuro
Copy link
Member

part of #1703

@anshgoyalevil anshgoyalevil mentioned this pull request Sep 4, 2023
4 tasks
@anshgoyalevil anshgoyalevil deleted the antd-4x branch September 4, 2023 12:29
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.

None yet

2 participants