Skip to content

Commit 1dd8b8d

Browse files
committed
feat: add tooltip support in DetailsTable and add more information tooltip for tag line
1 parent 4d964aa commit 1dd8b8d

File tree

3 files changed

+113
-14
lines changed

3 files changed

+113
-14
lines changed

src/modules/DetailsTable.tsx

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
import { Info } from 'lucide-react';
12
import { Table, TableBody, TableCell, TableRow } from '@/components/ui/table';
3+
import {
4+
Tooltip,
5+
TooltipContent,
6+
TooltipProvider,
7+
TooltipTrigger,
8+
} from '@/components/ui/tooltip';
29

310
type DealDetailsTableProps = {
411
details: Record<string, React.ReactNode | React.ReactNode[]>;
@@ -12,18 +19,44 @@ export function DetailsTable({ details, zebra = true }: DealDetailsTableProps) {
1219
return (
1320
<Table>
1421
<TableBody zebra={zebra}>
15-
{Object.entries(details).map(([key, value], i) => (
16-
<TableRow key={i}>
17-
<TableCell className="min-w-32 text-pretty! whitespace-normal">
18-
<p>{key} :</p>
19-
</TableCell>
20-
<TableCell className="relative overflow-x-auto">
21-
{Array.isArray(value)
22-
? value.map((v, j) => <div key={j}>{v}</div>)
23-
: value}
24-
</TableCell>
25-
</TableRow>
26-
))}
22+
{Object.entries(details).map(([key, value], i) => {
23+
// Si value est un objet avec .tooltip et .value
24+
const hasTooltip =
25+
value &&
26+
typeof value === 'object' &&
27+
'tooltip' in value &&
28+
'value' in value;
29+
return (
30+
<TableRow key={i}>
31+
<TableCell className="min-w-32 text-pretty! whitespace-normal">
32+
<span className="flex items-center gap-1">
33+
{hasTooltip && (
34+
<TooltipProvider delayDuration={0}>
35+
<Tooltip>
36+
<TooltipTrigger asChild>
37+
<span className="flex items-center gap-1">
38+
<Info size={14} />
39+
</span>
40+
</TooltipTrigger>
41+
<TooltipContent side="top" className="max-w-sm">
42+
{(value as { tooltip: React.ReactNode }).tooltip}
43+
</TooltipContent>
44+
</Tooltip>
45+
</TooltipProvider>
46+
)}
47+
<span>{key}</span>
48+
</span>
49+
</TableCell>
50+
<TableCell className="relative overflow-x-auto">
51+
{hasTooltip
52+
? (value.value as React.ReactNode)
53+
: Array.isArray(value)
54+
? value.map((v, j) => <div key={j}>{v}</div>)
55+
: (value as React.ReactNode)}
56+
</TableCell>
57+
</TableRow>
58+
);
59+
})}
2760
</TableBody>
2861
</Table>
2962
);

src/modules/deals/deal/buildDealDetails.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,40 @@ export function buildDealDetails({
6060
),
6161
}),
6262
...(deal.tag && {
63-
Tag: <Bytes>{deal.tag}</Bytes>,
63+
Tag: {
64+
tooltip: (
65+
<>
66+
Indicates the execution environment type defined by iExec :
67+
<ul className="list-inside list-disc">
68+
<li>
69+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
70+
0x0
71+
</code>
72+
: Standard
73+
</li>
74+
<li>
75+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
76+
0x3
77+
</code>
78+
: SGX Scone
79+
</li>
80+
<li>
81+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
82+
0x5
83+
</code>
84+
: SGX Gramine
85+
</li>
86+
<li>
87+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
88+
0x9
89+
</code>
90+
: TDX
91+
</li>
92+
</ul>
93+
</>
94+
),
95+
value: <Bytes>{deal.tag}</Bytes>,
96+
},
6497
}),
6598
...(deal.trust && {
6699
Trust: <p>{deal.trust}</p>,

src/modules/tasks/task/buildTaskDetails.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,40 @@ export function buildTaskDetails({ task }: { task: TaskQuery['task'] }) {
5757
),
5858
}),
5959
...(task.deal.tag && {
60-
Tag: <Bytes>{task.deal.tag}</Bytes>,
60+
Tag: {
61+
tooltip: (
62+
<>
63+
Indicates the execution environment type defined by iExec :
64+
<ul className="list-inside list-disc">
65+
<li>
66+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
67+
0x0
68+
</code>
69+
: Standard
70+
</li>
71+
<li>
72+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
73+
0x3
74+
</code>
75+
: SGX Scone
76+
</li>
77+
<li>
78+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
79+
0x5
80+
</code>
81+
: SGX Gramine
82+
</li>
83+
<li>
84+
<code className="bg-primary-foreground text-primary -mx-1 rounded-sm px-1 py-px">
85+
0x9
86+
</code>
87+
: TDX
88+
</li>
89+
</ul>
90+
</>
91+
),
92+
value: <Bytes>{task.deal.tag}</Bytes>,
93+
},
6194
}),
6295
...(task.deal.app && {
6396
App: (

0 commit comments

Comments
 (0)