Skip to content

Commit dc4a32c

Browse files
authored
feat: add text wrap to tables (#1029)
Closes HDX-1856 Added icon to left of CSV Download button for wrapping text in table <img width="1414" height="258" alt="image" src="https://github.com/user-attachments/assets/f5028799-1b61-4021-9775-4611c10d800e" />
1 parent 3bb11af commit dc4a32c

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

.changeset/stale-cups-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
feat: add text wrap to tables

packages/app/src/HDXMultiSeriesTableChart.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { memo, useCallback, useMemo, useRef } from 'react';
1+
import { memo, useCallback, useMemo, useRef, useState } from 'react';
22
import Link from 'next/link';
3-
import { Flex, Text } from '@mantine/core';
3+
import cx from 'classnames';
4+
import { Flex, Text, UnstyledButton } from '@mantine/core';
45
import {
56
flexRender,
67
getCoreRowModel,
@@ -158,6 +159,7 @@ export const Table = ({
158159
: [0, 0],
159160
[items, rowVirtualizer.options.scrollMargin, totalSize],
160161
);
162+
const [wrapLinesEnabled, setWrapLinesEnabled] = useState(false);
161163

162164
const { csvData } = useCsvExport(
163165
data,
@@ -245,6 +247,13 @@ export const Table = ({
245247
)}
246248
{headerIndex === headerGroup.headers.length - 1 && (
247249
<div className="d-flex align-items-center">
250+
<UnstyledButton
251+
onClick={() =>
252+
setWrapLinesEnabled(prev => !prev)
253+
}
254+
>
255+
<i className="bi bi-text-wrap" />
256+
</UnstyledButton>
248257
<CsvExportButton
249258
data={csvData}
250259
filename="HyperDX_table_results"
@@ -283,7 +292,12 @@ export const Table = ({
283292
return (
284293
<td key={cell.id} title={`${cell.getValue()}`}>
285294
{getRowSearchLink == null ? (
286-
<div className="align-top overflow-hidden py-1 pe-3">
295+
<div
296+
className={cx('align-top overflow-hidden py-1 pe-3', {
297+
'text-break': wrapLinesEnabled,
298+
'text-truncate': !wrapLinesEnabled,
299+
})}
300+
>
287301
{flexRender(
288302
cell.column.columnDef.cell,
289303
cell.getContext(),

packages/app/src/components/DBRowTable.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
SelectList,
2828
} from '@hyperdx/common-utils/dist/types';
2929
import { splitAndTrimWithBracket } from '@hyperdx/common-utils/dist/utils';
30-
import { Box, Code, Flex, Text } from '@mantine/core';
30+
import { Box, Code, Flex, Text, UnstyledButton } from '@mantine/core';
3131
import {
3232
FetchNextPageOptions,
3333
useQuery,
@@ -230,7 +230,7 @@ export const RawLogTable = memo(
230230
onScroll,
231231
onSettingsClick,
232232
onShowPatternsClick,
233-
wrapLines,
233+
wrapLines = false,
234234
columnNameMap,
235235
showServiceColumn = true,
236236
dedupRows,
@@ -527,6 +527,7 @@ export const RawLogTable = memo(
527527
// Scroll to log id if it's not in window yet
528528
const [scrolledToHighlightedLine, setScrolledToHighlightedLine] =
529529
useState(false);
530+
const [wrapLinesEnabled, setWrapLinesEnabled] = useState(wrapLines);
530531

531532
useEffect(() => {
532533
if (
@@ -688,6 +689,11 @@ export const RawLogTable = memo(
688689
<i className="bi bi-arrow-clockwise" />
689690
</div>
690691
)}
692+
<UnstyledButton
693+
onClick={() => setWrapLinesEnabled(prev => !prev)}
694+
>
695+
<i className="bi bi-text-wrap" />
696+
</UnstyledButton>
691697
<CsvExportButton
692698
data={csvData}
693699
filename={`hyperdx_search_results_${new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)}`}
@@ -742,8 +748,8 @@ export const RawLogTable = memo(
742748
<td
743749
key={cell.id}
744750
className={cx('align-top overflow-hidden', {
745-
'text-break': wrapLines,
746-
'text-truncate': !wrapLines,
751+
'text-break': wrapLinesEnabled,
752+
'text-truncate': !wrapLinesEnabled,
747753
})}
748754
>
749755
{flexRender(

0 commit comments

Comments
 (0)