Skip to content
Open
Show file tree
Hide file tree
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
106 changes: 71 additions & 35 deletions dashboard/src/components/BootsTable/BootsTable.tsx

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both BootsTable.tsx and BuildsTable.tsx have the details column, which is the only column that allows navigation to the details page. Clicking on the other cells only opens the right drawer.

I'm wondering if it's okay to allow the user to hide the only way they have to navigate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it might be safer to allow only for between cells resize, but leave the outter table size untouched.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's okay to allow the user to hide the only way they have to navigate.

The user can also navigate by opening the right drawer and clicking on "show more details" at the botton of the drawer

Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { ColumnDef, SortingState } from '@tanstack/react-table';
import {
flexRender,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
useReactTable,
} from '@tanstack/react-table';

import { useCallback, useEffect, useMemo, useState, type JSX } from 'react';
Expand All @@ -26,17 +24,17 @@ import { TableBody, TableCell, TableRow } from '@/components/ui/table';

import type { TestHistory } from '@/types/general';

import BaseTable, { TableHead } from '@/components/Table/BaseTable';

import { PaginationInfo } from '@/components/Table/PaginationInfo';
import { useTestIssues } from '@/api/testDetails';
import { useLogData } from '@/hooks/useLogData';
import WrapperTableWithLogSheet from '@/pages/TreeDetails/Tabs/WrapperTableWithLogSheet';
import { usePaginationState } from '@/hooks/usePaginationState';
import { useLayoutTable } from '@/hooks/useLayoutTable';

import type { TableKeys } from '@/utils/constants/tables';

import { TableRowMemoized } from '@/components/Table/TableComponents';
import { TableFrame } from '@/components/Table/TableFrame';

import { buildHardwareArray, buildTreeBranch } from '@/utils/table';

