mirror of
https://github.com/AtlasMediaGroup/Scissors-Website.git
synced 2024-12-25 11:27:41 +00:00
Fix where the array only have one version when there are more - timestamp doesn't work
This commit is contained in:
parent
729362e790
commit
84677b8d81
@ -46,4 +46,4 @@
|
|||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,9 +7,12 @@ import { Button } from "react-bootstrap";
|
|||||||
import { Alert } from "react-bootstrap";
|
import { Alert } from "react-bootstrap";
|
||||||
import { Container } from "react-bootstrap";
|
import { Container } from "react-bootstrap";
|
||||||
|
|
||||||
|
// Currently the timestamp here is undefined regardless of jenkins timestamp!
|
||||||
|
|
||||||
const DownloadPage = () => {
|
const DownloadPage = () => {
|
||||||
const [jobs, setJobs] = useState(new Map<Job, Build[]>())
|
const [jobs, setJobs] = useState(new Map<Job, Build[]>())
|
||||||
const [version, setVersion] = useState("1.19")
|
const [version, setVersion] = useState("1.19")
|
||||||
|
const versions = ["1.17.1", "1.18.2", "1.19"]
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
doJobs().then(value => {
|
doJobs().then(value => {
|
||||||
})
|
})
|
||||||
@ -19,14 +22,16 @@ const DownloadPage = () => {
|
|||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
getJobs().then(value => {
|
getJobs().then(value => {
|
||||||
for (let job of 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 => {
|
getBuilds(job.name).then(value1 => {
|
||||||
setJobs(prevState => {
|
setJobs(prevState => {
|
||||||
let map = new Map<Job, Build[]>([...prevState, [job, value1]])
|
let newState = new Map(prevState)
|
||||||
if (map.size >= value.length) {
|
newState.set(job, value1)
|
||||||
let job = Array.from(map.keys()).sort((a, b) => parseFloat(a.name) - parseFloat(b.name)).reverse()[0]
|
return newState
|
||||||
setVersion(job.name)
|
|
||||||
}
|
|
||||||
return new Map<Job, Build[]>([ ...map.entries() ].sort((a, b) => parseFloat(a[0].name) - parseFloat(b[0].name)).reverse())
|
|
||||||
})
|
})
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
@ -51,13 +56,23 @@ const DownloadPage = () => {
|
|||||||
P.S. If you know React, PLEASE help us make this look better. Our code is <a href="https://github.com/AtlasMediaGroup/Scissors-Website/tree/master">here</a>.
|
P.S. If you know React, PLEASE help us make this look better. Our code is <a href="https://github.com/AtlasMediaGroup/Scissors-Website/tree/master">here</a>.
|
||||||
</p>
|
</p>
|
||||||
</Alert>
|
</Alert>
|
||||||
<ul className={"versions"}>
|
<ul className="versions">
|
||||||
{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 <li className={version === value.name ? "selected" : "selectable"}
|
return <li className={version === value.name ? "selected" : "selectable"}
|
||||||
onClick={onClick}>{value.name}</li>
|
onClick={onClick}>{value.name}</li>
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
<ul className={"builds"}>
|
<ul className="builds">
|
||||||
{jobs.get(Array.from(jobs.keys()).filter(value => value.name === version)[0])?.map(value => {
|
{jobs.get(Array.from(jobs.keys()).filter(value => value.name === version)[0])?.map(value => {
|
||||||
return <li>
|
return <li>
|
||||||
<Button href={value.artifact ? `${value.url}/artifact/${value.artifact}` : value.url}>#{value.number}</Button>
|
<Button href={value.artifact ? `${value.url}/artifact/${value.artifact}` : value.url}>#{value.number}</Button>
|
||||||
|
@ -22,7 +22,7 @@ export type BuildChange = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getJobs(): Promise<Job[]> {
|
export function getJobs(): Promise<Job[]> {
|
||||||
let jobs: Job[] = []
|
let jobs: Job[] = [];
|
||||||
let request = axios.get(`${JENKINS_URL}/${ARTIFACT_NAME}/api/json?pretty=true`)
|
let request = axios.get(`${JENKINS_URL}/${ARTIFACT_NAME}/api/json?pretty=true`)
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -40,10 +40,8 @@ export function getBuilds(version: string): Promise<Build[]> {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
request.then(value => {
|
request.then(value => {
|
||||||
builds = value.data.builds as Build[]
|
builds = value.data.builds as Build[]
|
||||||
let count = 0;
|
|
||||||
for (let build of builds) {
|
for (let build of builds) {
|
||||||
axios.get(`${JENKINS_URL}/${ARTIFACT_NAME}/job/${version}/${build.number}/api/json?pretty=true`).then(value1 => {
|
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
|
let changeSet: any[] = value1.data.changeSets
|
||||||
if (changeSet.length > 0) {
|
if (changeSet.length > 0) {
|
||||||
let changes = changeSet[0].items as BuildChange[]
|
let changes = changeSet[0].items as BuildChange[]
|
||||||
@ -58,10 +56,7 @@ export function getBuilds(version: string): Promise<Build[]> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
resolve(builds)
|
||||||
if (count === builds.length - 1) {
|
|
||||||
resolve(builds)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user