diff --git a/Website/app/Releases.js b/Website/app/Releases.js index 870141584..0699480a4 100644 --- a/Website/app/Releases.js +++ b/Website/app/Releases.js @@ -1,195 +1,370 @@ "use client"; -import {useEffect, useMemo, useState} from "react" -import { remark } from 'remark'; -import html from 'remark-html'; +import { useEffect, useMemo, useState } from "react"; +import { remark } from "remark"; +import html from "remark-html"; function downloadLatestRelease(OSName, applicationType) { - if (applicationType === "CLI") { - if (OSName === "Windows") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-CLI.exe"); - } else if (OSName === "Linux") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-CLI_linux"); - } else { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-CLI_macos"); - } + if (applicationType === "CLI") { + if (OSName === "Windows") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-CLI.exe" + ); + } else if (OSName === "Linux") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-CLI_linux" + ); } else { - if (OSName === "Windows exe") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI.exe"); - } else if (OSName === "Windows msi") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI.msi"); - } else if (OSName === "Linux") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI_linux"); - } else { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI.pkg"); - } + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-CLI_macos" + ); } + } else { + if (OSName === "Windows exe") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI.exe" + ); + } else if (OSName === "Windows msi") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI.msi" + ); + } else if (OSName === "Linux") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI_linux" + ); + } else { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty-GUI.pkg" + ); + } + } } function downloadOlderReleases(OSName, applicationType, version) { - if (applicationType === "CLI") { - if (OSName === "Windows") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-CLI.exe"); - } else if (OSName === "Linux") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-CLI_linux"); - } else { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-CLI_macos"); - } + if (applicationType === "CLI") { + if (OSName === "Windows") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-CLI.exe" + ); + } else if (OSName === "Linux") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-CLI_linux" + ); } else { - if (OSName === "Windows exe") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-GUI.exe"); - } else if (OSName === "Windows msi") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-GUI.msi"); - } else if (OSName === "Linux") { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-GUI_linux"); - } else { - window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + version + "/Drifty-GUI.pkg"); - } + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-CLI_macos" + ); + } + } else { + if (OSName === "Windows exe") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-GUI.exe" + ); + } else if (OSName === "Windows msi") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-GUI.msi" + ); + } else if (OSName === "Linux") { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-GUI_linux" + ); + } else { + window.open( + "https://github.com/SaptarshiSarkar12/Drifty/releases/download/" + + version + + "/Drifty-GUI.pkg" + ); } + } } -export default function Releases({props}) { - const [buttonStates, setButtonStates] = useState({}); - const [content,setContent]=useState([]); - const [applicationType, setApplicationType] = useState("GUI"); - const maxReleasesToDisplay = 3; - const filteredReleases = useMemo(() => { - const releases = []; - props.release.map((item, index) => { - if (index !== 0) { - if (item.tag_name.startsWith("v2") && releases.length <= maxReleasesToDisplay) { - releases.push(item); - } - } - }); - return releases; - }, [props.release]); - const filterOlderReleases = useMemo(() => { - const releases = []; - let noOfReleases = filteredReleases.length; - props.release.map((item, index) => { - if (releases.length <= maxReleasesToDisplay && noOfReleases < maxReleasesToDisplay && index !== 0) { - if (!item.tag_name.startsWith("v2")) { - releases.push(item); - noOfReleases++; - } - } - }); - return releases; - }, [filteredReleases.length, props.release]); +export default function Releases({ props }) { + const [buttonStates, setButtonStates] = useState({}); + const [content, setContent] = useState([]); + const [applicationType, setApplicationType] = useState("GUI"); + const maxReleasesToDisplay = 3; + const filteredReleases = useMemo(() => { + const releases = []; + props.release.map((item, index) => { + if (index !== 0) { + if ( + item.tag_name.startsWith("v2") && + releases.length <= maxReleasesToDisplay + ) { + releases.push(item); + } + } + }); + return releases; + }, [props.release]); + const filterOlderReleases = useMemo(() => { + const releases = []; + let noOfReleases = filteredReleases.length; + props.release.map((item, index) => { + if ( + releases.length <= maxReleasesToDisplay && + noOfReleases < maxReleasesToDisplay && + index !== 0 + ) { + if (!item.tag_name.startsWith("v2")) { + releases.push(item); + noOfReleases++; + } + } + }); + return releases; + }, [filteredReleases.length, props.release]); - const handleButtonClick = (index) => { - setButtonStates((prevState) => ({ - ...prevState, - [index]: !prevState[index], - })); - }; - const markerToHtml = async (itemBody, i) => { - const cont = await remark().use(html).process(itemBody); - setContent((prev)=> {prev[i]=cont.toString(); return prev}); - } - useEffect(() => { - filteredReleases.forEach(async (item, index) => { - await markerToHtml(item.body, index); - }); - filterOlderReleases.forEach(async (item, index) => { - await markerToHtml(item.body, index + filteredReleases.length); - }); - }, [filteredReleases, filterOlderReleases]); + const handleButtonClick = (index) => { + setButtonStates((prevState) => ({ + ...prevState, + [index]: !prevState[index], + })); + }; + const markerToHtml = async (itemBody, i) => { + const cont = await remark().use(html).process(itemBody); + setContent((prev) => { + prev[i] = cont.toString(); + return prev; + }); + }; + useEffect(() => { + filteredReleases.forEach(async (item, index) => { + await markerToHtml(item.body, index); + }); + filterOlderReleases.forEach(async (item, index) => { + await markerToHtml(item.body, index + filteredReleases.length); + }); + }, [filteredReleases, filterOlderReleases]); - const handleApplicationTypeChange = (applicationType) => { - setApplicationType(applicationType.target.value); - } - - return ( -
-

Download Drifty

-
-

Select Application Type

-
- + const handleApplicationTypeChange = (applicationType) => { + setApplicationType(applicationType.target.value); + }; + + return ( +
+

+ Download Drifty +

+ + {/* Application Type Selection */} +
+

+ Select Application Type +

+
+ +
+
+ + {/* Download Buttons */} +
+ + {/* First Download Now Button */} +
+
+
+ + {applicationType === "GUI" && ( +
+ Prefer the msi?
+ )}
-
+
+
+ + {/* Second Download Now Button */} +
+ +
+ + {/* Third Download Now Button */} +
+ +
+
+ + +
+

+ Past Releases +

+ {filteredReleases.map((item, index) => { + return ( +
+ {item.tag_name} +

+ {new Date(item.published_at).toString()} with{" "} + {item.assets[0].download_count + + item.assets[1].download_count + + item.assets[2].download_count + + item.assets[3].download_count + + item.assets[4].download_count + + item.assets[5].download_count}{" "} + Downloads +

+ + {buttonStates[index] && ( +
+ )} + +
+ + {applicationType === "GUI" && ( - {applicationType === "GUI" && } + className={ + "text-sm text-violet-900 font-semibold hover:underline hover:transition ease-in-out duration-300 delay-100 hover:-translate-y-0.5 hover:scale-110" + } + onClick={() => + downloadOlderReleases( + "Windows msi", + applicationType, + item.tag_name + ) + } + > + Prefer the msi? + + )}
+ className="select-none pl-3 pr-3 w-auto h-min text-2xl bg-gradient-to-r from-blue-600 to-green-500 hover:from-pink-500 hover:to-yellow-500 rounded-full p-1 shadow-none hover:transition ease-in-out duration-300 delay-100 hover:-translate-y-1 hover:scale-110 hover:drop-shadow-2xl" + onClick={() => + downloadOlderReleases( + "Linux", + applicationType, + item.tag_name + ) + } + > + Download + + className="select-none pl-3 pr-3 w-auto h-min text-2xl bg-gradient-to-r from-blue-600 to-green-500 hover:from-pink-500 hover:to-yellow-500 rounded-full p-1 shadow-none hover:transition ease-in-out duration-300 delay-100 hover:-translate-y-1 hover:scale-110 hover:drop-shadow-2xl" + onClick={() => + downloadOlderReleases( + "MacOS", + applicationType, + item.tag_name + ) + } + > + Download + +
-
-

Past Releases

- {filteredReleases.map((item, index) => { - return ( -
- {item.tag_name} -

{new Date(item.published_at).toString()} with {item.assets[0].download_count + item.assets[1].download_count + item.assets[2].download_count + item.assets[3].download_count + item.assets[4].download_count + item.assets[5].download_count} Downloads

- - {buttonStates[index] &&
} -
-
- - {applicationType === "GUI" && } -
- - -
-
- )} + ); + })} + {filterOlderReleases.map((item, index) => { + index = index + filteredReleases.length; + if (filterOlderReleases.length !== 0) { + return ( +
+ {item.tag_name} +

+ {new Date(item.published_at).toString()} with{" "} + {item.assets[0].download_count + + item.assets[1].download_count}{" "} + Downloads +

+ + {buttonStates[index] && ( +
)} - {filterOlderReleases.map((item, index) => { - index = index + filteredReleases.length; - if (filterOlderReleases.length !== 0) { - return ( -
- {item.tag_name} -

{new Date(item.published_at).toString()} with {item.assets[0].download_count + item.assets[1].download_count} Downloads

- - {buttonStates[index] &&
} -
- - -
-
- ) - } +
+
-
-

Looking for more releases?

- View all releases -
-
- ) + > + Download + + +
+
+ ); + } + })} +
+
+

+ Looking for more releases? +

+ + View all releases + +
+
+ ); }