Expand All @@ -60,6 +58,12 @@ const defaultColumns: ColumnDef<TestByCommitHash>[] = [
header: ({ column }): JSX.Element => (
<TableHeader column={column} intlKey="global.path" />
),
meta: {
headerIntlKey: 'global.path',
isRowHeader: true,
minWidth: 160,
maxWidth: 400,
},
},
{
accessorKey: 'status',
Expand All @@ -72,6 +76,11 @@ const defaultColumns: ColumnDef<TestByCommitHash>[] = [
tooltipId="boots.statusTooltip"
/>
),
meta: {
headerIntlKey: 'global.status',
minWidth: 100,
maxWidth: 160,
},
},
{
accessorKey: 'startTime',
Expand All @@ -86,6 +95,11 @@ const defaultColumns: ColumnDef<TestByCommitHash>[] = [
showLabelTZ={true}
/>
),
meta: {
headerIntlKey: 'buildDetails.startTime',
minWidth: 140,
maxWidth: 220,
},
},
{
accessorKey: 'duration',
Expand All @@ -94,6 +108,11 @@ const defaultColumns: ColumnDef<TestByCommitHash>[] = [
),
cell: ({ row }): string =>
row.getValue('duration') ? row.getValue('duration') : '-',
meta: {
headerIntlKey: 'global.duration',
minWidth: 100,
maxWidth: 160,
},
},
{
id: 'lab',
Expand All @@ -104,6 +123,11 @@ const defaultColumns: ColumnDef<TestByCommitHash>[] = [
cell: ({ row }): string => {
return row.getValue('lab') || UNKNOWN_STRING;
},
meta: {
headerIntlKey: 'global.lab',
minWidth: 100,
maxWidth: 200,
},
},
{
accessorKey: 'hardware',
Expand All @@ -113,11 +137,21 @@ const defaultColumns: ColumnDef<TestByCommitHash>[] = [
cell: ({ row }): JSX.Element | string => {
return <TooltipHardware hardwares={row.original.hardware} />;
},
meta: {
headerIntlKey: 'global.hardware',
minWidth: 120,
maxWidth: 280,
},
},
{
id: DETAILS_COLUMN_ID,
header: (): JSX.Element => <MoreDetailsTableHeader />,
cell: (): JSX.Element => <MoreDetailsIcon />,
enableResizing: false,
meta: {
minWidth: 64,
maxWidth: 96,
},
},
];

Expand Down Expand Up @@ -180,7 +214,14 @@ export function BootsTable({

const testsData = useMemo(() => rawData.tests, [rawData]);

const table = useReactTable({
const {
table,
containerRef,
columnWidths,
tableWidth,
columnsMenu,
tableHeaders,
} = useLayoutTable({
data: testsData,
columns,
onSortingChange: setSorting,
Expand Down Expand Up @@ -278,26 +319,6 @@ export function BootsTable({
[updatePathFilter],
);

const groupHeaders = table.getHeaderGroups()[0]?.headers;
const tableHeaders = useMemo((): JSX.Element[] => {
return groupHeaders.map(header => {
const headerComponent = header.isPlaceholder
? null
: // the header must change the icon when sorting changes,
// but just the column dependency won't trigger the rerender
// so we pass an unused sorting prop here to force the useMemo dependency
flexRender(header.column.columnDef.header, {
...header.getContext(),
sorting,
});
return (
<TableHead key={header.id} className="border-b px-2 font-bold">
{headerComponent}
</TableHead>
);
});
}, [groupHeaders, sorting]);

const modelRows = table.getRowModel().rows;

const sortedItems = useMemo(
Expand Down Expand Up @@ -339,6 +360,7 @@ export function BootsTable({
openLogSheet={openLogSheet}
currentLog={currentLog}
getRowLink={getRowLink}
columnWidths={columnWidths}
/>
))
) : (
Expand All @@ -348,7 +370,14 @@ export function BootsTable({
</TableCell>
</TableRow>
);
}, [modelRows, getRowLink, openLogSheet, currentLog, columns.length]);
}, [
modelRows,
getRowLink,
openLogSheet,
currentLog,
columns.length,
columnWidths,
]);

const handlePreviousItem = useCallback(() => {
if (currentLog !== undefined && currentLog > 0) {
Expand Down Expand Up @@ -399,16 +428,23 @@ export function BootsTable({
status={status}
error={error}
>
<TableTopFilters
key="bootsTableSearch"
filters={filters}
onClickFilter={onClickFilter}
onSearchChange={onSearchChange}
currentPathFilter={currentPathFilter}
/>
<BaseTable headerComponents={tableHeaders}>
<div className="flex flex-wrap items-start justify-between gap-4">
<TableTopFilters
key="bootsTableSearch"
filters={filters}
onClickFilter={onClickFilter}
onSearchChange={onSearchChange}
currentPathFilter={currentPathFilter}
/>
{columnsMenu}
</div>
<TableFrame
containerRef={containerRef}
tableWidth={tableWidth}
headerComponents={tableHeaders}
>
<TableBody>{tableRows}</TableBody>
</BaseTable>
</TableFrame>
<PaginationInfo table={table} intlLabel="global.boots" />
</WrapperTableWithLogSheet>
);
Expand Down
66 changes: 34 additions & 32 deletions dashboard/src/components/BuildsTable/BuildsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { ColumnDef, SortingState } from '@tanstack/react-table';
import {
flexRender,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
useReactTable,
} from '@tanstack/react-table';

import { useCallback, useEffect, useMemo, useState, type JSX } from 'react';
Expand All @@ -14,7 +12,6 @@ import { FormattedMessage, useIntl } from 'react-intl';

import type { LinkProps } from '@tanstack/react-router';

import BaseTable, { TableHead } from '@/components/Table/BaseTable';
import { PaginationInfo } from '@/components/Table/PaginationInfo';
import { TableBody, TableCell, TableRow } from '@/components/ui/table';
import {
Expand All @@ -26,10 +23,12 @@ import {
import WrapperTableWithLogSheet from '@/pages/TreeDetails/Tabs/WrapperTableWithLogSheet';

import { usePaginationState } from '@/hooks/usePaginationState';
import { useLayoutTable } from '@/hooks/useLayoutTable';

import type { TableKeys } from '@/utils/constants/tables';

import { TableRowMemoized } from '@/components/Table/TableComponents';
import { TableFrame } from '@/components/Table/TableFrame';

import { useBuildIssues } from '@/api/buildDetails';
import { useLogData } from '@/hooks/useLogData';
Expand Down Expand Up @@ -84,7 +83,14 @@ export function BuildsTable({
}));
}, [buildItems]);

const table = useReactTable({
const {
table,
containerRef,
columnWidths,
tableWidth,
columnsMenu,
tableHeaders,
} = useLayoutTable({
data: rawData,
columns,
onSortingChange: setSorting,
Expand Down Expand Up @@ -171,25 +177,6 @@ export function BuildsTable({
[table],
);

const groupHeaders = table.getHeaderGroups()[0]?.headers;
const tableHeaders = useMemo((): JSX.Element[] => {
return groupHeaders.map(header => {
return (
<TableHead key={header.id} className="border-b px-0 font-bold">
{header.isPlaceholder
? null
: // the header must change the icon when sorting changes,
// but just the column dependency won't trigger the rerender
// so we pass an unused sorting prop here to force the useMemo dependency
flexRender(header.column.columnDef.header, {
...header.getContext(),
sorting,
})}
</TableHead>
);
});
}, [groupHeaders, sorting]);

const modelRows = table.getRowModel().rows;

const sortedItems = useMemo(
Expand Down Expand Up @@ -233,6 +220,7 @@ export function BuildsTable({
openLogSheet={openLogSheet}
currentLog={currentLog}
getRowLink={getRowLink}
columnWidths={columnWidths}
/>
);
})
Expand All @@ -244,7 +232,14 @@ export function BuildsTable({
</TableRow>
);
}
}, [modelRows, columns.length, openLogSheet, currentLog, getRowLink]);
}, [
modelRows,
columns.length,
openLogSheet,
currentLog,
getRowLink,
columnWidths,
]);

const handlePreviousItem = useCallback(() => {
if (currentLog !== undefined && currentLog > 0) {
Expand Down Expand Up @@ -295,15 +290,22 @@ export function BuildsTable({
status={status}
error={error}
>
<TableTopFilters
key="buildsTableSearch"
filters={filters}
onClickFilter={onClickFilter}
onSearchChange={onSearchChange}
/>
<BaseTable headerComponents={tableHeaders}>
<div className="flex flex-wrap items-start justify-between gap-4">
<TableTopFilters
key="buildsTableSearch"
filters={filters}
onClickFilter={onClickFilter}
onSearchChange={onSearchChange}
/>
{columnsMenu}
</div>
<TableFrame
containerRef={containerRef}
tableWidth={tableWidth}
headerComponents={tableHeaders}
>
<TableBody>{tableBody}</TableBody>
</BaseTable>
</TableFrame>
<PaginationInfo table={table} intlLabel="global.builds" />
</WrapperTableWithLogSheet>
);
Expand Down
Loading
Loading