Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit 49e090a

Browse files
authored
NEOS-1631: reduce constraint text (#2970)
1 parent 0be8c6c commit 49e090a

File tree

2 files changed

+59
-42
lines changed

2 files changed

+59
-42
lines changed

frontend/apps/web/components/jobs/JobMappingTable/Columns.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ function getJobMappingColumns(): ColumnDef<JobMappingRow, string>[] {
8585
header({ column }) {
8686
return <SchemaColumnHeader column={column} title="Schema" />;
8787
},
88+
cell({ getValue }) {
89+
return <TruncatedText text={getValue()} />;
90+
},
8891
});
8992

9093
const tableColumn = columnHelper.accessor((row) => row.table, {
9194
id: 'table',
9295
header({ column }) {
9396
return <SchemaColumnHeader column={column} title="Table" />;
9497
},
98+
cell({ getValue }) {
99+
return <TruncatedText text={getValue()} />;
100+
},
95101
});
96102

97103
const columnColumn = columnHelper.accessor('column', {

frontend/apps/web/components/jobs/JobMappingTable/ConstraintsCell.tsx

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
TooltipProvider,
66
TooltipTrigger,
77
} from '@/components/ui/tooltip';
8+
import { cn } from '@/libs/utils';
89
import { ReactElement } from 'react';
910

1011
interface Props {
@@ -23,63 +24,73 @@ export default function ConstraintsCell(props: Props): ReactElement {
2324
<div className="flex flex-col lg:flex-row items-start gap-1">
2425
{isPrimaryKey && (
2526
<div>
26-
<Badge
27-
variant="outline"
28-
className="text-xs bg-blue-100 text-gray-800 cursor-default dark:bg-blue-200 dark:text-gray-900"
29-
>
30-
Primary Key
31-
</Badge>
27+
<HoverBadge
28+
badgeText="P"
29+
tooltipContent="Primary Key"
30+
badgeClassName="bg-blue-100 dark:bg-blue-200"
31+
/>
3232
</div>
3333
)}
3434
{isForeignKey && (
3535
<div>
36-
<TooltipProvider>
37-
<Tooltip delayDuration={200}>
38-
<TooltipTrigger>
39-
<Badge
40-
variant="outline"
41-
className="text-xs bg-orange-100 text-gray-800 cursor-default dark:dark:text-gray-900 dark:bg-orange-300"
42-
>
43-
Foreign Key
44-
</Badge>
45-
</TooltipTrigger>
46-
<TooltipContent>
47-
{fkCols.map((col) => `Primary Key: ${col}`).join('\n')}
48-
</TooltipContent>
49-
</Tooltip>
50-
</TooltipProvider>
36+
<HoverBadge
37+
badgeText="FK"
38+
tooltipContent={`FK: ${fkCols
39+
.map((col) => `Primary Key: ${col}`)
40+
.join('\n')}`}
41+
badgeClassName="bg-orange-100 dark:bg-orange-300"
42+
/>
5143
</div>
5244
)}
5345
{isVirtualForeignKey && (
5446
<div>
55-
<TooltipProvider>
56-
<Tooltip delayDuration={200}>
57-
<TooltipTrigger>
58-
<Badge
59-
variant="outline"
60-
className="text-xs bg-orange-100 text-gray-800 cursor-default dark:dark:text-gray-900 dark:bg-orange-300"
61-
>
62-
Virtual Foreign Key
63-
</Badge>
64-
</TooltipTrigger>
65-
<TooltipContent>
66-
{vfkCols.map((col) => `Primary Key: ${col}`).join('\n')}
67-
</TooltipContent>
68-
</Tooltip>
69-
</TooltipProvider>
47+
<HoverBadge
48+
badgeText="VFK"
49+
tooltipContent={`VFK: ${vfkCols
50+
.map((col) => `Primary Key: ${col}`)
51+
.join('\n')}`}
52+
badgeClassName="bg-orange-100 dark:bg-orange-300"
53+
/>
7054
</div>
7155
)}
7256
{isUnique && (
7357
<div>
74-
<Badge
75-
variant="outline"
76-
className="text-xs bg-purple-100 text-gray-800 cursor-default dark:bg-purple-300 dark:text-gray-900"
77-
>
78-
Unique
79-
</Badge>
58+
<HoverBadge
59+
badgeText="U"
60+
tooltipContent="Unique Key"
61+
badgeClassName="bg-red-100 dark:bg-red-300"
62+
/>
8063
</div>
8164
)}
8265
</div>
8366
</span>
8467
);
8568
}
69+
70+
interface HoverBadgeProps {
71+
badgeText: string;
72+
tooltipContent: string;
73+
badgeClassName?: string;
74+
}
75+
76+
function HoverBadge(props: HoverBadgeProps): ReactElement {
77+
const { badgeText, tooltipContent, badgeClassName } = props;
78+
return (
79+
<TooltipProvider>
80+
<Tooltip delayDuration={200}>
81+
<TooltipTrigger>
82+
<Badge
83+
variant="outline"
84+
className={cn(
85+
'text-xs cursor-default text-gray-800 dark:text-gray-900',
86+
badgeClassName
87+
)}
88+
>
89+
{badgeText}
90+
</Badge>
91+
</TooltipTrigger>
92+
<TooltipContent>{tooltipContent}</TooltipContent>
93+
</Tooltip>
94+
</TooltipProvider>
95+
);
96+
}

0 commit comments

Comments
 (0)