-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
select worker version before downloading
- Loading branch information
1 parent
b60d88d
commit 04b3d37
Showing
7 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
|
||
|
||
export default function ButtonDownloadVersionedImage({type}){ | ||
const [selectedVersion, setSelectedVersion] = React.useState(""); | ||
const [versions, setVersions] = React.useState([]); | ||
|
||
React.useEffect(() => { | ||
const fetchReleases = async () => { | ||
try { | ||
const response = await fetch("https://api.github.com/repos/pioreactor/custopizer/releases"); | ||
if (!response.ok) { | ||
throw new Error("Failed to fetch releases"); | ||
} | ||
|
||
const data = await response.json(); | ||
// Filter out prereleases and drafts | ||
const filteredVersions = data | ||
.filter(release => !release.prerelease && !release.draft) | ||
.map(release => ({ version: release.tag_name })); | ||
|
||
setVersions(filteredVersions); | ||
} catch (error) { | ||
console.error("Error fetching releases:", error); | ||
} | ||
}; | ||
|
||
fetchReleases(); | ||
}, []); | ||
|
||
const handleDownload = () => { | ||
if (selectedVersion) { | ||
const downloadUrl = `https://github.com/Pioreactor/CustoPiZer/releases/download/${selectedVersion}/pioreactor_${type}.zip`; | ||
window.open(downloadUrl, '_blank'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<span> Select software version: </span> | ||
<select name="version" onChange={e => setSelectedVersion(e.target.value)} style={{ width: "100px" }}> | ||
<option value="">version</option> | ||
{versions.map((blob, index) => ( | ||
<option key={index} value={blob.version}>{blob.version}</option> | ||
))} | ||
</select> | ||
<button onClick={handleDownload} disabled={selectedVersion === ''} style={{"marginLeft": "10px"}}> | ||
Download {type} image | ||
</button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters