Skip to content

Commit 91940c0

Browse files
committed
feat(ui): Remove some unwanted props from statistics cards
Signed-off-by: Jyrki Keisala <[email protected]>
1 parent bf6749a commit 91940c0

File tree

2 files changed

+92
-84
lines changed
  • ui/src

2 files changed

+92
-84
lines changed

ui/src/components/statistics-card.tsx

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,65 +17,37 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
import { Link, useParams } from '@tanstack/react-router';
21-
22-
import {
23-
AdvisorJob,
24-
AnalyzerJob,
25-
EvaluatorJob,
26-
ReporterJob,
27-
ScannerJob,
28-
} from '@/api/requests';
2920
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
3021

3122
type StatisticsCardProps = {
32-
job?:
33-
| AnalyzerJob
34-
| AdvisorJob
35-
| ScannerJob
36-
| EvaluatorJob
37-
| ReporterJob
38-
| undefined;
3923
title: string;
4024
icon?: React.ComponentType<{ className?: string }>;
4125
value?: number | string;
42-
resultsPath: 'issues' | 'packages' | 'vulnerabilities' | 'rule-violations';
43-
pollInterval: number;
26+
27+
className?: string;
4428
};
4529

4630
export const StatisticsCard = ({
4731
title,
4832
icon: Icon,
4933
value,
50-
resultsPath,
34+
className,
5135
}: StatisticsCardProps) => {
52-
const { orgId, productId, repoId, runIndex } = useParams({ strict: false });
5336
return (
54-
<Link
55-
from='/organizations/$orgId/products/$productId/repositories/$repoId/runs/$runIndex'
56-
to={resultsPath}
57-
params={{
58-
orgId: orgId || '',
59-
productId: productId || '',
60-
repoId: repoId || '',
61-
runIndex: runIndex || '',
62-
}}
63-
>
64-
<Card className='hover:bg-muted/50'>
65-
<CardHeader>
66-
<CardTitle>
67-
<div className='flex items-center justify-between'>
68-
<span className='text-sm font-semibold'>{title}</span>
69-
{Icon && <Icon />}
70-
</div>
71-
</CardTitle>
72-
</CardHeader>
73-
<CardContent className='text-sm'>
37+
<Card className={className}>
38+
<CardHeader>
39+
<CardTitle>
7440
<div className='flex items-center justify-between'>
75-
<div className='text-2xl font-bold'>{value ? value : '-'}</div>
41+
<span className='text-sm font-semibold'>{title}</span>
42+
{Icon && <Icon />}
7643
</div>
77-
</CardContent>
78-
</Card>
79-
</Link>
44+
</CardTitle>
45+
</CardHeader>
46+
<CardContent className='text-sm'>
47+
<div className='flex items-center justify-between'>
48+
<div className='text-2xl font-bold'>{value ? value : '-'}</div>
49+
</div>
50+
</CardContent>
51+
</Card>
8052
);
8153
};

ui/src/routes/_layout/organizations/$orgId/products/$productId/repositories/$repoId/_layout/runs/$runIndex/index.tsx

Lines changed: 76 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -233,46 +233,82 @@ const RunComponent = () => {
233233
</Card>
234234
</div>
235235
<div className='grid grid-cols-4 gap-2'>
236-
<StatisticsCard
237-
title='Issues'
238-
icon={() => <Bug className={`h-4 w-4 text-gray-300`} />}
239-
value='N/A'
240-
resultsPath='issues'
241-
pollInterval={pollInterval}
242-
/>
243-
<StatisticsCard
244-
title='Packages'
245-
icon={() => (
246-
<ListTree
247-
className={`h-4 w-4 ${getStatusFontColor(ortRun.jobs.analyzer?.status)}`}
248-
/>
249-
)}
250-
value={ortRun.jobs.analyzer ? '-' : 'N/A'}
251-
resultsPath='packages'
252-
pollInterval={pollInterval}
253-
/>
254-
<StatisticsCard
255-
title='Vulnerabilities'
256-
icon={() => (
257-
<ShieldQuestion
258-
className={`h-4 w-4 ${getStatusFontColor(ortRun.jobs.advisor?.status)}`}
259-
/>
260-
)}
261-
value={ortRun.jobs.advisor ? vulnTotal : 'N/A'}
262-
resultsPath='vulnerabilities'
263-
pollInterval={pollInterval}
264-
/>
265-
<StatisticsCard
266-
title='Rule Violations'
267-
icon={() => (
268-
<Scale
269-
className={`h-4 w-4 ${getStatusFontColor(ortRun.jobs.evaluator?.status)}`}
270-
/>
271-
)}
272-
value={ortRun.jobs.evaluator ? '-' : 'N/A'}
273-
resultsPath='rule-violations'
274-
pollInterval={pollInterval}
275-
/>
236+
<Link
237+
to='/organizations/$orgId/products/$productId/repositories/$repoId/runs/$runIndex/issues'
238+
params={{
239+
orgId: params.orgId,
240+
productId: params.productId,
241+
repoId: params.repoId,
242+
runIndex: params.runIndex,
243+
}}
244+
>
245+
<StatisticsCard
246+
title='Issues'
247+
icon={() => <Bug className={`h-4 w-4 text-gray-300`} />}
248+
value='N/A'
249+
className='hover:bg-muted/50'
250+
/>
251+
</Link>
252+
<Link
253+
to='/organizations/$orgId/products/$productId/repositories/$repoId/runs/$runIndex/packages'
254+
params={{
255+
orgId: params.orgId,
256+
productId: params.productId,
257+
repoId: params.repoId,
258+
runIndex: params.runIndex,
259+
}}
260+
>
261+
<StatisticsCard
262+
title='Packages'
263+
icon={() => (
264+
<ListTree
265+
className={`h-4 w-4 ${getStatusFontColor(ortRun.jobs.analyzer?.status)}`}
266+
/>
267+
)}
268+
value={ortRun.jobs.analyzer ? '-' : 'N/A'}
269+
className='hover:bg-muted/50'
270+
/>
271+
</Link>
272+
<Link
273+
to='/organizations/$orgId/products/$productId/repositories/$repoId/runs/$runIndex/vulnerabilities'
274+
params={{
275+
orgId: params.orgId,
276+
productId: params.productId,
277+
repoId: params.repoId,
278+
runIndex: params.runIndex,
279+
}}
280+
>
281+
<StatisticsCard
282+
title='Vulnerabilities'
283+
icon={() => (
284+
<ShieldQuestion
285+
className={`h-4 w-4 ${getStatusFontColor(ortRun.jobs.advisor?.status)}`}
286+
/>
287+
)}
288+
value={ortRun.jobs.advisor ? vulnTotal : 'N/A'}
289+
className='hover:bg-muted/50'
290+
/>
291+
</Link>
292+
<Link
293+
to='/organizations/$orgId/products/$productId/repositories/$repoId/runs/$runIndex/rule-violations'
294+
params={{
295+
orgId: params.orgId,
296+
productId: params.productId,
297+
repoId: params.repoId,
298+
runIndex: params.runIndex,
299+
}}
300+
>
301+
<StatisticsCard
302+
title='Rule Violations'
303+
icon={() => (
304+
<Scale
305+
className={`h-4 w-4 ${getStatusFontColor(ortRun.jobs.evaluator?.status)}`}
306+
/>
307+
)}
308+
value={ortRun.jobs.evaluator ? '-' : 'N/A'}
309+
className='hover:bg-muted/50'
310+
/>
311+
</Link>
276312
</div>
277313
<Card className='flex flex-1 overflow-hidden'>
278314
<CardHeader>

0 commit comments

Comments
 (0)