Skip to content

Commit 517600d

Browse files
committed
anpassungen purlpage
1 parent 384c6f4 commit 517600d

File tree

2 files changed

+94
-80
lines changed

2 files changed

+94
-80
lines changed

src/components/package-inspector/ProjectStats.tsx

Lines changed: 81 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Project } from './types'
1111
import { Badge } from '@/components/ui/badge'
1212

1313
interface ProjectStatsProps {
14-
project: Project
14+
project: Project | null
1515
purl: string
1616
published?: string
1717
isMalicious: boolean
@@ -44,9 +44,11 @@ export default function ProjectStats({
4444

4545
return (
4646
<div className="space-y-3">
47-
<p className="line-clamp-2 text-lg text-gray-400">
48-
{project.description}
49-
</p>
47+
{project?.description && (
48+
<p className="line-clamp-2 text-lg text-gray-400">
49+
{project.description}
50+
</p>
51+
)}
5052

5153
<div className="flex flex-wrap items-center gap-2">
5254
<Badge
@@ -56,27 +58,31 @@ export default function ProjectStats({
5658
<Package className="h-4 w-4" />
5759
{packageManager}
5860
</Badge>
59-
<Badge
60-
variant="outline"
61-
className="flex w-fit items-center gap-1.5 text-sm"
62-
>
63-
<Scale className="h-4 w-4" />
64-
{project.license}
65-
</Badge>
66-
<Badge
67-
variant="outline"
68-
className="flex w-fit items-center gap-1.5 text-sm"
69-
>
70-
<Star className="h-4 w-4" />
71-
{project.starsCount.toLocaleString('de-DE')}
72-
</Badge>
73-
<Badge
74-
variant="outline"
75-
className="flex w-fit items-center gap-1.5 text-sm"
76-
>
77-
<GitFork className="h-4 w-4" />
78-
{project.forksCount.toLocaleString('de-DE')}
79-
</Badge>
61+
{project && (
62+
<>
63+
<Badge
64+
variant="outline"
65+
className="flex w-fit items-center gap-1.5 text-sm"
66+
>
67+
<Scale className="h-4 w-4" />
68+
{project.license}
69+
</Badge>
70+
<Badge
71+
variant="outline"
72+
className="flex w-fit items-center gap-1.5 text-sm"
73+
>
74+
<Star className="h-4 w-4" />
75+
{project.starsCount.toLocaleString('de-DE')}
76+
</Badge>
77+
<Badge
78+
variant="outline"
79+
className="flex w-fit items-center gap-1.5 text-sm"
80+
>
81+
<GitFork className="h-4 w-4" />
82+
{project.forksCount.toLocaleString('de-DE')}
83+
</Badge>
84+
</>
85+
)}
8086
</div>
8187

8288
<div className="flex flex-wrap gap-x-4 text-xs text-gray-400">
@@ -92,53 +98,57 @@ export default function ProjectStats({
9298
)}
9399
</div>
94100

95-
<div className="flex flex-wrap items-center gap-4">
96-
<a
97-
href={'https://' + project.projectKey}
98-
target="_blank"
99-
rel="noopener noreferrer"
100-
className="flex items-center gap-1.5 text-sm text-blue-400 hover:underline"
101-
>
102-
<ExternalLink className="h-4 w-4" />
103-
View on GitHub
104-
</a>
105-
</div>
106-
<div className="flex flex-wrap items-center">
107-
{project.homepage && (
108-
<a
109-
href={project.homepage}
110-
target="_blank"
111-
rel="noopener noreferrer"
112-
className="flex items-center gap-1.5 text-sm text-blue-400 hover:underline"
113-
>
114-
<ExternalLink className="h-4 w-4" />
115-
Project Homepage
116-
</a>
117-
)}
118-
</div>
119-
<div className="flex flex-wrap items-center">
120-
{!isMalicious && (
121-
<div>
122-
<div className="flex items-center gap-1.5 rounded-md border border-green-700 bg-green-900/30 px-3 py-2">
123-
<ShieldCheck className="h-4 w-4 shrink-0 text-green-400" />
124-
<span className="text-xs font-semibold text-green-300">
125-
Not flagged as malicious
126-
</span>
127-
</div>
128-
<span className="mt-1 block text-xs text-gray-400">
129-
Scorecard updated:{' '}
130-
{new Date(project.updatedAt).toLocaleDateString(
131-
'en-US',
132-
{
133-
year: 'numeric',
134-
month: 'long',
135-
day: 'numeric',
136-
},
137-
)}
138-
</span>
101+
{project && (
102+
<>
103+
<div className="flex flex-wrap items-center gap-4">
104+
<a
105+
href={'https://' + project.projectKey}
106+
target="_blank"
107+
rel="noopener noreferrer"
108+
className="flex items-center gap-1.5 text-sm text-blue-400 hover:underline"
109+
>
110+
<ExternalLink className="h-4 w-4" />
111+
View on GitHub
112+
</a>
139113
</div>
140-
)}
141-
</div>
114+
<div className="flex flex-wrap items-center">
115+
{project.homepage && (
116+
<a
117+
href={project.homepage}
118+
target="_blank"
119+
rel="noopener noreferrer"
120+
className="flex items-center gap-1.5 text-sm text-blue-400 hover:underline"
121+
>
122+
<ExternalLink className="h-4 w-4" />
123+
Project Homepage
124+
</a>
125+
)}
126+
</div>
127+
<div className="flex flex-wrap items-center">
128+
{!isMalicious && (
129+
<div>
130+
<div className="flex items-center gap-1.5 rounded-md border border-green-700 bg-green-900/30 px-3 py-2">
131+
<ShieldCheck className="h-4 w-4 shrink-0 text-green-400" />
132+
<span className="text-xs font-semibold text-green-300">
133+
Not flagged as malicious
134+
</span>
135+
</div>
136+
<span className="mt-1 block text-xs text-gray-400">
137+
Scorecard updated:{' '}
138+
{new Date(project.updatedAt).toLocaleDateString(
139+
'en-US',
140+
{
141+
year: 'numeric',
142+
month: 'long',
143+
day: 'numeric',
144+
},
145+
)}
146+
</span>
147+
</div>
148+
)}
149+
</div>
150+
</>
151+
)}
142152
</div>
143153
)
144154
}

src/components/package-inspector/purlPage.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,24 @@ export default function PurlPageComponent({ purl }: { purl?: string }) {
8585
isMalicious={result.maliciousPackage != null}
8686
/>
8787
</div>
88-
<div className="shrink-0">
89-
<OverallScoreGauge score={project.scoreCardScore} />
90-
</div>
88+
{project && (
89+
<div className="shrink-0">
90+
<OverallScoreGauge score={project.scoreCardScore} />
91+
</div>
92+
)}
9193
</div>
9294
</div>
9395

9496
{/* Two-column: Scorecard + Vulnerabilities */}
9597
<div className="grid items-stretch gap-4 md:grid-cols-2">
96-
<div className="rounded-xl border border-gray-700 bg-gray-800/50 p-6">
97-
<h2 className="mb-4 text-base font-bold text-white">
98-
Open SSF Scorecard
99-
</h2>
100-
<ScoreCardChart checks={project.scoreCard.checks} />
101-
</div>
98+
{project?.scoreCard && (
99+
<div className="rounded-xl border border-gray-700 bg-gray-800/50 p-6">
100+
<h2 className="mb-4 text-base font-bold text-white">
101+
Open SSF Scorecard
102+
</h2>
103+
<ScoreCardChart checks={project.scoreCard.checks} />
104+
</div>
105+
)}
102106

103107
<div className="rounded-xl border border-gray-700 bg-gray-800/50 p-6">
104108
<h2 className="mb-4 text-base font-bold text-white">

0 commit comments

Comments
 (0)