Skip to content

Commit 42470bf

Browse files
author
Gustavo Flores
authored
feat: add hierarchical grouping for dotted test paths (#1885)
* feat: add hierarchical grouping for dotted test paths * fix: disable scroll reset in TestsTab component when updating path filter
1 parent 30b0215 commit 42470bf

9 files changed

Lines changed: 496 additions & 246 deletions

File tree

dashboard/src/components/AnimatedIcons/Chevron.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,27 @@ import { MdChevronRight } from 'react-icons/md';
22

33
import type { JSX } from 'react';
44

5-
export const ChevronRightAnimate = (): JSX.Element => {
5+
import { cn } from '@/lib/utils';
6+
7+
interface ChevronRightAnimateProps {
8+
isExpanded?: boolean;
9+
animated?: boolean;
10+
className?: string;
11+
}
12+
13+
export const ChevronRightAnimate = ({
14+
isExpanded,
15+
animated = true,
16+
className,
17+
}: ChevronRightAnimateProps): JSX.Element => {
618
return (
7-
<MdChevronRight className="transition group-data-[state='open']:rotate-90" />
19+
<MdChevronRight
20+
className={cn(
21+
'transition',
22+
animated && "group-data-[state='open']:rotate-90",
23+
isExpanded && 'rotate-90',
24+
className,
25+
)}
26+
/>
827
);
928
};

dashboard/src/components/Table/BaseTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ export const DumbBaseTable = ({
5858

5959
export const DumbTableHeader = ({
6060
children,
61+
className,
6162
}: {
6263
children: ReactNode;
64+
className?: string;
6365
}): JSX.Element => {
6466
return (
65-
<TableHeader className="bg-medium-gray">
67+
<TableHeader className={classNames('bg-medium-gray', className)}>
6668
<TableRow>{children}</TableRow>
6769
</TableHeader>
6870
);

dashboard/src/components/TestsTable/DefaultTestsColumns.tsx

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ColumnDef } from '@tanstack/react-table';
1+
import type { CellContext, ColumnDef } from '@tanstack/react-table';
22

33
import type { JSX } from 'react';
44

@@ -22,12 +22,43 @@ import {
2222
} from '@/components/Table/DetailsColumn';
2323
import { UNKNOWN_STRING } from '@/utils/constants/backend';
2424

25+
const INDENT_WIDTH = 20;
26+
27+
const PathCell = ({
28+
row,
29+
getValue,
30+
}: CellContext<TPathTests, unknown>): JSX.Element => {
31+
const value = getValue() as string;
32+
const depth = row.depth;
33+
const indent = depth * INDENT_WIDTH;
34+
35+
const hasSubGroups =
36+
row.original.sub_groups !== undefined && row.original.sub_groups.length > 0;
37+
const hasIndividualTests = row.original.individual_tests.length > 0;
38+
const isExpandable = hasSubGroups || hasIndividualTests;
39+
40+
return (
41+
<div className="flex items-center" style={{ paddingLeft: `${indent}px` }}>
42+
{isExpandable && (
43+
<span className="mr-2">
44+
<ChevronRightAnimate
45+
isExpanded={row.getIsExpanded()}
46+
animated={false}
47+
/>
48+
</span>
49+
)}
50+
<span>{value}</span>
51+
</div>
52+
);
53+
};
54+
2555
export const defaultColumns: ColumnDef<TPathTests>[] = [
2656
{
2757
accessorKey: 'path_group',
2858
header: ({ column }): JSX.Element => (
2959
<TableHeader column={column} intlKey="global.path" />
3060
),
61+
cell: PathCell,
3162
},
3263
{
3364
accessorKey: 'pass_tests',
@@ -52,10 +83,6 @@ export const defaultColumns: ColumnDef<TPathTests>[] = [
5283
);
5384
},
5485
},
55-
{
56-
id: 'chevron',
57-
cell: (): JSX.Element => <ChevronRightAnimate />,
58-
},
5986
];
6087

6188
export const defaultInnerColumns: ColumnDef<TIndividualTest>[] = [

0 commit comments

Comments
 (0)