-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
087c7a2
commit 3a4c518
Showing
9 changed files
with
101 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ui/src/components/table/table-element/ grouping-description-cell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import TooltipOnTruncate from '@/components/table/table-element/tooltip-on-truncate'; | ||
|
||
const GroupingDescriptionCell = ({ description }: { description: string }) => { | ||
return ( | ||
<TooltipOnTruncate value={description}> | ||
<div className="truncate ml-4 pr-4 sm:mr-10 md:mr-2">{description}</div> | ||
</TooltipOnTruncate> | ||
); | ||
}; | ||
|
||
export default GroupingDescriptionCell; |
17 changes: 17 additions & 0 deletions
17
ui/src/components/table/table-element/ grouping-name-cell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Link from 'next/link'; | ||
import { SquarePen } from 'lucide-react'; | ||
|
||
const GroupingNameCell = ({ path, name }: { path: string; name: string }) => { | ||
return ( | ||
<div className="m-2 w-full'"> | ||
<Link href={`/groupings/${path}`}> | ||
<div className="flex"> | ||
<SquarePen size="1.25em" className="text-text-primary" data-testid={'square-pen-icon'} /> | ||
<div className="pl-2">{name}</div> | ||
</div> | ||
</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GroupingNameCell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 16 additions & 5 deletions
21
ui/src/components/table/table-element/groupings-table-columns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
const GroupingsTableColumns = [ | ||
import { ColumnDef } from '@tanstack/react-table'; | ||
import { GroupingPath } from '@/lib/types'; | ||
import GroupingPathCell from '@/components/table/table-element/grouping-path-cell'; | ||
import GroupingDescriptionCell from '@/components/table/table-element/ grouping-description-cell'; | ||
import GroupingNameCell from '@/components/table/table-element/ grouping-name-cell'; | ||
const GroupingsTableColumns: ColumnDef<GroupingPath>[] = [ | ||
{ | ||
header: 'Grouping Name', | ||
accessorKey: 'name', | ||
enableHiding: false, | ||
sortDescFirst: true | ||
sortDescFirst: true, | ||
cell: ({ row }) => ( | ||
<GroupingNameCell path={row.getValue('path')} name={row.getValue('name')}></GroupingNameCell> | ||
) | ||
}, | ||
{ | ||
header: 'Description', | ||
accessorKey: 'description' | ||
accessorKey: 'description', | ||
cell: ({ row }) => ( | ||
<GroupingDescriptionCell description={row.getValue('description')}></GroupingDescriptionCell> | ||
) | ||
}, | ||
{ | ||
header: 'Grouping Path', | ||
accessorKey: 'path' | ||
accessorKey: 'path', | ||
cell: ({ row }) => <GroupingPathCell path={row.getValue('path')} /> | ||
} | ||
]; | ||
|
||
export default GroupingsTableColumns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
ui/tests/components/table/table-element/ grouping-description-cell.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
|
||
import userEvent from '@testing-library/user-event'; | ||
import GroupingDescriptionCell from '@/components/table/table-element/ grouping-description-cell'; | ||
|
||
describe('GroupingDescriptionCell', () => { | ||
it('renders the description inside TooltipOnTruncate', () => { | ||
const description = 'This is a test description'; | ||
render(<GroupingDescriptionCell description={description} />); | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show tooltip if description content is truncated', async () => { | ||
Object.defineProperties(HTMLElement.prototype, { | ||
scrollWidth: { get: () => 500, configurable: true }, | ||
clientWidth: { get: () => 30, configurable: true } | ||
}); | ||
|
||
const description = 'This is a test description'; | ||
render(<GroupingDescriptionCell description={description} />); | ||
|
||
const descriptionComponent = screen.getByText(description); | ||
await userEvent.hover(descriptionComponent); | ||
|
||
await waitFor(() => { | ||
expect(screen.getAllByTestId('tooltip-on-truncate')[0]).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
ui/tests/components/table/table-element/ grouping-name-cell.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { render, screen} from '@testing-library/react'; | ||
import GroupingNameCell from '@/components/table/table-element/ grouping-name-cell'; | ||
|
||
describe('GroupingNameCell', () => { | ||
it('renders the link with the correct path and displays the name', () => { | ||
const path = 'test-path'; | ||
const name = 'Test Name'; | ||
render(<GroupingNameCell path={path} name={name} />); | ||
expect(screen.getByText(name)).toBeInTheDocument(); | ||
expect(screen.getByTestId('square-pen-icon')).toBeInTheDocument(); | ||
expect(screen.getByRole('link')).toHaveAttribute('href', `/groupings/${path}`) | ||
}); | ||
}); |