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 #811

Merged
merged 14 commits into from
Dec 14, 2020
Merged

Upgrade antd #811

merged 14 commits into from
Dec 14, 2020

Conversation

baurine
Copy link
Collaborator

@baurine baurine commented Nov 24, 2020

close #803 , close #711
upgrade antd from 4.2.5 to 4.8.5

@baurine baurine marked this pull request as draft November 24, 2020 09:53
@breezewish
Copy link
Member

A kind reminder: I previously found that Tab+Table will have problems, table inside is lazily resized.. Maybe you can try it out and find out how to avoid this issue..

@baurine
Copy link
Collaborator Author

baurine commented Nov 25, 2020

A kind reminder: I previously found that Tab+Table will have problems, table inside is lazily resized.. Maybe you can try it out and find out how to avoid this issue..

Got, let me try it.

@baurine
Copy link
Collaborator Author

baurine commented Nov 25, 2020

A kind reminder: I previously found that Tab+Table will have problems, table inside is lazily resized.. Maybe you can try it out and find out how to avoid this issue..

I found this depends on the screen width, the old CardTabs implementation has this problem as well. When the screen is wide, the old implementation is lazily resized at the table end while the new implementation is lazily resized at the first column of the table. (not captured as gif)

While the screen is narrow, the old implementation is lazily resized at the first column while the new implementation doesn't resize.

When the screen is narrow, the old CardTabs:

26

the new implementation:

27

I guess it may be caused by the container width, will continue to dig it.

@baurine
Copy link
Collaborator Author

baurine commented Nov 25, 2020

Hard to dig, but I found an workaround, just use the Tab as the indicator, not the container:

    <ScrollablePane style={{ height: '100vh' }}>
      <Card>
        <CardTabs
          defaultActiveKey={tabKey}
          onChange={(key) => {
            navigate(`/cluster_info/${key}`)
          }}
          renderTabBar={renderTabBar}
          animated={false}
        >
          <CardTabs.TabPane
            tab={t('cluster_info.list.instance_table.title')}
            key="instance"
          ></CardTabs.TabPane>
          <CardTabs.TabPane
            tab={t('cluster_info.list.host_table.title')}
            key="host"
          ></CardTabs.TabPane>
          <CardTabs.TabPane
            tab={t('cluster_info.list.store_topology.title')}
            key="store_topology"
          ></CardTabs.TabPane>
        </CardTabs>
        {tabKey === 'instance' && <InstanceTable />}
        {tabKey === 'host' && <HostTable />}
        {tabKey === 'store_topology' && <StoreLocation />}
      </Card>
    </ScrollablePane>

Not sure whether it is fine.

30

padding-left: @padding-page; // 48px
height: @padding-page; // 48px
margin-bottom: @padding-md; // 16px
border-bottom: 1px solid @gray-4;
Copy link
Collaborator Author

@baurine baurine Nov 25, 2020

Choose a reason for hiding this comment

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

Although 1px and solid also have variables, I think here using the value may be more direct and explicit.

@baurine
Copy link
Collaborator Author

baurine commented Nov 25, 2020

Final effect:

30

31

@baurine baurine marked this pull request as ready for review November 25, 2020 06:55
@baurine baurine changed the title [wip] Upgrade antd Upgrade antd Nov 25, 2020
@baurine
Copy link
Collaborator Author

baurine commented Nov 25, 2020

hi @breeswish PTAL, thanks!

@breezewish
Copy link
Member

Fantastic! I will try with this PR later this week.

@unbyte
Copy link
Contributor

unbyte commented Nov 25, 2020

To avoid potential problems, I think it's better to check for changes in the changelog of antd. https://github.com/ant-design/ant-design/blob/master/CHANGELOG.zh-CN.md

@baurine
Copy link
Collaborator Author

baurine commented Nov 25, 2020

To avoid potential problems, I think it's better to check for changes in the changelog of antd. https://github.com/ant-design/ant-design/blob/master/CHANGELOG.zh-CN.md

I did, but too many 😂, and I noticed that it said the Tabs components have been totally rewritten in 4.3.0

🔥 重做 Tabs 以提升多标签在不同环境下的用户体验,DOM 结构完全重写,请注意覆盖样式丢失的问题。

