From da4cbf6c2f8804d1fcff194c235a74ef83502a41 Mon Sep 17 00:00:00 2001 From: GitStart <1501599+gitstart@users.noreply.github.com> Date: Wed, 22 Mar 2023 12:01:37 +0530 Subject: [PATCH] fix: tabs deprecation warning from antd (#2479) Co-authored-by: gitstart Co-authored-by: Chintan Sudani <46838508+techchintan@users.noreply.github.com> Co-authored-by: Palash Gupta --- frontend/src/components/RouteTab/index.tsx | 26 ++-- .../container/FormAlertRules/QuerySection.tsx | 36 +++-- frontend/src/container/Licenses/index.tsx | 26 ++-- .../src/container/LogDetailedView/index.tsx | 22 ++- .../QueryBuilder/QueryBuilder.tsx | 5 +- .../NewDashboard/DashboardSettings/index.tsx | 18 +-- .../LeftContainer/QuerySection/index.tsx | 145 +++++++++--------- .../TraceDetail/SelectedSpanDetails/index.tsx | 48 +++--- frontend/src/pages/AlertList/index.tsx | 38 ++--- 9 files changed, 184 insertions(+), 180 deletions(-) diff --git a/frontend/src/components/RouteTab/index.tsx b/frontend/src/components/RouteTab/index.tsx index 1192f2f8e2..0059f5b84c 100644 --- a/frontend/src/components/RouteTab/index.tsx +++ b/frontend/src/components/RouteTab/index.tsx @@ -2,8 +2,6 @@ import { Tabs, TabsProps } from 'antd'; import history from 'lib/history'; import React from 'react'; -const { TabPane } = Tabs; - function RouteTab({ routes, activeKey, @@ -22,29 +20,23 @@ function RouteTab({ } }; + const items = routes.map(({ Component, name, route }) => ({ + label: name, + key: name, + tabKey: route, + children: , + })); + return ( - {routes.map( - ({ Component, name, route }): JSX.Element => ( - - - - ), - )} - + /> ); } diff --git a/frontend/src/container/FormAlertRules/QuerySection.tsx b/frontend/src/container/FormAlertRules/QuerySection.tsx index f02299dbc8..ab39c51083 100644 --- a/frontend/src/container/FormAlertRules/QuerySection.tsx +++ b/frontend/src/container/FormAlertRules/QuerySection.tsx @@ -23,7 +23,6 @@ import PromqlSection from './PromqlSection'; import { FormContainer, QueryButton, StepHeading } from './styles'; import { toIMetricsBuilderQuery } from './utils'; -const { TabPane } = Tabs; function QuerySection({ queryCategory, setQueryCategory, @@ -282,6 +281,24 @@ function QuerySection({ runQuery(); }; + const tabs = [ + { + label: t('tab_qb'), + key: EQueryType.QUERY_BUILDER.toString(), + disabled: true, + }, + { + label: t('tab_chquery'), + key: EQueryType.CLICKHOUSE.toString(), + }, + ]; + + const items = [ + { label: t('tab_qb'), key: EQueryType.QUERY_BUILDER.toString() }, + { label: t('tab_chquery'), key: EQueryType.CLICKHOUSE.toString() }, + { label: t('tab_promql'), key: EQueryType.PROM.toString() }, + ]; + const renderTabs = (typ: AlertTypes): JSX.Element | null => { switch (typ) { case AlertTypes.TRACES_BASED_ALERT: @@ -303,14 +320,8 @@ function QuerySection({ )} } - > - - - + items={tabs} + /> ); case AlertTypes.METRICS_BASED_ALERT: default: @@ -330,11 +341,8 @@ function QuerySection({ )} } - > - - - - + items={items} + /> ); } }; diff --git a/frontend/src/container/Licenses/index.tsx b/frontend/src/container/Licenses/index.tsx index b326a5b0e7..d7dc4ab22b 100644 --- a/frontend/src/container/Licenses/index.tsx +++ b/frontend/src/container/Licenses/index.tsx @@ -8,8 +8,6 @@ import { useQuery } from 'react-query'; import ApplyLicenseForm from './ApplyLicenseForm'; import ListLicenses from './ListLicenses'; -const { TabPane } = Tabs; - function Licenses(): JSX.Element { const { t } = useTranslation(['licenses']); const { data, isError, isLoading, refetch } = useQuery({ @@ -28,17 +26,21 @@ function Licenses(): JSX.Element { const allValidLicense = data?.payload?.filter((license) => license.isCurrent) || []; - return ( - - - - - + const tabs = [ + { + label: t('tab_current_license'), + key: 'licenses', + children: , + }, + { + label: t('tab_license_history'), + key: 'history', + children: , + }, + ]; - - - - + return ( + ); } diff --git a/frontend/src/container/LogDetailedView/index.tsx b/frontend/src/container/LogDetailedView/index.tsx index 930dfbf0d8..98ab0909a4 100644 --- a/frontend/src/container/LogDetailedView/index.tsx +++ b/frontend/src/container/LogDetailedView/index.tsx @@ -24,6 +24,19 @@ function LogDetailedView(): JSX.Element { }); }; + const items = [ + { + label: 'Table', + key: '1', + children: detailedLog && , + }, + { + label: 'JSON', + key: '2', + children: detailedLog && , + }, + ]; + return ( - - - {detailedLog && } - - - {detailedLog && } - - + ); } diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx index 4db70b7db2..9aff0b6dd7 100644 --- a/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx +++ b/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx @@ -27,8 +27,9 @@ function QueryConditionField({ return (