From 165b2e7a671d16e02734fc4bd39625068563361c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 27 Jan 2026 16:11:10 +0400 Subject: [PATCH] Fix signatures count on documents page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- .../CreateDocumentDialogMutation.graphql.ts | 96 ++++++++------ .../core/DocumentListItemFragment.graphql.ts | 119 ++++++++++-------- .../core/DocumentsListQuery.graphql.ts | 94 ++++++++------ .../core/DocumentsPageQuery.graphql.ts | 96 ++++++++------ .../PublishDocumentsDialogMutation.graphql.ts | 96 ++++++++------ .../documents/_components/DocumentList.tsx | 2 +- .../_components/DocumentListItem.tsx | 43 +++---- 7 files changed, 305 insertions(+), 241 deletions(-) diff --git a/apps/console/src/__generated__/core/CreateDocumentDialogMutation.graphql.ts b/apps/console/src/__generated__/core/CreateDocumentDialogMutation.graphql.ts index af43bd4c0..7ac93f209 100644 --- a/apps/console/src/__generated__/core/CreateDocumentDialogMutation.graphql.ts +++ b/apps/console/src/__generated__/core/CreateDocumentDialogMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<766e48d090179d20cc6a7b1d6bc6591f>> + * @generated SignedSource<<40817b8ba263ba9d0140a57e41e6ca44>> * @lightSyntaxTransform * @nogrep */ @@ -65,7 +65,21 @@ v3 = { "kind": "ScalarField", "name": "id", "storageKey": null -}; +}, +v4 = { + "kind": "Literal", + "name": "first", + "value": 0 +}, +v5 = [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "totalCount", + "storageKey": null + } +]; return { "fragment": { "argumentDefinitions": [ @@ -214,12 +228,20 @@ return { "storageKey": null }, { - "alias": null, + "alias": "lastVersion", "args": [ { "kind": "Literal", "name": "first", "value": 1 + }, + { + "kind": "Literal", + "name": "orderBy", + "value": { + "direction": "DESC", + "field": "CREATED_AT" + } } ], "concreteType": "DocumentVersionConnection", @@ -263,47 +285,41 @@ return { "args": [ { "kind": "Literal", - "name": "first", - "value": 1000 - } + "name": "filter", + "value": { + "activeContract": true + } + }, + (v4/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": [ + "selections": (v5/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true},first:0)" + }, + { + "alias": "signedSignatures", + "args": [ { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignatureEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignature", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v3/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "state", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } + "kind": "Literal", + "name": "filter", + "value": { + "activeContract": true, + "states": [ + "SIGNED" + ] + } + }, + (v4/*: any*/) ], - "storageKey": "signatures(first:1000)" + "concreteType": "DocumentVersionSignatureConnection", + "kind": "LinkedField", + "name": "signatures", + "plural": false, + "selections": (v5/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true,\"states\":[\"SIGNED\"]},first:0)" } ], "storageKey": null @@ -312,7 +328,7 @@ return { "storageKey": null } ], - "storageKey": "versions(first:1)" + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" } ], "storageKey": null @@ -342,12 +358,12 @@ return { ] }, "params": { - "cacheID": "20ca0b6c942e66b92ced0b4869262530", + "cacheID": "089c02e59ef9b51883dd556df68891b9", "id": null, "metadata": {}, "name": "CreateDocumentDialogMutation", "operationKind": "mutation", - "text": "mutation CreateDocumentDialogMutation(\n $input: CreateDocumentInput!\n) {\n createDocument(input: $input) {\n documentEdge {\n node {\n id\n ...DocumentListItemFragment\n }\n }\n }\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n versions(first: 1) {\n edges {\n node {\n id\n status\n version\n signatures(first: 1000) {\n edges {\n node {\n id\n state\n }\n }\n }\n }\n }\n }\n}\n" + "text": "mutation CreateDocumentDialogMutation(\n $input: CreateDocumentInput!\n) {\n createDocument(input: $input) {\n documentEdge {\n node {\n id\n ...DocumentListItemFragment\n }\n }\n }\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n status\n version\n signatures(first: 0, filter: {activeContract: true}) {\n totalCount\n }\n signedSignatures: signatures(first: 0, filter: {states: [SIGNED], activeContract: true}) {\n totalCount\n }\n }\n }\n }\n}\n" } }; })(); diff --git a/apps/console/src/__generated__/core/DocumentListItemFragment.graphql.ts b/apps/console/src/__generated__/core/DocumentListItemFragment.graphql.ts index 19b3c560d..83fd0c266 100644 --- a/apps/console/src/__generated__/core/DocumentListItemFragment.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentListItemFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<664a9b09aac444c69891219cca1c6b8d>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -12,36 +12,33 @@ import { ReaderFragment } from 'relay-runtime'; export type DocumentClassification = "CONFIDENTIAL" | "INTERNAL" | "PUBLIC" | "SECRET"; export type DocumentStatus = "DRAFT" | "PUBLISHED"; export type DocumentType = "ISMS" | "OTHER" | "POLICY" | "PROCEDURE"; -export type DocumentVersionSignatureState = "REQUESTED" | "SIGNED"; import { FragmentRefs } from "relay-runtime"; export type DocumentListItemFragment$data = { readonly canDelete: boolean; readonly classification: DocumentClassification; readonly documentType: DocumentType; readonly id: string; - readonly owner: { - readonly fullName: string; - readonly id: string; - }; - readonly title: string; - readonly updatedAt: string; - readonly versions: { + readonly lastVersion: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string; readonly signatures: { - readonly edges: ReadonlyArray<{ - readonly node: { - readonly id: string; - readonly state: DocumentVersionSignatureState; - }; - }>; + readonly totalCount: number; + }; + readonly signedSignatures: { + readonly totalCount: number; }; readonly status: DocumentStatus; readonly version: number; }; }>; }; + readonly owner: { + readonly fullName: string; + readonly id: string; + }; + readonly title: string; + readonly updatedAt: string; readonly " $fragmentType": "DocumentListItemFragment"; }; export type DocumentListItemFragment$key = { @@ -56,7 +53,21 @@ var v0 = { "kind": "ScalarField", "name": "id", "storageKey": null -}; +}, +v1 = { + "kind": "Literal", + "name": "first", + "value": 0 +}, +v2 = [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "totalCount", + "storageKey": null + } +]; return { "argumentDefinitions": [], "kind": "Fragment", @@ -125,12 +136,20 @@ return { "storageKey": null }, { - "alias": null, + "alias": "lastVersion", "args": [ { "kind": "Literal", "name": "first", "value": 1 + }, + { + "kind": "Literal", + "name": "orderBy", + "value": { + "direction": "DESC", + "field": "CREATED_AT" + } } ], "concreteType": "DocumentVersionConnection", @@ -174,47 +193,41 @@ return { "args": [ { "kind": "Literal", - "name": "first", - "value": 1000 - } + "name": "filter", + "value": { + "activeContract": true + } + }, + (v1/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": [ + "selections": (v2/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true},first:0)" + }, + { + "alias": "signedSignatures", + "args": [ { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignatureEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignature", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v0/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "state", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } + "kind": "Literal", + "name": "filter", + "value": { + "activeContract": true, + "states": [ + "SIGNED" + ] + } + }, + (v1/*: any*/) ], - "storageKey": "signatures(first:1000)" + "concreteType": "DocumentVersionSignatureConnection", + "kind": "LinkedField", + "name": "signatures", + "plural": false, + "selections": (v2/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true,\"states\":[\"SIGNED\"]},first:0)" } ], "storageKey": null @@ -223,7 +236,7 @@ return { "storageKey": null } ], - "storageKey": "versions(first:1)" + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" } ], "type": "Document", @@ -231,6 +244,6 @@ return { }; })(); -(node as any).hash = "6c4db808e4ec47dbca635feb3ea13e56"; +(node as any).hash = "6e72b37fa90b7a272ebba38fe80b9f93"; export default node; diff --git a/apps/console/src/__generated__/core/DocumentsListQuery.graphql.ts b/apps/console/src/__generated__/core/DocumentsListQuery.graphql.ts index 77150f9b4..ebf472e95 100644 --- a/apps/console/src/__generated__/core/DocumentsListQuery.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentsListQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<582e2fb7616b46350bf9dbce26c62811>> * @lightSyntaxTransform * @nogrep */ @@ -119,6 +119,20 @@ v13 = [ "name": "orderBy", "variableName": "order" } +], +v14 = { + "kind": "Literal", + "name": "first", + "value": 0 +}, +v15 = [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "totalCount", + "storageKey": null + } ]; return { "fragment": { @@ -302,12 +316,20 @@ return { "storageKey": null }, { - "alias": null, + "alias": "lastVersion", "args": [ { "kind": "Literal", "name": "first", "value": 1 + }, + { + "kind": "Literal", + "name": "orderBy", + "value": { + "direction": "DESC", + "field": "CREATED_AT" + } } ], "concreteType": "DocumentVersionConnection", @@ -351,47 +373,41 @@ return { "args": [ { "kind": "Literal", - "name": "first", - "value": 1000 - } + "name": "filter", + "value": { + "activeContract": true + } + }, + (v14/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": [ + "selections": (v15/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true},first:0)" + }, + { + "alias": "signedSignatures", + "args": [ { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignatureEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignature", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v12/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "state", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } + "kind": "Literal", + "name": "filter", + "value": { + "activeContract": true, + "states": [ + "SIGNED" + ] + } + }, + (v14/*: any*/) ], - "storageKey": "signatures(first:1000)" + "concreteType": "DocumentVersionSignatureConnection", + "kind": "LinkedField", + "name": "signatures", + "plural": false, + "selections": (v15/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true,\"states\":[\"SIGNED\"]},first:0)" } ], "storageKey": null @@ -400,7 +416,7 @@ return { "storageKey": null } ], - "storageKey": "versions(first:1)" + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" }, (v11/*: any*/) ], @@ -491,12 +507,12 @@ return { ] }, "params": { - "cacheID": "c404cb30a5176c7d01cace940923f480", + "cacheID": "d79ffc90943fa44e309a27784a8c65b8", "id": null, "metadata": {}, "name": "DocumentsListQuery", "operationKind": "query", - "text": "query DocumentsListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 50\n $last: Int = null\n $order: DocumentOrder = {field: TITLE, direction: ASC}\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...DocumentListFragment_16fISc\n id\n }\n}\n\nfragment DocumentListFragment_16fISc on Organization {\n documents(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\n edges {\n node {\n id\n canUpdate: permission(action: \"core:document:update\")\n canDelete: permission(action: \"core:document:delete\")\n canRequestSignatures: permission(action: \"core:document-version:request-signature\")\n ...DocumentListItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n versions(first: 1) {\n edges {\n node {\n id\n status\n version\n signatures(first: 1000) {\n edges {\n node {\n id\n state\n }\n }\n }\n }\n }\n }\n}\n" + "text": "query DocumentsListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 50\n $last: Int = null\n $order: DocumentOrder = {field: TITLE, direction: ASC}\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...DocumentListFragment_16fISc\n id\n }\n}\n\nfragment DocumentListFragment_16fISc on Organization {\n documents(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\n edges {\n node {\n id\n canUpdate: permission(action: \"core:document:update\")\n canDelete: permission(action: \"core:document:delete\")\n canRequestSignatures: permission(action: \"core:document-version:request-signature\")\n ...DocumentListItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n status\n version\n signatures(first: 0, filter: {activeContract: true}) {\n totalCount\n }\n signedSignatures: signatures(first: 0, filter: {states: [SIGNED], activeContract: true}) {\n totalCount\n }\n }\n }\n }\n}\n" } }; })(); diff --git a/apps/console/src/__generated__/core/DocumentsPageQuery.graphql.ts b/apps/console/src/__generated__/core/DocumentsPageQuery.graphql.ts index 3b7523c03..9c0ae5caa 100644 --- a/apps/console/src/__generated__/core/DocumentsPageQuery.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentsPageQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -107,7 +107,21 @@ v8 = { "kind": "ScalarField", "name": "id", "storageKey": null -}; +}, +v9 = { + "kind": "Literal", + "name": "first", + "value": 0 +}, +v10 = [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "totalCount", + "storageKey": null + } +]; return { "fragment": { "argumentDefinitions": (v0/*: any*/), @@ -317,12 +331,20 @@ return { "storageKey": null }, { - "alias": null, + "alias": "lastVersion", "args": [ { "kind": "Literal", "name": "first", "value": 1 + }, + { + "kind": "Literal", + "name": "orderBy", + "value": { + "direction": "DESC", + "field": "CREATED_AT" + } } ], "concreteType": "DocumentVersionConnection", @@ -366,47 +388,41 @@ return { "args": [ { "kind": "Literal", - "name": "first", - "value": 1000 - } + "name": "filter", + "value": { + "activeContract": true + } + }, + (v9/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": [ + "selections": (v10/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true},first:0)" + }, + { + "alias": "signedSignatures", + "args": [ { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignatureEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignature", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v8/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "state", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } + "kind": "Literal", + "name": "filter", + "value": { + "activeContract": true, + "states": [ + "SIGNED" + ] + } + }, + (v9/*: any*/) ], - "storageKey": "signatures(first:1000)" + "concreteType": "DocumentVersionSignatureConnection", + "kind": "LinkedField", + "name": "signatures", + "plural": false, + "selections": (v10/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true,\"states\":[\"SIGNED\"]},first:0)" } ], "storageKey": null @@ -415,7 +431,7 @@ return { "storageKey": null } ], - "storageKey": "versions(first:1)" + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" }, (v2/*: any*/), (v7/*: any*/) @@ -507,12 +523,12 @@ return { ] }, "params": { - "cacheID": "2ff9e1818d86d64d512a54ec9acebb16", + "cacheID": "be5d2e7f4a87fba4bf56e605bd849d7d", "id": null, "metadata": {}, "name": "DocumentsPageQuery", "operationKind": "query", - "text": "query DocumentsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n canCreateDocument: permission(action: \"core:document:create\")\n ...DocumentListFragment_1WMmEg\n documents(first: 50, orderBy: {field: TITLE, direction: ASC}) {\n edges {\n node {\n canSendSigningNotifications: permission(action: \"core:document:send-signing-notifications\")\n id\n }\n }\n }\n }\n id\n }\n}\n\nfragment DocumentListFragment_1WMmEg on Organization {\n documents(first: 50, orderBy: {field: TITLE, direction: ASC}) {\n edges {\n node {\n id\n canUpdate: permission(action: \"core:document:update\")\n canDelete: permission(action: \"core:document:delete\")\n canRequestSignatures: permission(action: \"core:document-version:request-signature\")\n ...DocumentListItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n versions(first: 1) {\n edges {\n node {\n id\n status\n version\n signatures(first: 1000) {\n edges {\n node {\n id\n state\n }\n }\n }\n }\n }\n }\n}\n" + "text": "query DocumentsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n canCreateDocument: permission(action: \"core:document:create\")\n ...DocumentListFragment_1WMmEg\n documents(first: 50, orderBy: {field: TITLE, direction: ASC}) {\n edges {\n node {\n canSendSigningNotifications: permission(action: \"core:document:send-signing-notifications\")\n id\n }\n }\n }\n }\n id\n }\n}\n\nfragment DocumentListFragment_1WMmEg on Organization {\n documents(first: 50, orderBy: {field: TITLE, direction: ASC}) {\n edges {\n node {\n id\n canUpdate: permission(action: \"core:document:update\")\n canDelete: permission(action: \"core:document:delete\")\n canRequestSignatures: permission(action: \"core:document-version:request-signature\")\n ...DocumentListItemFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n status\n version\n signatures(first: 0, filter: {activeContract: true}) {\n totalCount\n }\n signedSignatures: signatures(first: 0, filter: {states: [SIGNED], activeContract: true}) {\n totalCount\n }\n }\n }\n }\n}\n" } }; })(); diff --git a/apps/console/src/__generated__/core/PublishDocumentsDialogMutation.graphql.ts b/apps/console/src/__generated__/core/PublishDocumentsDialogMutation.graphql.ts index e60fdda84..97872c012 100644 --- a/apps/console/src/__generated__/core/PublishDocumentsDialogMutation.graphql.ts +++ b/apps/console/src/__generated__/core/PublishDocumentsDialogMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<3fb1661c5bda6573c377f516b970643a>> + * @generated SignedSource<<96fbfd51b05b496753a0d278d92f2eb4>> * @lightSyntaxTransform * @nogrep */ @@ -53,7 +53,21 @@ v2 = { "kind": "ScalarField", "name": "id", "storageKey": null -}; +}, +v3 = { + "kind": "Literal", + "name": "first", + "value": 0 +}, +v4 = [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "totalCount", + "storageKey": null + } +]; return { "fragment": { "argumentDefinitions": (v0/*: any*/), @@ -196,12 +210,20 @@ return { "storageKey": null }, { - "alias": null, + "alias": "lastVersion", "args": [ { "kind": "Literal", "name": "first", "value": 1 + }, + { + "kind": "Literal", + "name": "orderBy", + "value": { + "direction": "DESC", + "field": "CREATED_AT" + } } ], "concreteType": "DocumentVersionConnection", @@ -245,47 +267,41 @@ return { "args": [ { "kind": "Literal", - "name": "first", - "value": 1000 - } + "name": "filter", + "value": { + "activeContract": true + } + }, + (v3/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": [ + "selections": (v4/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true},first:0)" + }, + { + "alias": "signedSignatures", + "args": [ { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignatureEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "DocumentVersionSignature", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v2/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "state", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } + "kind": "Literal", + "name": "filter", + "value": { + "activeContract": true, + "states": [ + "SIGNED" + ] + } + }, + (v3/*: any*/) ], - "storageKey": "signatures(first:1000)" + "concreteType": "DocumentVersionSignatureConnection", + "kind": "LinkedField", + "name": "signatures", + "plural": false, + "selections": (v4/*: any*/), + "storageKey": "signatures(filter:{\"activeContract\":true,\"states\":[\"SIGNED\"]},first:0)" } ], "storageKey": null @@ -294,7 +310,7 @@ return { "storageKey": null } ], - "storageKey": "versions(first:1)" + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" } ], "storageKey": null @@ -308,12 +324,12 @@ return { ] }, "params": { - "cacheID": "9e790eaab9b8c776beb9d021942bdf22", + "cacheID": "0ac164af501f3f1bb74483e15b320715", "id": null, "metadata": {}, "name": "PublishDocumentsDialogMutation", "operationKind": "mutation", - "text": "mutation PublishDocumentsDialogMutation(\n $input: BulkPublishDocumentVersionsInput!\n) {\n bulkPublishDocumentVersions(input: $input) {\n documentEdges {\n node {\n id\n ...DocumentListItemFragment\n }\n }\n }\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n versions(first: 1) {\n edges {\n node {\n id\n status\n version\n signatures(first: 1000) {\n edges {\n node {\n id\n state\n }\n }\n }\n }\n }\n }\n}\n" + "text": "mutation PublishDocumentsDialogMutation(\n $input: BulkPublishDocumentVersionsInput!\n) {\n bulkPublishDocumentVersions(input: $input) {\n documentEdges {\n node {\n id\n ...DocumentListItemFragment\n }\n }\n }\n}\n\nfragment DocumentListItemFragment on Document {\n id\n title\n documentType\n classification\n updatedAt\n canDelete: permission(action: \"core:document:delete\")\n owner {\n id\n fullName\n }\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n status\n version\n signatures(first: 0, filter: {activeContract: true}) {\n totalCount\n }\n signedSignatures: signatures(first: 0, filter: {states: [SIGNED], activeContract: true}) {\n totalCount\n }\n }\n }\n }\n}\n" } }; })(); diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx index 7a2797785..b236b6c3f 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx @@ -254,7 +254,7 @@ export function DocumentList(props: { checked={selection.includes(document.id)} onCheck={() => toggle(document.id)} key={document.id} - fKey={document} + fragmentRef={document} connectionId={connectionId} hasAnyAction={hasAnyAction} /> diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx index a0550b6bf..f4afddb0f 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx @@ -2,7 +2,7 @@ import { formatDate, getDocumentClassificationLabel, getDocumentTypeLabel, sprin import { useTranslate } from "@probo/i18n"; import { ActionDropdown, Avatar, Badge, Checkbox, DropdownItem, IconTrashCan, Td, Tr, useConfirm } from "@probo/ui"; import { useFragment } from "react-relay"; -import { graphql } from "relay-runtime"; +import { type DataID, graphql } from "relay-runtime"; import type { DocumentListItem_deleteMutation } from "#/__generated__/core/DocumentListItem_deleteMutation.graphql"; import type { DocumentListItemFragment$key } from "#/__generated__/core/DocumentListItemFragment.graphql"; @@ -21,19 +21,17 @@ const fragment = graphql` id fullName } - versions(first: 1) { + lastVersion: versions(first: 1 orderBy: { field: CREATED_AT direction: DESC }) { edges { node { id status version - signatures(first: 1000) { - edges { - node { - id - state - } - } + signatures(first: 0 filter: { activeContract: true }) { + totalCount + } + signedSignatures: signatures(first: 0 filter: { states: [SIGNED], activeContract: true }) { + totalCount } } } @@ -53,15 +51,15 @@ const deleteDocumentMutation = graphql` `; export function DocumentListItem(props: { - fKey: DocumentListItemFragment$key; - connectionId: string; + fragmentRef: DocumentListItemFragment$key; + connectionId: DataID; checked: boolean; onCheck: () => void; hasAnyAction: boolean; }) { const { connectionId, - fKey, + fragmentRef, checked, onCheck, hasAnyAction, @@ -70,11 +68,11 @@ export function DocumentListItem(props: { const organizationId = useOrganizationId(); const document = useFragment( fragment, - fKey, + fragmentRef, ); - const lastVersion = document.versions.edges?.[0]?.node; + const lastVersion = document.lastVersion.edges[0].node; - const isDraft = lastVersion?.status === "DRAFT"; + const isDraft = lastVersion.status === "DRAFT"; const { __ } = useTranslate(); const [deleteDocument] = useMutationWithToasts( @@ -86,17 +84,6 @@ export function DocumentListItem(props: { ); const confirm = useConfirm(); - if (!lastVersion) { - return null; - } - - const signatures - = lastVersion.signatures?.edges?.map(edge => edge?.node)?.filter(Boolean) - ?? []; - const signedCount = signatures.filter( - signature => signature.state === "SIGNED", - ).length; - const handleDelete = () => { confirm( () => @@ -148,9 +135,9 @@ export function DocumentListItem(props: { {formatDate(document.updatedAt)} - {signedCount} + {lastVersion.signedSignatures.totalCount} / - {signatures.length} + {lastVersion.signatures.totalCount} {hasAnyAction && (