diff --git a/package.json b/package.json index 1b2e405e..a3fd66ad 100644 --- a/package.json +++ b/package.json @@ -46,4 +46,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file diff --git a/src/pages/DownloadPage.tsx b/src/pages/DownloadPage.tsx index 768fb0a6..8245f4b5 100644 --- a/src/pages/DownloadPage.tsx +++ b/src/pages/DownloadPage.tsx @@ -7,9 +7,12 @@ import { Button } from "react-bootstrap"; import { Alert } from "react-bootstrap"; import { Container } from "react-bootstrap"; +// Currently the timestamp here is undefined regardless of jenkins timestamp! + const DownloadPage = () => { const [jobs, setJobs] = useState(new Map()) const [version, setVersion] = useState("1.19") + const versions = ["1.17.1", "1.18.2", "1.19"] useEffect(() => { doJobs().then(value => { }) @@ -19,14 +22,16 @@ const DownloadPage = () => { return new Promise(resolve => { getJobs().then(value => { for (let job of value) { + // if the job name is not included in versions array, then skip it. + if (!versions.includes(job.name)) { + continue; + } + getBuilds(job.name).then(value1 => { setJobs(prevState => { - let map = new Map([...prevState, [job, value1]]) - if (map.size >= value.length) { - let job = Array.from(map.keys()).sort((a, b) => parseFloat(a.name) - parseFloat(b.name)).reverse()[0] - setVersion(job.name) - } - return new Map([ ...map.entries() ].sort((a, b) => parseFloat(a[0].name) - parseFloat(b[0].name)).reverse()) + let newState = new Map(prevState) + newState.set(job, value1) + return newState }) resolve() }) @@ -51,13 +56,23 @@ const DownloadPage = () => { P.S. If you know React, PLEASE help us make this look better. Our code is here.

-
    - {Array.from(jobs.keys()).map(value => { +
      + {Array.from(jobs.keys()).sort(function(x, y) { + let x1 = x.name.split(".") + let y1 = y.name.split(".") + if (x1.length >= 3) { + x1 = x1.slice(0, x1.length - 1) + } + if (y1.length >= 3) { + y1 = y1.slice(0, y1.length - 1) + } + return y1.join(".") > x1.join(".") ? 1 : -1 + }).map(value => { return
    • {value.name}
    • })}
    -
      +
        {jobs.get(Array.from(jobs.keys()).filter(value => value.name === version)[0])?.map(value => { return
      • diff --git a/src/util/Jenkins.ts b/src/util/Jenkins.ts index 7c0b2cff..5c99b7fb 100644 --- a/src/util/Jenkins.ts +++ b/src/util/Jenkins.ts @@ -22,7 +22,7 @@ export type BuildChange = { } export function getJobs(): Promise { - let jobs: Job[] = [] + let jobs: Job[] = []; let request = axios.get(`${JENKINS_URL}/${ARTIFACT_NAME}/api/json?pretty=true`) return new Promise((resolve, reject) => { @@ -40,10 +40,8 @@ export function getBuilds(version: string): Promise { return new Promise((resolve, reject) => { request.then(value => { builds = value.data.builds as Build[] - let count = 0; for (let build of builds) { axios.get(`${JENKINS_URL}/${ARTIFACT_NAME}/job/${version}/${build.number}/api/json?pretty=true`).then(value1 => { - build.timestamp = value1.data.timestamp let changeSet: any[] = value1.data.changeSets if (changeSet.length > 0) { let changes = changeSet[0].items as BuildChange[] @@ -58,10 +56,7 @@ export function getBuilds(version: string): Promise { } } - count++; - if (count === builds.length - 1) { - resolve(builds) - } + resolve(builds) } }) }