Skip to content

Commit

Permalink
Add recent release option to the website
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedBasem20 committed Aug 16, 2023
1 parent d19a075 commit 7f6c977
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion aiida-registry-app/src/Components/MainIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function MainIndex() {
setSortOption(option);


let sortedPlugins;
let sortedPlugins = {};
if (option === 'commits') {
const pluginsArray = Object.entries(plugins);

Expand All @@ -53,6 +53,26 @@ function MainIndex() {
else if (option == 'alpha') {
sortedPlugins = plugins;
}
else if (option == 'release') {
//Sort plugins by the recent release date
const pluginsArray = Object.entries(plugins);
pluginsArray.sort(([, pluginA], [, pluginB]) => {
if (!pluginA.metadata.release_date && !pluginB.metadata.release_date) {
return 0; // Both plugins have no release date, keep them in the current order
} else if (!pluginA.metadata.release_date) {
return 1;
// Only pluginB has a release date, so pluginA should come first
} else if (!pluginB.metadata.release_date) {
return -1;
// Only pluginA has a release date, so pluginB should come first
} else {
return new Date(pluginB.metadata.release_date) - new Date(pluginA.metadata.release_date);
}
});

// Convert the sorted array back to an object
sortedPlugins = Object.fromEntries(pluginsArray);
}

setSortedData(sortedPlugins);
};
Expand Down Expand Up @@ -91,6 +111,7 @@ function MainIndex() {
>
<MenuItem value= 'alpha'>Alphabetical</MenuItem>
<MenuItem value='commits'>Commits Count</MenuItem>
<MenuItem value='release'>Recent Release</MenuItem>
</Select>
</FormControl>
</Box>
Expand Down Expand Up @@ -120,6 +141,14 @@ function MainIndex() {
src={`https://img.shields.io/badge/Yearly%20Commits-${value.commits_count}-007ec6.svg`}
/>
}

{sortOption === 'release' && value.metadata.release_date &&
<img
className="svg-badge"
style={{padding:'3px'}}
src={`https://img.shields.io/badge/Recent%20Release-${value.metadata.release_date.replace(/-/g, '/')}-007ec6.svg`}
/>
}
</p>

<p>{value.metadata.description}</p>
Expand Down

0 comments on commit 7f6c977

Please sign in to comment.