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
14 changes: 14 additions & 0 deletions ui/lib/apps/ClusterInfo/pages/List.module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import '~antd/es/style/themes/default.less';

.sticky_tabs_header {
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.


:global {
.ant-tabs-ink-bar {
height: @outline-width; // 2px
}
}
}
31 changes: 14 additions & 17 deletions ui/lib/apps/ClusterInfo/pages/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import { useNavigate, useParams } from 'react-router-dom'
import { Card } from '@lib/components'
import CardTabs from '@lib/components/CardTabs'

import InstanceTable from '../components/InstanceTable'
import HostTable from '../components/HostTable'
import DiskTable from '../components/DiskTable'
import InstanceTable from '../components/InstanceTable'
import StoreLocation from '../components/StoreLocation'
import Statistics from '../components/Statistics'

import styles from './List.module.less'

function renderTabBar(props, DefaultTabBar) {
return (
<Sticky stickyPosition={StickyPositionType.Header}>
<DefaultTabBar {...props} />
<DefaultTabBar {...props} className={styles.sticky_tabs_header} />
</Sticky>
)
}
Expand All @@ -40,34 +42,29 @@ export default function ListPage() {
<CardTabs.TabPane
tab={t('cluster_info.list.instance_table.title')}
key="instance"
>
<InstanceTable />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('cluster_info.list.host_table.title')}
key="host"
>
<HostTable />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('cluster_info.list.disk_table.title')}
key="disk"
>
<DiskTable />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('cluster_info.list.store_topology.title')}
key="store_topology"
>
<StoreLocation />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('cluster_info.list.statistics.title')}
key="statistics"
>
<Statistics />
</CardTabs.TabPane>
></CardTabs.TabPane>
</CardTabs>
{tabKey === 'instance' && <InstanceTable />}
{tabKey === 'host' && <HostTable />}
{tabKey === 'disk' && <DiskTable />}
{tabKey === 'store_topology' && <StoreLocation />}
{tabKey === 'statistics' && <Statistics />}
</Card>
</ScrollablePane>
)
Expand Down
30 changes: 16 additions & 14 deletions ui/lib/apps/SlowQuery/pages/Detail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState } from 'react'
import { Space } from 'antd'
import { useTranslation } from 'react-i18next'
import { useLocation } from 'react-router-dom'
Expand Down Expand Up @@ -38,6 +38,8 @@ function DetailPage() {

const { t } = useTranslation()

const [tabKey, setTabKey] = useState('basic')

const { data, isLoading, error } = useClientRequest((reqConfig) =>
client
.getInstance()
Expand Down Expand Up @@ -158,32 +160,32 @@ function DetailPage() {
</Descriptions.Item>
</Descriptions>

<CardTabs animated={false}>
<CardTabs
defaultActiveKey={tabKey}
onChange={setTabKey}
animated={false}
>
<CardTabs.TabPane
tab={t('slow_query.detail.tabs.basic')}
key="basic"
>
<TabBasic data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('slow_query.detail.tabs.time')}
key="time"
>
<TabTime data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('slow_query.detail.tabs.copr')}
key="copr"
>
<TabCopr data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('slow_query.detail.tabs.txn')}
key="txn"
>
<TabTxn data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
</CardTabs>
{tabKey === 'basic' && <TabBasic data={data} />}
{tabKey === 'time' && <TabTime data={data} />}
{tabKey === 'copr' && <TabCopr data={data} />}
{tabKey === 'txn' && <TabTxn data={data} />}
</>
)}
</AnimatedSkeleton>
Expand Down
46 changes: 24 additions & 22 deletions ui/lib/apps/Statement/pages/Detail/PlanDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState } from 'react'
import { Space } from 'antd'
import { useLocalStorageState } from '@umijs/hooks'
import { useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -37,6 +37,7 @@ export interface IPlanDetailProps {
const STMT_DETAIL_PLAN_EXPAND = 'statement.detail_plan_expand'

function PlanDetail({ query }: IPlanDetailProps) {
const [tabKey, setTabKey] = useState('basic')
const { t } = useTranslation()
const { data, isLoading, error } = useClientRequest((reqConfig) =>
client
Expand Down Expand Up @@ -67,17 +68,18 @@ function PlanDetail({ query }: IPlanDetailProps) {
const togglePlan = () =>
setDetailExpand((prev) => ({ ...prev, plan: !prev.plan }))

let title_key
let titleKey
if (query.allPlans === 1) {
title_key = 'one_for_all'
titleKey = 'one_for_all'
} else if (query.plans.length === query.allPlans) {
title_key = 'all'
titleKey = 'all'
} else {
title_key = 'some'
titleKey = 'some'
}

return (
<Card
title={t(`statement.pages.detail.desc.plans.title.${title_key}`, {
title={t(`statement.pages.detail.desc.plans.title.${titleKey}`, {
n: query.plans.length,
})}
>
Expand Down Expand Up @@ -167,38 +169,38 @@ function PlanDetail({ query }: IPlanDetailProps) {
</Expand>
</Descriptions.Item>
</Descriptions>
<CardTabs animated={false}>

<CardTabs
defaultActiveKey={tabKey}
onChange={setTabKey}
animated={false}
>
<CardTabs.TabPane
tab={t('statement.pages.detail.tabs.basic')}
key="basic"
>
<TabBasic data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('statement.pages.detail.tabs.time')}
key="time"
>
<TabTime data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('statement.pages.detail.tabs.copr')}
key="copr"
>
<TabCopr data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('statement.pages.detail.tabs.txn')}
key="txn"
>
<TabTxn data={data} />
</CardTabs.TabPane>
></CardTabs.TabPane>
<CardTabs.TabPane
tab={t('statement.pages.detail.tabs.slow_query')}
key="slow_query"
>
<SlowQueryTab query={query} />
</CardTabs.TabPane>
></CardTabs.TabPane>
</CardTabs>
{tabKey === 'basic' && <TabBasic data={data} />}
{tabKey === 'time' && <TabTime data={data} />}
{tabKey === 'copr' && <TabCopr data={data} />}
{tabKey === 'txn' && <TabTxn data={data} />}
{tabKey === 'slow_query' && <SlowQueryTab query={query} />}
</>
)}
</AnimatedSkeleton>
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/components/CardTabs/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -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!

padding-left: @padding-page;
padding-right: @padding-page;
}
Expand Down
4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"@umijs/hooks": "^1.9.3",
"@welldone-software/why-did-you-render": "^4.2.7",
"ace-builds": "^1.4.12",
"antd": "~4.2",
"antd": "~4.8.5",
"axios": "^0.19.0",
"bulma": "^0.9.0",
"classnames": "^2.2.6",
"d3": "^5.16.0",
"dayjs": "^1.8.31",
"dayjs": "^1.9.6",
"echarts": "^4.8.0",
"echarts-for-react": "^2.0.16",
"history": "^5.0.0",
Expand Down
Loading