Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added latest version as default project card version #593

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/pages/BesVersionHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,18 @@ function BesVersionHistory() {
const [selectedOption, setSelectedOption] = React.useState("");

try {
if (!selectedOption && versionSummary[0].version) {
setSelectedOption(versionSummary[0].version);
if (!selectedOption && versionSummary){
const latestVersion = versionSummary.reduce((latest, current) => {
const currentDate = new Date(current.release_date);
const latestDate = new Date(latest.release_date);
return currentDate > latestDate ? current : latest;
}, versionSummary[0]);
if (latestVersion.version){
setSelectedOption(latestVersion.version);
}
}
} catch (e: any) {
//ignore
console.log(e);
}

const handleOptionChange = (event: any) => {
Expand Down Expand Up @@ -311,8 +318,6 @@ function BesVersionHistory() {
.join("");
const envpath: string = `https://github.com/Be-Secure/besecure-ce-env-repo/tree/master/${camelCaseString}/`;
const languages = Object.keys(item.language) // To get the list of languages
// console.log(item.owner)
// debugger
return (
<>
<Card key={`TOPCARD${index}`} style={{ marginTop: "-1.5rem", paddingTop: "6px" }}>
Expand Down Expand Up @@ -362,7 +367,7 @@ function BesVersionHistory() {
fontSize: "15px",
height: "fit-content"
}}
>
>
{versionSummary.map((option: any, index1: any) => (
<MenuItem
key={`TOPMENUITEM${index}${index1}`}
Expand Down
Loading