-
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
22f7c0e
commit afa5723
Showing
10 changed files
with
120 additions
and
80 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
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; |
18 changes: 18 additions & 0 deletions
18
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,18 @@ | ||
import Link from 'next/link'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faEdit } from '@fortawesome/free-regular-svg-icons'; | ||
|
||
const GroupingNameCell = ({ path, name }: { path: string; name: string }) => { | ||
return ( | ||
<div className="m-2 w-full'"> | ||
<Link href={`/groupings/${path}`}> | ||
<div className="flex"> | ||
<FontAwesomeIcon className="text-text-primary" data-testid={'edit-icon'} icon={faEdit} /> | ||
<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
22 changes: 17 additions & 5 deletions
22
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,30 @@ | ||
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
28 changes: 28 additions & 0 deletions
28
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,28 @@ | ||
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('edit-icon')).toBeInTheDocument(); | ||
expect(screen.getByRole('link')).toHaveAttribute('href', `/groupings/${path}`) | ||
}); | ||
}); |