fix: issue #3034, add columns to end of the list (#3035)

* fix: issue #3034, add columns to end of the list

* fix: #3033 replace columns
This commit is contained in:
dnazarenkoo 2023-07-06 17:00:00 +03:00 committed by GitHub
parent 197ccca30f
commit c1664dde6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 16 deletions

View File

@ -1,11 +1,11 @@
import { DEFAULT_PER_PAGE_OPTIONS } from 'hooks/queryPagination';
export const defaultSelectedColumns: string[] = [
'name',
'serviceName',
'responseStatusCode',
'httpMethod',
'name',
'durationNano',
'httpMethod',
'responseStatusCode',
];
export const PER_PAGE_OPTIONS: number[] = [10, ...DEFAULT_PER_PAGE_OPTIONS];

View File

@ -28,21 +28,18 @@ export const modifyColumns = (
columns: ColumnsType<RowData>,
selectedColumns: BaseAutocompleteData[],
): ColumnsType<RowData> => {
const initialColumns = columns.filter(({ key }) => {
let isValidColumn = true;
const initialColumns = selectedColumns.reduce(
(acc, { key: selectedColumnKey }) => {
const column = columns.find(({ key }) => selectedColumnKey === key);
const checkIsExistColumnByKey = (attributeKey: string): boolean =>
!selectedColumns.find(({ key }) => key === attributeKey) &&
attributeKey === key;
if (column) {
return [...acc, column];
}
const isSelectedSpanId = checkIsExistColumnByKey('spanID');
const isSelectedTraceId = checkIsExistColumnByKey('traceID');
if (isSelectedSpanId || isSelectedTraceId || key === 'date')
isValidColumn = false;
return isValidColumn;
});
return acc;
},
[] as ColumnsType<RowData>,
);
const dateColumn = columns.find(({ key }) => key === 'date');