Skip to content

Commit

Permalink
fix: intermittent undefined page in trace details page (#6084)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikrantgupta25 authored Sep 26, 2024
1 parent 7a125e3 commit ef4b70f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
21 changes: 2 additions & 19 deletions frontend/src/container/TracesExplorer/ListView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { Pagination } from 'hooks/queryPagination';
import useDragColumns from 'hooks/useDragColumns';
import { getDraggedColumns } from 'hooks/useDragColumns/utils';
import useUrlQueryData from 'hooks/useUrlQueryData';
import history from 'lib/history';
import { RowData } from 'lib/query/createTableColumnsFromQuery';
import { HTMLAttributes, memo, useCallback, useMemo } from 'react';
import { memo, useCallback, useMemo } from 'react';
import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers';
import { DataSource } from 'types/common/queryBuilder';
Expand All @@ -25,7 +24,7 @@ import { GlobalReducer } from 'types/reducer/globalTime';
import { TracesLoading } from '../TraceLoading/TraceLoading';
import { defaultSelectedColumns, PER_PAGE_OPTIONS } from './configs';
import { Container, ErrorText, tableStyles } from './styles';
import { getListColumns, getTraceLink, transformDataWithDate } from './utils';
import { getListColumns, transformDataWithDate } from './utils';

interface ListViewProps {
isFilterApplied: boolean;
Expand Down Expand Up @@ -108,21 +107,6 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
[queryTableData],
);

const handleRow = useCallback(
(record: RowData): HTMLAttributes<RowData> => ({
onClick: (event): void => {
event.preventDefault();
event.stopPropagation();
if (event.metaKey || event.ctrlKey) {
window.open(getTraceLink(record), '_blank');
} else {
history.push(getTraceLink(record));
}
},
}),
[],
);

const handleDragColumn = useCallback(
(fromIndex: number, toIndex: number) =>
onDragColumns(columns, fromIndex, toIndex),
Expand Down Expand Up @@ -169,7 +153,6 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
style={tableStyles}
dataSource={transformedQueryTableData}
columns={columns}
onRow={handleRow}
onDragColumn={handleDragColumn}
/>
)}
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/container/TracesExplorer/ListView/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export const getListColumns = (
key: 'date',
title: 'Timestamp',
width: 145,
render: (item): JSX.Element => {
render: (value, item): JSX.Element => {
const date =
typeof item === 'string'
? dayjs(item).format('YYYY-MM-DD HH:mm:ss.SSS')
: dayjs(item / 1e6).format('YYYY-MM-DD HH:mm:ss.SSS');
typeof value === 'string'
? dayjs(value).format('YYYY-MM-DD HH:mm:ss.SSS')
: dayjs(value / 1e6).format('YYYY-MM-DD HH:mm:ss.SSS');
return (
<BlockLink to={getTraceLink(item)}>
<Typography.Text>{date}</Typography.Text>
Expand All @@ -67,18 +67,18 @@ export const getListColumns = (
dataIndex: key,
key: `${key}-${dataType}-${type}`,
width: 145,
render: (value): JSX.Element => {
render: (value, item): JSX.Element => {
if (value === '') {
return (
<BlockLink to={getTraceLink(value)}>
<BlockLink to={getTraceLink(item)}>
<Typography data-testid={key}>N/A</Typography>
</BlockLink>
);
}

if (key === 'httpMethod' || key === 'responseStatusCode') {
return (
<BlockLink to={getTraceLink(value)}>
<BlockLink to={getTraceLink(item)}>
<Tag data-testid={key} color="magenta">
{value}
</Tag>
Expand All @@ -88,14 +88,14 @@ export const getListColumns = (

if (key === 'durationNano') {
return (
<BlockLink to={getTraceLink(value)}>
<BlockLink to={getTraceLink(item)}>
<Typography data-testid={key}>{getMs(value)}ms</Typography>
</BlockLink>
);
}

return (
<BlockLink to={getTraceLink(value)}>
<BlockLink to={getTraceLink(item)}>
<Typography data-testid={key}>{value}</Typography>
</BlockLink>
);
Expand Down

0 comments on commit ef4b70f

Please sign in to comment.