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
23 changes: 21 additions & 2 deletions dashboard/src/components/AnimatedIcons/Chevron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,27 @@ import { MdChevronRight } from 'react-icons/md';

import type { JSX } from 'react';

export const ChevronRightAnimate = (): JSX.Element => {
import { cn } from '@/lib/utils';

interface ChevronRightAnimateProps {
isExpanded?: boolean;
animated?: boolean;
className?: string;
}

export const ChevronRightAnimate = ({
isExpanded,
animated = true,
className,
}: ChevronRightAnimateProps): JSX.Element => {
return (
<MdChevronRight className="transition group-data-[state='open']:rotate-90" />
<MdChevronRight
className={cn(
'transition',
animated && "group-data-[state='open']:rotate-90",
isExpanded && 'rotate-90',
className,
)}
/>
);
};
4 changes: 3 additions & 1 deletion dashboard/src/components/Table/BaseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ export const DumbBaseTable = ({

export const DumbTableHeader = ({
children,
className,
}: {
children: ReactNode;
className?: string;
}): JSX.Element => {
return (
<TableHeader className="bg-medium-gray">
<TableHeader className={classNames('bg-medium-gray', className)}>
<TableRow>{children}</TableRow>
</TableHeader>
);
Expand Down
37 changes: 32 additions & 5 deletions dashboard/src/components/TestsTable/DefaultTestsColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ColumnDef } from '@tanstack/react-table';
import type { CellContext, ColumnDef } from '@tanstack/react-table';

import type { JSX } from 'react';

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

const INDENT_WIDTH = 20;

const PathCell = ({
row,
getValue,
}: CellContext<TPathTests, unknown>): JSX.Element => {
const value = getValue() as string;
const depth = row.depth;
const indent = depth * INDENT_WIDTH;

const hasSubGroups =
row.original.sub_groups !== undefined && row.original.sub_groups.length > 0;
const hasIndividualTests = row.original.individual_tests.length > 0;
const isExpandable = hasSubGroups || hasIndividualTests;

return (
<div className="flex items-center" style={{ paddingLeft: `${indent}px` }}>
{isExpandable && (
<span className="mr-2">
<ChevronRightAnimate
isExpanded={row.getIsExpanded()}
animated={false}
/>
</span>
)}
<span>{value}</span>
</div>
);
};

export const defaultColumns: ColumnDef<TPathTests>[] = [
{
accessorKey: 'path_group',
header: ({ column }): JSX.Element => (
<TableHeader column={column} intlKey="global.path" />
),
cell: PathCell,
},
{
accessorKey: 'pass_tests',
Expand All @@ -52,10 +83,6 @@ export const defaultColumns: ColumnDef<TPathTests>[] = [
);
},
},
{
id: 'chevron',
cell: (): JSX.Element => <ChevronRightAnimate />,
},
];

export const defaultInnerColumns: ColumnDef<TIndividualTest>[] = [
Expand Down
Loading
Loading