feat(dashboard): recent work in plain English
This commit is contained in:
parent
8711c36833
commit
4a278fa56b
2 changed files with 50 additions and 1 deletions
|
|
@ -9,13 +9,14 @@ import { ActivityCalendar } from "@/components/dashboard/activity-calendar";
|
|||
import { BarList } from "@/components/dashboard/bar-list";
|
||||
import { MonthBars } from "@/components/dashboard/month-bars";
|
||||
import { Methodology } from "@/components/dashboard/methodology";
|
||||
import { RecentActivity } from "@/components/dashboard/recent-activity";
|
||||
import { RecomputeButton } from "@/components/dashboard/recompute-button";
|
||||
import { getSession } from "@/lib/auth/session";
|
||||
import { getServerPb } from "@/lib/pb/server";
|
||||
import { loadBoard } from "@/lib/data/board";
|
||||
import { relativeTime } from "@/lib/time/relative";
|
||||
import type { ProjectMetrics } from "@/lib/metrics/compute";
|
||||
import type { ProjectMetricsRecord } from "@/lib/pb/types";
|
||||
import type { CommitRecord, ProjectMetricsRecord } from "@/lib/pb/types";
|
||||
|
||||
export default async function DashboardPage({
|
||||
params,
|
||||
|
|
@ -38,6 +39,16 @@ export default async function DashboardPage({
|
|||
const metrics = cached?.payload as ProjectMetrics | undefined;
|
||||
const boardHref = `/p/${clientSlug}/${projectSlug}`;
|
||||
|
||||
// Most recent non-merge commits, with the AI summary where one exists and the
|
||||
// raw subject otherwise. Mixed list is the point — see the comment on
|
||||
// RecentActivity.
|
||||
const recent = await pb
|
||||
.collection("commits")
|
||||
.getList<CommitRecord>(1, 12, {
|
||||
filter: `project = "${board.project.id}" && is_merge = false`,
|
||||
sort: "-authored_at",
|
||||
});
|
||||
|
||||
return (
|
||||
<AppShell role={session.role} currentPath={boardHref}>
|
||||
<TopBar title={board.project.name} subtitle={board.client.name}>
|
||||
|
|
@ -94,6 +105,8 @@ export default async function DashboardPage({
|
|||
|
||||
<MonthBars monthly={metrics.monthly} />
|
||||
|
||||
<RecentActivity commits={recent.items} />
|
||||
|
||||
<div className="grid gap-8 sm:grid-cols-2">
|
||||
<BarList title="Commits by type" items={metrics.byType} />
|
||||
<BarList
|
||||
|
|
|
|||
36
src/components/dashboard/recent-activity.tsx
Normal file
36
src/components/dashboard/recent-activity.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { relativeTime } from "@/lib/time/relative";
|
||||
import type { CommitRecord } from "@/lib/pb/types";
|
||||
|
||||
/**
|
||||
* The most recent work, in plain English.
|
||||
*
|
||||
* Falls back to the raw subject per entry, so a partially summarised project
|
||||
* shows a mixed list rather than a half-empty one.
|
||||
*/
|
||||
export function RecentActivity({ commits }: { commits: CommitRecord[] }) {
|
||||
if (commits.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xs font-semibold uppercase tracking-wide text-text-secondary">
|
||||
Recent work
|
||||
</h2>
|
||||
|
||||
<ol className="space-y-2">
|
||||
{commits.map((commit) => (
|
||||
<li
|
||||
key={commit.id}
|
||||
className="flex items-baseline gap-3 border-b border-border-subtle pb-2 last:border-0"
|
||||
>
|
||||
<p className="min-w-0 flex-1 text-sm text-text-secondary">
|
||||
{commit.summary || commit.subject}
|
||||
</p>
|
||||
<span className="shrink-0 text-[11px] text-text-muted">
|
||||
{relativeTime(commit.authored_at)}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue