Skip to content

Commit

Permalink
[3016] Assume that there are EA versions for versions between 16 and … (
Browse files Browse the repository at this point in the history
#3059)

* [3016] Assume that there are EA versions for versions between 16 and most_recent_feature_version

* update snapshots

* Fix tests coverage

* if releaseType is "ea", add missing "ea" versions up to mostRecentFeatureVersion

---------

Co-authored-by: Martijn Verburg <[email protected]>
  • Loading branch information
xavierfacq and karianna authored Sep 9, 2024
1 parent f965dbf commit 48fec4e
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 15 deletions.
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
[33mvalue[39m=[32m"2"[39m
[33mvalue[39m=[32m"24"[39m
>
[0m2 - EA[0m
[0m24 - EA[0m
</option>
<option
[33mvalue[39m=[32m"1"[39m
[33mvalue[39m=[32m"23"[39m
>
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

0 comments on commit 48fec4e

Please sign in to comment.