@baurine baurine mentioned this pull request Nov 26, 2020
@breezewish
Copy link
Member

Hard to dig, but I found an workaround, just use the Tab as the indicator, not the container:

    <ScrollablePane style={{ height: '100vh' }}>
      <Card>
        <CardTabs
          defaultActiveKey={tabKey}
          onChange={(key) => {
            navigate(`/cluster_info/${key}`)
          }}
          renderTabBar={renderTabBar}
          animated={false}
        >
          <CardTabs.TabPane
            tab={t('cluster_info.list.instance_table.title')}
            key="instance"
          ></CardTabs.TabPane>
          <CardTabs.TabPane
            tab={t('cluster_info.list.host_table.title')}
            key="host"
          ></CardTabs.TabPane>
          <CardTabs.TabPane
            tab={t('cluster_info.list.store_topology.title')}
            key="store_topology"
          ></CardTabs.TabPane>
        </CardTabs>
        {tabKey === 'instance' && <InstanceTable />}
        {tabKey === 'host' && <HostTable />}
        {tabKey === 'store_topology' && <StoreLocation />}
      </Card>
    </ScrollablePane>

Not sure whether it is fine.

30

Nice dig, can we encapsulate this logic into our own components, in order to avoid writing this hack everywhere? Or is there "detached tabs" available in Antd?

@baurine baurine mentioned this pull request Nov 26, 2020
@baurine
Copy link
Collaborator Author

baurine commented Nov 26, 2020

Nice dig, can we encapsulate this logic into our own components, in order to avoid writing this hack everywhere? Or is there "detached tabs" available in Antd?

Let me try it.

@@ -3,7 +3,7 @@
margin-right: -@padding-page;

:global {
.ant-tabs-bar {
.ant-tabs-nav {
Copy link
Member

@breezewish breezewish Nov 27, 2020

Choose a reason for hiding this comment

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

Maybe better to find some way to remove this rule (which depends on the internal implementation of Antd's Tab).

I'm not sure renderTabBar could be useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, let me try it.

Copy link
Collaborator Author

@baurine baurine Nov 27, 2020

Choose a reason for hiding this comment

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

It works, awesome!

}

function CardTabs({ className, children, ...restProps }: ICardTabsProps) {
function CardTabs({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hi @breeswish , refactor the CardTabs like this, is it ok?

@unbyte
Copy link
Contributor

unbyte commented Dec 1, 2020

LGTM

@breezewish
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

@breeswish: adding 'status/can-merge' to this PR must have 1 LGTMs

In response to this:

/merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the tidb-community-bots/ti-community-prow repository.

1 similar comment
@ti-chi-bot
Copy link
Member

@breeswish: adding 'status/can-merge' to this PR must have 1 LGTMs

In response to this:

/merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the tidb-community-bots/ti-community-prow repository.

@breezewish
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

Can merge label has been added.

Git tree hash: 5c971d3

@ti-chi-bot ti-chi-bot merged commit 39e4d0c into pingcap:master Dec 14, 2020
@baurine baurine deleted the upgrade-antd branch December 16, 2020 14:55
breezewish added a commit that referenced this pull request Jan 4, 2021
* *: upgrade antd from 4.2.5 to 4.8.5

* yarn upgrade dayjs --latest

* fix tabs style

* fix tabs style

* wip

* only use CardTabs as the indicator

* use variables in less

* refine

* refactor CardTabs

* refine style

Co-authored-by: Wenxuan <hi@breeswish.org>
breezewish added a commit that referenced this pull request Jan 4, 2021
* ui: increasing precision for metric chart y axis (#823)
* build(deps): bump ini from 1.3.5 to 1.3.8 in /ui (#824)
* build(deps): bump ini from 1.3.5 to 1.3.8 in /ui/tests (#825)
* Upgrade antd (#811)
* Upgrade ahooks (#814)
* fix issue of query topn statement get error (#827)
* ui: show indents for slow query detail time more elegantly (#830)
* differ tikv and tiflash nodes (#834)
* Release v2021.01.04.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update UI dependencies Upgrade antd to latest
4 participants