Bundles in-flight ECHODO work with the Coolify deployment configuration: App - New routes: ai, forms, planner, settings (templates/types), teams, doc detail, whiteboard detail - New components: app shell rework (icon-rail, top-header), forms builder/renderer/responses, types manager, objects creation dialog, card primitive, form + overview views - New tRPC routers: favorites, forms, types, workspaces; updates to health and objects routers - Markdown backlog sync (packages/database) + cursor-sync schema/migrations - Schema additions: forms, types, favorites, markdown_backlog, cursor_sync - Initial Drizzle migrations checked in Deployment - docker/docker-compose.coolify.yml: drops bundled Postgres/Redis (uses CT 102 shared services), removes host port mappings, adds Coolify SERVICE_FQDN_* magic vars for web + collab - .env.example rewritten as the full ECHODO/Coolify variable manifest - NextAuth gains an Authentik OIDC provider (gated on env presence) - Root layout injects Umami tracking script when configured; metadata title flipped to ECHODO Security - .gitignore expanded to exclude AGENT-DEPLOY.md, .env.*, secrets/, credentials.*, *.key, *.crt, *.pem, ssh keys Made-with: Cursor
101 lines
3.3 KiB
TypeScript
101 lines
3.3 KiB
TypeScript
"use client";
|
|
|
|
import { useMemo } from "react";
|
|
import Link from "next/link";
|
|
import { useParams, useRouter } from "next/navigation";
|
|
import { FileText, Plus } from "lucide-react";
|
|
|
|
import { api } from "@/lib/trpc";
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
function formatUpdatedAt(value: Date | string): string {
|
|
const date = value instanceof Date ? value : new Date(value);
|
|
if (Number.isNaN(date.getTime())) return String(value);
|
|
return date.toLocaleString();
|
|
}
|
|
|
|
export default function DocsPage() {
|
|
const params = useParams();
|
|
const router = useRouter();
|
|
const utils = api.useUtils();
|
|
|
|
const workspaceId =
|
|
typeof params?.workspaceSlug === "string" ? params.workspaceSlug : undefined;
|
|
|
|
const listQuery = api.objects.list.useQuery(
|
|
{ workspaceId: workspaceId!, parentId: undefined, limit: 200 },
|
|
{ enabled: Boolean(workspaceId) },
|
|
);
|
|
|
|
const createMutation = api.objects.create.useMutation({
|
|
onSuccess: (created) => {
|
|
if (workspaceId) {
|
|
void utils.objects.list.invalidate({ workspaceId });
|
|
router.push(`/${workspaceId}/docs/${created.id}`);
|
|
}
|
|
},
|
|
});
|
|
|
|
const documents = useMemo(() => {
|
|
const rows = listQuery.data?.objects ?? [];
|
|
return rows
|
|
.filter((o) => o.type === "document")
|
|
.slice()
|
|
.sort((a, b) => {
|
|
const ta = new Date(a.updatedAt).getTime();
|
|
const tb = new Date(b.updatedAt).getTime();
|
|
return tb - ta;
|
|
});
|
|
}, [listQuery.data?.objects]);
|
|
|
|
return (
|
|
<div className="mx-auto max-w-4xl px-8 py-10">
|
|
<div className="mb-8 flex flex-wrap items-center justify-between gap-4">
|
|
<h1 className="text-3xl font-bold tracking-tight">Documents</h1>
|
|
<Button
|
|
type="button"
|
|
disabled={!workspaceId || createMutation.isPending}
|
|
onClick={() => {
|
|
if (!workspaceId) return;
|
|
createMutation.mutate({
|
|
type: "document",
|
|
title: "Untitled",
|
|
workspaceId,
|
|
parentId: null,
|
|
});
|
|
}}
|
|
>
|
|
<Plus className="mr-2 size-4" />
|
|
New Document
|
|
</Button>
|
|
</div>
|
|
|
|
{listQuery.isLoading ? (
|
|
<p className="text-sm text-muted-foreground">Loading documents…</p>
|
|
) : documents.length === 0 ? (
|
|
<div className="rounded-lg border border-dashed border-border bg-muted/30 p-12 text-center text-sm text-muted-foreground">
|
|
No documents yet. Create one to get started.
|
|
</div>
|
|
) : (
|
|
<ul className="divide-y divide-border rounded-lg border border-border bg-card shadow-sm">
|
|
{documents.map((doc) => (
|
|
<li key={doc.id}>
|
|
<Link
|
|
href={`/${workspaceId}/docs/${doc.id}`}
|
|
className="flex items-center justify-between gap-4 px-4 py-4 transition-colors hover:bg-muted/40"
|
|
>
|
|
<span className="flex min-w-0 items-center gap-3">
|
|
<FileText className="size-5 shrink-0 text-muted-foreground" />
|
|
<span className="truncate font-medium">{doc.title}</span>
|
|
</span>
|
|
<span className="shrink-0 text-xs text-muted-foreground tabular-nums">
|
|
{formatUpdatedAt(doc.updatedAt)}
|
|
</span>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|