fix: trace table pagination (#1749)

* fix: trace table pagination

* chore: refactor

* chore: refactor

Co-authored-by: Palash Gupta <palashgdev@gmail.com>
This commit is contained in:
Vishal Sharma 2022-11-24 16:25:26 +05:30 committed by GitHub
parent 220f848b04
commit b0ec619881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 12 deletions

View File

@ -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<TableType>['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,

View File

@ -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 '';
};