Skip to content

Commit c9740ea

Browse files
authored
fix(frontend): add links to the settings page in the score page (#425)
This PR adds links to the settings page in the score page. Closes #423 Before: <img width="830" alt="image" src="https://github.com/jsr-io/jsr/assets/3132889/cff9ef0e-4e12-4491-a4c2-2c563b5b3783"> After(with admin role): <img width="841" alt="image" src="https://github.com/jsr-io/jsr/assets/3132889/12d3791d-e193-498c-9df9-5b1dc4f74053"> After(without admin role): <img width="830" alt="image" src="https://github.com/jsr-io/jsr/assets/3132889/71a17259-cd0f-4078-9d2f-385c8fe4b99d">
1 parent 33d195b commit c9740ea

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

frontend/routes/package/score.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default function Score(
6161
name={data.package.name}
6262
scorePercentage={data.package.score}
6363
score={data.score}
64+
canAdmin={iam.canAdmin}
6465
/>
6566
)
6667
: (
@@ -78,8 +79,9 @@ function ScoreInfo(props: {
7879
name: string;
7980
scorePercentage: number;
8081
score: PackageScore;
82+
canAdmin: boolean;
8183
}) {
82-
const { scope, name, scorePercentage, score } = props;
84+
const { scope, name, scorePercentage, score, canAdmin } = props;
8385

8486
return (
8587
<div class="mt-8 grid items-center justify-items-center grid-cols-1 md:grid-cols-3 gap-12">
@@ -173,25 +175,43 @@ function ScoreInfo(props: {
173175
scoreValue={1}
174176
title="Has a description"
175177
>
176-
The package should have a description set in the package settings to
177-
help users find this package via search.
178+
The package should have a description set in {canAdmin
179+
? (
180+
<a class="link" href="settings#description">
181+
the package settings
182+
</a>
183+
)
184+
: "the package settings"}{" "}
185+
to help users find this package via search.
178186
</ScoreItem>
179187
<ScoreItem
180188
value={score.atLeastOneRuntimeCompatible}
181189
scoreValue={1}
182190
title="At least one runtime is marked as compatible"
183191
>
184192
The package should be marked with at least one runtime as "compatible"
185-
in the package settings to aid users in understanding where they can
186-
use this package.
193+
in {canAdmin
194+
? (
195+
<a class="link" href="settings#runtime_compat">
196+
the package settings
197+
</a>
198+
)
199+
: "the package settings"}{" "}
200+
to aid users in understanding where they can use this package.
187201
</ScoreItem>
188202
<ScoreItem
189203
value={score.multipleRuntimesCompatible}
190204
scoreValue={1}
191205
title="At least two runtimes are marked as compatible"
192206
>
193207
The package should be compatible with more than one runtime, and be
194-
marked as such in the package settings.
208+
marked as such in {canAdmin
209+
? (
210+
<a class="link" href="settings#runtime_compat">
211+
the package settings
212+
</a>
213+
)
214+
: "the package settings"}.
195215
</ScoreItem>
196216
<ScoreItem
197217
value={score.hasProvenance}

frontend/routes/package/settings.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function GitHubRepository(props: { package: Package }) {
100100
function DescriptionEditor(props: { description: string }) {
101101
return (
102102
<form class="mt-8" method="POST">
103-
<h2 class="text-xl font-sans font-bold">Description</h2>
103+
<h2 class="text-xl font-sans font-bold" id="description">Description</h2>
104104

105105
<p class="mt-2 text-gray-600 max-w-3xl">
106106
The package description is shown on the package page and in search
@@ -117,7 +117,9 @@ function DescriptionEditor(props: { description: string }) {
117117
function RuntimeCompatEditor(props: { runtimeCompat: RuntimeCompat }) {
118118
return (
119119
<form class="border-t pt-8 mt-12" method="POST">
120-
<h2 class="text-xl font-sans font-bold">Runtime Compat</h2>
120+
<h2 class="text-xl font-sans font-bold" id="runtime_compat">
121+
Runtime Compat
122+
</h2>
121123

122124
<p class="mt-2 text-gray-600 max-w-3xl">
123125
Set which packages this package is compatible with. This information is

0 commit comments

Comments
 (0)