Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add color to scorecard menu #253

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@nodesecure/flags": "^2.4.0",
"@nodesecure/i18n": "^3.2.2",
"@nodesecure/npm-registry-sdk": "^1.6.1",
"@nodesecure/ossf-scorecard-sdk": "^3.0.0",
"@nodesecure/ossf-scorecard-sdk": "^2.0.0",
"@nodesecure/rc": "^1.5.0",
"@nodesecure/scanner": "^5.0.1",
"@nodesecure/utils": "^1.1.0",
Expand Down
17 changes: 17 additions & 0 deletions public/css/components/package/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,20 @@ section#package-info>.package-navigation>div>.signal {
section#package-info>.package-navigation>div#scorecard-menu {
display: none;
}

section#package-info>.package-navigation>div#scorecard-menu.red {
border: 2px solid #EF5350;
color: #FF80AB;
}
section#package-info>.package-navigation>div#scorecard-menu.orange {
border: 2px solid #FDD835;
color: #FFD740;
}
section#package-info>.package-navigation>div#scorecard-menu.blue {
border: 2px solid #2962FF;
color: #BBDEFB;
}
section#package-info>.package-navigation>div#scorecard-menu.green {
border: 2px solid #00E676;
color: #B2FF59;
}
17 changes: 17 additions & 0 deletions public/js/components/package/pannels/scorecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ export class Scorecard {
});
}

getScoreColor(score) {
if (score < 4) {
return "red";
}
if (score < 6.5) {
return "orange";
}
if (score < 8.5) {
return "blue";
}

return "green";
}

renderScorecard(data, repoName) {
const { score, checks } = data;

Expand All @@ -74,6 +88,9 @@ export class Scorecard {
}

document.getElementById('ossf-score').innerText = score;
document.getElementById('scorecard-menu').classList.add(
this.getScoreColor(score)
);
document.getElementById('head-score').innerText = score;
document
.querySelector(".score-header .visualizer a")
Expand Down
6 changes: 5 additions & 1 deletion src/http-server/endpoints/ossf-scorecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export async function get(req, res) {
}

catch (error) {
return send(res, error.statusCode ?? 404, { error: error.statusMessage ?? "Not Found" });
return send(
res,
error.statusCode ?? 404,
{ error: error.statusMessage ?? "Not Found" }
);
}
}
2 changes: 1 addition & 1 deletion test/helpers/cliCommandRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fork } from "node:child_process";
import { createInterface } from "node:readline";

// Import Third-party Dependencies
import { MockAgent, setGlobalDispatcher } from "@myunisoft/httpie";
import { MockAgent, setGlobalDispatcher } from "undici";
import stripAnsi from "strip-ansi";

export async function* runProcess(options) {
Expand Down
Loading