Skip to content

Commit

Permalink
Add a badge indicating if the release is latest or stale (#3116)
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanmai authored Oct 30, 2024
1 parent 7023b47 commit 2abee24
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion helm-frontend/public/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
window.RELEASE = "v1.0.0";
window.RELEASE = "v1.9.0";
window.BENCHMARK_OUTPUT_BASE_URL =
"https://storage.googleapis.com/crfm-helm-public/lite/benchmark_output/";
window.PROJECT_ID = "lite";
33 changes: 19 additions & 14 deletions helm-frontend/src/components/ReleaseDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Badge } from "@tremor/react";
import { useEffect, useState } from "react";
import getReleaseSummary from "@/services/getReleaseSummary";
import ReleaseSummary from "@/types/ReleaseSummary";
Expand Down Expand Up @@ -40,13 +41,6 @@ function ReleaseDropdown() {
});
}, []);

function getReleases(): string[] {
return currProjectMetadata !== undefined &&
currProjectMetadata.releases !== undefined
? currProjectMetadata.releases
: ["v1.0.0"];
}

useEffect(() => {
const controller = new AbortController();
async function fetchData() {
Expand All @@ -58,20 +52,31 @@ function ReleaseDropdown() {
return () => controller.abort();
}, []);

const releases = getReleases();
const releases =
currProjectMetadata !== undefined &&
currProjectMetadata.releases !== undefined
? currProjectMetadata.releases
: ["v1.0.0"];

if (!summary.release && !summary.suite) {
const currentVersion = summary.release || summary.suite || null;

if (!currentVersion) {
return null;
}

const releaseInfo = `Release ${summary.release || summary.suite} (${
summary.date
})`;
const releaseInfo = `Release ${currentVersion} (${summary.date})`;

if (releases.length <= 1) {
return <div>{releaseInfo}</div>;
}

const badge =
releases.length > 0 && currentVersion != releases[0] ? (
<Badge color="yellow">stale</Badge>
) : (
<Badge color="blue">latest</Badge>
);

return (
<div className="dropdown">
<div
Expand All @@ -81,7 +86,7 @@ function ReleaseDropdown() {
aria-haspopup="true"
aria-controls="menu"
>
{releaseInfo}&nbsp;
{releaseInfo}&nbsp;{badge}&nbsp;
<ChevronDownIcon
fill="black"
color="black"
Expand All @@ -90,7 +95,7 @@ function ReleaseDropdown() {
</div>
<ul
tabIndex={0}
className="dropdown-content z-[1] menu p-1 shadow-lg bg-base-100 rounded-box w-max text-base"
className="dropdown-content z-[50] menu p-1 shadow-lg bg-base-100 rounded-box w-max text-base"
role="menu"
>
{releases.map((release) => (
Expand Down

0 comments on commit 2abee24

Please sign in to comment.