From b0ec61988100266b3ccd23e4644a41605cea85fd Mon Sep 17 00:00:00 2001 From: Vishal Sharma Date: Thu, 24 Nov 2022 16:25:26 +0530 Subject: [PATCH] fix: trace table pagination (#1749) * fix: trace table pagination * chore: refactor * chore: refactor Co-authored-by: Palash Gupta --- .../src/container/Trace/TraceTable/index.tsx | 18 ++++++------------ .../src/container/Trace/TraceTable/util.ts | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 frontend/src/container/Trace/TraceTable/util.ts diff --git a/frontend/src/container/Trace/TraceTable/index.tsx b/frontend/src/container/Trace/TraceTable/index.tsx index d66dd37592..aa9fc1cf6b 100644 --- a/frontend/src/container/Trace/TraceTable/index.tsx +++ b/frontend/src/container/Trace/TraceTable/index.tsx @@ -1,6 +1,10 @@ import { TableProps, Tag, Typography } from 'antd'; import Table, { ColumnsType } from 'antd/lib/table'; import ROUTES from 'constants/routes'; +import { + getSpanOrder, + getSpanOrderParam, +} from 'container/Trace/TraceTable/util'; import dayjs from 'dayjs'; import duration from 'dayjs/plugin/duration'; import history from 'lib/history'; @@ -111,16 +115,6 @@ function TraceTable(): JSX.Element { }, ]; - const getSortKey = (key: string): string => { - if (key === 'durationNano') { - return 'duration'; - } - if (key === 'timestamp') { - return 'timestamp'; - } - return ''; - }; - const onChangeHandler: TableProps['onChange'] = ( props, _, @@ -129,8 +123,8 @@ function TraceTable(): JSX.Element { if (!Array.isArray(sort)) { const { order = spansAggregateOrder } = sort; if (props.current && props.pageSize) { - const spanOrder = order === 'ascend' ? 'ascending' : 'descending'; - const orderParam = getSortKey(sort.field as string); + const spanOrder = getSpanOrder(order || ''); + const orderParam = getSpanOrderParam(sort.field as string); dispatch({ type: UPDATE_SPAN_ORDER, diff --git a/frontend/src/container/Trace/TraceTable/util.ts b/frontend/src/container/Trace/TraceTable/util.ts new file mode 100644 index 0000000000..08276636c1 --- /dev/null +++ b/frontend/src/container/Trace/TraceTable/util.ts @@ -0,0 +1,19 @@ +export const getSpanOrderParam = (key: string): string => { + if (key === 'durationNano') { + return 'duration'; + } + if (key === 'timestamp') { + return 'timestamp'; + } + return ''; +}; + +export const getSpanOrder = (order: string): string => { + if (order === 'ascend') { + return 'ascending'; + } + if (order === 'descend') { + return 'descending'; + } + return ''; +};