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

[dashboard] sort projects by activity #6073

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Changes from all commits
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
6 changes: 5 additions & 1 deletion components/dashboard/src/projects/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export default function () {
return true;
}

function hasNewerPrebuild(p0: Project, p1: Project): number {
return moment(lastPrebuilds.get(p1.id)?.info?.startedAt || '1970-01-01').diff(moment(lastPrebuilds.get(p0.id)?.info?.startedAt || '1970-01-01'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a.startedAt.localeCompare(b.startetAt) works as well and doesn't require momentjs

}

const teamOrUserSlug = !!team ? 't/'+team.slug : 'projects';

return <>
Expand Down Expand Up @@ -105,7 +109,7 @@ export default function () {
<button className="ml-2" onClick={() => onNewProject()}>New Project</button>
</div>
<div className="mt-4 grid grid-cols-3 gap-4">
{projects.filter(filter).map(p => (<div key={`project-${p.id}`} className="h-52">
{projects.filter(filter).sort(hasNewerPrebuild).map(p => (<div key={`project-${p.id}`} className="h-52">
<div className="h-42 border border-gray-100 dark:border-gray-800 rounded-t-xl">
<div className="h-32 p-6">
<div className="flex text-xl font-semibold text-gray-700 dark:text-gray-200 font-medium">
Expand Down