Skip to content

Commit

Permalink
Use dynamic export instead of import for GroupingsTable
Browse files Browse the repository at this point in the history
  • Loading branch information
JorWo committed Nov 21, 2024
1 parent 6313241 commit 860037f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
9 changes: 1 addition & 8 deletions ui/src/app/groupings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { ownerGroupings } from '@/lib/fetchers';
import dynamic from 'next/dynamic';
import GroupingsTableSkeleton from '@/components/table/groupings-table-skeleton';

// Require dynamic import for localStorage
const GroupingsTable = dynamic(() => import('@/components/table/groupings-table'), {
ssr: false,
loading: () => <GroupingsTableSkeleton />
});
import GroupingsTable from '@/components/table/groupings-table';

const Groupings = async () => {
const { groupingPaths } = await ownerGroupings();
Expand Down
7 changes: 6 additions & 1 deletion ui/src/components/table/groupings-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { useState } from 'react';
import { useLocalStorage } from 'usehooks-ts';
import { GroupingPath } from '@/lib/types';
import GroupingsTableColumns from '@/components/table/table-element/groupings-table-columns';
import dynamic from 'next/dynamic';
import GroupingsTableSkeleton from './groupings-table-skeleton';

const pageSize = parseInt(process.env.NEXT_PUBLIC_PAGE_SIZE as string);

Expand Down Expand Up @@ -100,4 +102,7 @@ const GroupingsTable = ({ groupingPaths }: { groupingPaths: GroupingPath[] }) =>
);
};

export default GroupingsTable;
export default dynamic(() => Promise.resolve(GroupingsTable), {
ssr: false, // Disables SSR for localStorage
loading: () => <GroupingsTableSkeleton />
});
8 changes: 6 additions & 2 deletions ui/src/components/table/table-element/grouping-path-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ const GroupingPathCell = ({ path }: { path: string }) => {
justify-center hover:bg-green-blue h-6 p-2 transition ease-in-out duration-150"
data-testid="clipboard-button"
>
<FontAwesomeIcon className="group-hover:text-white h-4 w-4 text-gray-600" data-testid="clipboard-icon" icon={faClipboard} />
<FontAwesomeIcon
className="group-hover:text-white h-4 w-4 text-gray-600"
data-testid="clipboard-icon"
icon={faClipboard}
/>
</button>
</TooltipTrigger>
<TooltipContent>
<TooltipContent className="bg-white text-slate-950">
<p data-testid="tooltip">{tooltipContent}</p>
</TooltipContent>
</Tooltip>
Expand Down
4 changes: 3 additions & 1 deletion ui/tests/components/table/groupings-table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe('GroupingsTable', () => {

// Check for "Manage Groupings", filter, and column settings
expect(screen.getByText('Manage Groupings')).toBeInTheDocument();
expect(screen.getByPlaceholderText('Filter Groupings...')).toBeInTheDocument();
await waitFor(() => {
expect(screen.getByPlaceholderText('Filter Groupings...')).toBeInTheDocument();
});
expect(screen.getByLabelText('column-settings-button')).toBeInTheDocument();

// Check for table column headers
Expand Down

0 comments on commit 860037f

Please sign in to comment.