Skip to content

Commit

Permalink
add EA version to nightly version selector (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Aug 10, 2023
1 parent 2cf1af3 commit 2be85f5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
19 changes: 19 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ exports.sourceNodes = async ({ actions, createNodeId }) => {
}
}
createNode(node)

// Create a node for the most_recent_feature_version
const latestFeatureVersion = data.most_recent_feature_version
const nodeContentFeatureVersion = JSON.stringify(latestFeatureVersion)
const MostRecentFeatureVersion = {
id: createNodeId('adoptium-feature-version-most-recent'), // Unique identifier for each node
version: latestFeatureVersion,
parent: null,
children: [],
internal: {
type: 'MostRecentFeatureVersion',
content: nodeContentFeatureVersion,
contentDigest: crypto
.createHash('md5')
.update(nodeContentFeatureVersion)
.digest('hex')
}
}
createNode(MostRecentFeatureVersion)
}

exports.onCreatePage = ({ page, actions }) => {
Expand Down
17 changes: 10 additions & 7 deletions src/components/DownloadDropdowns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ let defaultArch = 'any'

const DownloadDropdowns = ({updaterAction, marketplace, Table}) => {
const data = useStaticQuery(graphql`
query VersionsQuery {
query VersionsQuery {
allVersions(sort: {version: DESC}) {
edges {
edges {
node {
version
label
lts
}
version
label
lts
}
}
}
mostRecentLts {
version
version
}
mostRecentFeatureVersion {
version
}
}
`)

const defaultVersion = data.mostRecentLts.version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ exports[`VersionSelector > updates the number of builds and build date when the
id=\\"version-filter\\"
style=\\"max-width: 10em;\\"
>
<option
value=\\"2\\"
>
2 - EA
</option>
<option
value=\\"1\\"
>
Expand Down
14 changes: 11 additions & 3 deletions src/components/VersionSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ const VersionSelector = ({updater, releaseType, Table}) => {
mostRecentLts {
version
}
mostRecentFeatureVersion {
version
}
}
`)

const defaultVersion = data.mostRecentLts.version;
const mostRecentFeatureVersion = data.mostRecentFeatureVersion.version;
const versions = data.allVersions.edges;

const { language } = useI18next();
Expand Down Expand Up @@ -81,11 +85,15 @@ 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(
(version, i): number | JSX.Element => version && (
<option key={version.node.id} value={version.node.version}>{version.node.label}</option>
)
(version, i): number | JSX.Element => version && (
<option key={version.node.id} value={version.node.version}>{version.node.label}</option>
)
)}
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ exports[`Temurin Nightly page > renders correctly 1`] = `
id="version-filter"
style="max-width: 10em;"
>
<option
value="2"
>
2 - EA
</option>
<option
value="1"
>
Expand Down
3 changes: 3 additions & 0 deletions vitest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ vi.mock('gatsby', async () => {
mostRecentLts: {
version: 1,
},
mostRecentFeatureVersion: {
version: 2,
},
allVersions: {
edges: [
{
Expand Down

0 comments on commit 2be85f5

Please sign in to comment.