Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the trace table row act as an anchor tag #5626

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 41 additions & 7 deletions frontend/src/container/TracesExplorer/ListView/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@ import { getMs } from 'container/Trace/Filters/Panel/PanelBody/Duration/util';
import { formUrlParams } from 'container/TraceDetail/utils';
import dayjs from 'dayjs';
import { RowData } from 'lib/query/createTableColumnsFromQuery';
import { Link } from 'react-router-dom';
import { ILog } from 'types/api/logs/log';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { QueryDataV3 } from 'types/api/widgets/getQuery';

function BlockLink({
children,
to,
}: {
children: React.ReactNode;
to: string;
}): any {
// Display block to make the whole cell clickable
return (
<Link to={to} style={{ display: 'block' }}>
{children}
</Link>
);
}

export const transformDataWithDate = (
data: QueryDataV3[],
): Omit<ILog, 'timestamp'>[] =>
Expand Down Expand Up @@ -36,7 +52,11 @@ export const getListColumns = (
typeof item === 'string'
? dayjs(item).format('YYYY-MM-DD HH:mm:ss.SSS')
: dayjs(item / 1e6).format('YYYY-MM-DD HH:mm:ss.SSS');
return <Typography.Text>{date}</Typography.Text>;
return (
<BlockLink to={getTraceLink(item)}>
ahmadshaheer marked this conversation as resolved.
Show resolved Hide resolved
<Typography.Text>{date}</Typography.Text>
</BlockLink>
);
},
},
];
Expand All @@ -49,22 +69,36 @@ export const getListColumns = (
width: 145,
render: (value): JSX.Element => {
if (value === '') {
return <Typography data-testid={key}>N/A</Typography>;
return (
<BlockLink to={getTraceLink(value)}>
<Typography data-testid={key}>N/A</Typography>
</BlockLink>
);
}

if (key === 'httpMethod' || key === 'responseStatusCode') {
return (
<Tag data-testid={key} color="magenta">
{value}
</Tag>
<BlockLink to={getTraceLink(value)}>
<Tag data-testid={key} color="magenta">
{value}
</Tag>
</BlockLink>
);
}

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

return <Typography data-testid={key}>{value}</Typography>;
return (
<BlockLink to={getTraceLink(value)}>
<Typography data-testid={key}>{value}</Typography>
</BlockLink>
);
},
responsive: ['md'],
})) || [];
Expand Down
Loading