From b63f043849d44c5bc84f3bf7329c9deeb6be87b1 Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Tue, 7 Apr 2026 18:45:46 +0200 Subject: [PATCH] Move document title ownership from document to version Title is now owned by document_versions, following the same pattern as classification and document_type. The documents.title column is made nullable with a TODO to drop it. Backend loads title from a latest_versions CTE for ordering purposes only. The frontend resolves title from the latest version, and DocumentTitleForm now operates on DocumentVersion using UpdateDocumentVersion mutation. Signed-off-by: Sacha Al Himdani --- .../documents/LinkedDocumentsCard.tsx | 4 +- .../documents/LinkedDocumentsDialog.tsx | 6 +- .../CompliancePageAccessEditDialog.tsx | 4 +- .../documents/DocumentLayout.tsx | 10 +- .../_components/DocumentActionsDropdown.tsx | 11 +- .../_components/DocumentListItem.tsx | 6 +- .../_components/DocumentTitleForm.tsx | 55 ++-- e2e/console/document_test.go | 164 ++++++------ e2e/console/employee_document_test.go | 2 - e2e/console/risk_test.go | 4 +- e2e/internal/factory/factory.go | 96 +++---- pkg/coredata/document.go | 236 +++++++++--------- pkg/coredata/migrations/20260407T120000Z.sql | 16 ++ pkg/probo/document_service.go | 26 +- pkg/server/api/console/v1/schema.graphql | 4 +- pkg/server/api/console/v1/types/document.go | 3 +- pkg/server/api/console/v1/v1_resolver.go | 2 +- pkg/server/api/mcp/v1/schema.resolvers.go | 2 +- pkg/server/api/mcp/v1/specification.yaml | 10 +- pkg/server/api/mcp/v1/types/document.go | 1 - 20 files changed, 329 insertions(+), 333 deletions(-) create mode 100644 pkg/coredata/migrations/20260407T120000Z.sql diff --git a/apps/console/src/components/documents/LinkedDocumentsCard.tsx b/apps/console/src/components/documents/LinkedDocumentsCard.tsx index d70fc67c1..9b5b32368 100644 --- a/apps/console/src/components/documents/LinkedDocumentsCard.tsx +++ b/apps/console/src/components/documents/LinkedDocumentsCard.tsx @@ -43,11 +43,11 @@ import { LinkedDocumentDialog } from "./LinkedDocumentsDialog"; const linkedDocumentFragment = graphql` fragment LinkedDocumentsCardFragment on Document { id - title versions(first: 1) { edges { node { id + title documentType status } @@ -217,7 +217,7 @@ function DocumentRow(props: { height={36} className="border-4 border-highlight rounded box-content" /> - {document.title} + {document.versions.edges[0].node.title} diff --git a/apps/console/src/components/documents/LinkedDocumentsDialog.tsx b/apps/console/src/components/documents/LinkedDocumentsDialog.tsx index ccb18a912..24e0dd42f 100644 --- a/apps/console/src/components/documents/LinkedDocumentsDialog.tsx +++ b/apps/console/src/components/documents/LinkedDocumentsDialog.tsx @@ -71,10 +71,10 @@ const documentsFragment = graphql` edges { node { id - title versions(first: 1, orderBy: { field: CREATED_AT, direction: DESC }) { edges { node { + title documentType } } @@ -135,7 +135,7 @@ function LinkedDocumentsDialogContent(props: Omit) { const filteredDocuments = useMemo(() => { return documents.filter(document => - document.title.toLowerCase().includes(search.toLowerCase()), + document.versions.edges[0].node.title.toLowerCase().includes(search.toLowerCase()), ); }, [documents, search]); @@ -192,7 +192,7 @@ function DocumentRow(props: RowProps) { className="py-4 flex items-center gap-4 hover:bg-subtle cursor-pointer px-6 w-full h-[100px]" onClick={() => onClick(props.document.id)} > - {props.document.title} + {props.document.versions.edges[0].node.title}