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

[3016] Assume that there are EA versions for versions between 16 and … #3059

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
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,60 @@ exports[`VersionSelector > updates the number of builds and build date when the
style="max-width: 10em;"
>
<option
value="2"
value="24"
>
2 - EA
24 - EA
</option>
<option
value="1"
value="23"
>
1 - LTS
23 - EA
</option>
<option
value="22"
>
22 - EA
</option>
<option
value="21"
>
21 - EA
</option>
<option
value="20"
>
20 - EA
</option>
<option
value="19"
>
19 - EA
</option>
<option
value="18"
>
18 - EA
</option>
<option
value="17"
>
17 - EA
</option>
<option
value="16"
>
16 - EA
</option>
<option
value="2"
>
2
</option>
<option
value="1"
>
1 - LTS
</option>
</select>
</div>
<div
Expand Down
36 changes: 30 additions & 6 deletions src/components/VersionSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,35 @@ const VersionSelector = ({updater, releaseType, Table}) => {
udateNumBuilds(number);
}, []);

const versionsToDisplay = [...versions]

if(releaseType === "ea") {
// if releaseType is "ea", add missing "ea" versions up to mostRecentFeatureVersion
const range = (start: number, stop: number, step: number) =>
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);

// https://github.com/adoptium/adoptium.net/issues/3016
// johnoliver: "assume that there are EA versions for versions between 16 and most_recent_feature_version"
const sixteenToLastEA = range(16, mostRecentFeatureVersion, 1);

sixteenToLastEA.forEach(version => {
if(versionsToDisplay.findIndex(v => v.node.version === version) < 0) {
// this version number is missing, append to the version list
const v = {
node: {
id: version,
version: version,
label: `${version} - EA`
}
}
versionsToDisplay.push(v)
}
})

// sort by version DESC
versionsToDisplay.sort((v1, v2) => v2.node.version - v1.node.version)
}

return (
<>
<p className='text-center'>
Expand All @@ -86,12 +115,7 @@ const VersionSelector = ({updater, releaseType, Table}) => {
<div className="input-group p-3 d-flex justify-content-center">
<label className="px-2 fw-bold" htmlFor="version"><Trans>Version</Trans></label>
<select data-testid="version-filter" aria-label="version-filter" id="version-filter" onChange={(e) => setVersion(e.target.value)} value={version} className="form-select form-select-sm" style={{ maxWidth: '10em' }}>
{/* if releaseType is ea add another option */}
{releaseType === "ea" && (
<option key={mostRecentFeatureVersion} value={mostRecentFeatureVersion}>{`${mostRecentFeatureVersion} - EA`}</option>
)}
{/* loop through versions array from graphql */}
{versions.map(
{versionsToDisplay.map(
(version, i): number | JSX.Element => version && (
<option key={version.node.id} value={version.node.version}>{version.node.label}</option>
)
Expand Down
48 changes: 44 additions & 4 deletions src/pages/temurin/__tests__/__snapshots__/nightly.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,60 @@ exports[`Temurin Nightly page > renders correctly 1`] = `
style="max-width: 10em;"
>
<option
value="2"
value="24"
>
2 - EA
24 - EA
</option>
<option
value="1"
value="23"
>
1 - LTS
23 - EA
</option>
<option
value="22"
>
22 - EA
</option>
<option
value="21"
>
21 - EA
</option>
<option
value="20"
>
20 - EA
</option>
<option
value="19"
>
19 - EA
</option>
<option
value="18"
>
18 - EA
</option>
<option
value="17"
>
17 - EA
</option>
<option
value="16"
>
16 - EA
</option>
<option
value="2"
>
2
</option>
<option
value="1"
>
1 - LTS
</option>
</select>
</div>
<div
Expand Down
2 changes: 1 addition & 1 deletion vitest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ vi.mock('gatsby', async () => {
version: 1,
},
mostRecentFeatureVersion: {
version: 2,
version: 24,
},
allVersions: {
edges: [
Expand Down