From 51db1685f74476cf3ba59e1c5c55119b36f7fdfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 27 Jan 2026 17:08:11 +0400 Subject: [PATCH] Refactor documents controls & description tabs to pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- ...=> DocumentControlListFragment.graphql.ts} | 20 +- ...ts => DocumentControlListQuery.graphql.ts} | 28 +- ...trolList_attachControlMutation.graphql.ts} | 24 +- ...trolList_detachControlMutation.graphql.ts} | 24 +- .../core/DocumentControlsPageQuery.graphql.ts | 263 +++++++++++++++ .../DocumentDescriptionPageQuery.graphql.ts | 316 ++++++++++++++++++ .../core/DocumentLayoutQuery.graphql.ts | 315 ++++++----------- .../documents/DocumentLayout.tsx | 7 +- .../controls/DocumentControlsPage.tsx | 22 ++ .../controls/DocumentControlsPageLoader.tsx | 38 +++ .../_components/DocumentControlList.tsx} | 39 ++- .../description/DocumentDescriptionPage.tsx | 51 +++ .../DocumentDescriptionPageLoader.tsx | 42 +++ .../documents/tabs/DocumentDescriptionTab.tsx | 18 - apps/console/src/routes/documentsRoutes.ts | 4 +- 15 files changed, 902 insertions(+), 309 deletions(-) rename apps/console/src/__generated__/core/{DocumentControlsTabFragment.graphql.ts => DocumentControlListFragment.graphql.ts} (89%) rename apps/console/src/__generated__/core/{DocumentControlsTabControlsQuery.graphql.ts => DocumentControlListQuery.graphql.ts} (84%) rename apps/console/src/__generated__/core/{DocumentControlsTab_attachControlMutation.graphql.ts => DocumentControlList_attachControlMutation.graphql.ts} (87%) rename apps/console/src/__generated__/core/{DocumentControlsTab_detachControlMutation.graphql.ts => DocumentControlList_detachControlMutation.graphql.ts} (78%) create mode 100644 apps/console/src/__generated__/core/DocumentControlsPageQuery.graphql.ts create mode 100644 apps/console/src/__generated__/core/DocumentDescriptionPageQuery.graphql.ts create mode 100644 apps/console/src/pages/organizations/documents/controls/DocumentControlsPage.tsx create mode 100644 apps/console/src/pages/organizations/documents/controls/DocumentControlsPageLoader.tsx rename apps/console/src/pages/organizations/documents/{tabs/DocumentControlsTab.tsx => controls/_components/DocumentControlList.tsx} (67%) create mode 100644 apps/console/src/pages/organizations/documents/description/DocumentDescriptionPage.tsx create mode 100644 apps/console/src/pages/organizations/documents/description/DocumentDescriptionPageLoader.tsx delete mode 100644 apps/console/src/pages/organizations/documents/tabs/DocumentDescriptionTab.tsx diff --git a/apps/console/src/__generated__/core/DocumentControlsTabFragment.graphql.ts b/apps/console/src/__generated__/core/DocumentControlListFragment.graphql.ts similarity index 89% rename from apps/console/src/__generated__/core/DocumentControlsTabFragment.graphql.ts rename to apps/console/src/__generated__/core/DocumentControlListFragment.graphql.ts index a551f40b2..0850ee11f 100644 --- a/apps/console/src/__generated__/core/DocumentControlsTabFragment.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentControlListFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -10,7 +10,7 @@ import { ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; -export type DocumentControlsTabFragment$data = { +export type DocumentControlListFragment$data = { readonly controls: { readonly __id: string; readonly edges: ReadonlyArray<{ @@ -21,14 +21,14 @@ export type DocumentControlsTabFragment$data = { }>; }; readonly id: string; - readonly " $fragmentType": "DocumentControlsTabFragment"; + readonly " $fragmentType": "DocumentControlListFragment"; }; -export type DocumentControlsTabFragment$key = { - readonly " $data"?: DocumentControlsTabFragment$data; - readonly " $fragmentSpreads": FragmentRefs<"DocumentControlsTabFragment">; +export type DocumentControlListFragment$key = { + readonly " $data"?: DocumentControlListFragment$data; + readonly " $fragmentSpreads": FragmentRefs<"DocumentControlListFragment">; }; -import DocumentControlsTabControlsQuery_graphql from './DocumentControlsTabControlsQuery.graphql'; +import DocumentControlListQuery_graphql from './DocumentControlListQuery.graphql'; const node: ReaderFragment = (function(){ var v0 = [ @@ -99,14 +99,14 @@ return { "fragmentPathInResult": [ "node" ], - "operation": DocumentControlsTabControlsQuery_graphql, + "operation": DocumentControlListQuery_graphql, "identifierInfo": { "identifierField": "id", "identifierQueryVariableName": "id" } } }, - "name": "DocumentControlsTabFragment", + "name": "DocumentControlListFragment", "selections": [ (v1/*: any*/), { @@ -230,6 +230,6 @@ return { }; })(); -(node as any).hash = "c1b6d5212b3fa33f60c02ddee32d5cea"; +(node as any).hash = "564d18d5d5fb4c71f137e236bc16d138"; export default node; diff --git a/apps/console/src/__generated__/core/DocumentControlsTabControlsQuery.graphql.ts b/apps/console/src/__generated__/core/DocumentControlListQuery.graphql.ts similarity index 84% rename from apps/console/src/__generated__/core/DocumentControlsTabControlsQuery.graphql.ts rename to apps/console/src/__generated__/core/DocumentControlListQuery.graphql.ts index b1468e986..390e4448e 100644 --- a/apps/console/src/__generated__/core/DocumentControlsTabControlsQuery.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentControlListQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<9b0874e62bfe3cc79cbf2853e7571ae2>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -19,7 +19,7 @@ export type ControlOrder = { direction: OrderDirection; field: ControlOrderField; }; -export type DocumentControlsTabControlsQuery$variables = { +export type DocumentControlListQuery$variables = { after?: string | null | undefined; before?: string | null | undefined; filter?: ControlFilter | null | undefined; @@ -28,14 +28,14 @@ export type DocumentControlsTabControlsQuery$variables = { last?: number | null | undefined; order?: ControlOrder | null | undefined; }; -export type DocumentControlsTabControlsQuery$data = { +export type DocumentControlListQuery$data = { readonly node: { - readonly " $fragmentSpreads": FragmentRefs<"DocumentControlsTabFragment">; + readonly " $fragmentSpreads": FragmentRefs<"DocumentControlListFragment">; }; }; -export type DocumentControlsTabControlsQuery = { - response: DocumentControlsTabControlsQuery$data; - variables: DocumentControlsTabControlsQuery$variables; +export type DocumentControlListQuery = { + response: DocumentControlListQuery$data; + variables: DocumentControlListQuery$variables; }; const node: ConcreteRequest = (function(){ @@ -152,7 +152,7 @@ return { ], "kind": "Fragment", "metadata": null, - "name": "DocumentControlsTabControlsQuery", + "name": "DocumentControlListQuery", "selections": [ { "alias": null, @@ -176,7 +176,7 @@ return { } ], "kind": "FragmentSpread", - "name": "DocumentControlsTabFragment" + "name": "DocumentControlListFragment" } ], "storageKey": null @@ -197,7 +197,7 @@ return { (v4/*: any*/) ], "kind": "Operation", - "name": "DocumentControlsTabControlsQuery", + "name": "DocumentControlListQuery", "selections": [ { "alias": null, @@ -348,16 +348,16 @@ return { ] }, "params": { - "cacheID": "3640a2f9f03d965c268474fdfb4aa5e0", + "cacheID": "b88b4ca4d817fd4cb0e830391b10053a", "id": null, "metadata": {}, - "name": "DocumentControlsTabControlsQuery", + "name": "DocumentControlListQuery", "operationKind": "query", - "text": "query DocumentControlsTabControlsQuery(\n $after: CursorKey\n $before: CursorKey = null\n $filter: ControlFilter = null\n $first: Int = 20\n $last: Int = null\n $order: ControlOrder = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...DocumentControlsTabFragment_4cFWzS\n id\n }\n}\n\nfragment DocumentControlsTabFragment_4cFWzS on Document {\n id\n controls(first: $first, after: $after, last: $last, before: $before, orderBy: $order, filter: $filter) {\n edges {\n node {\n id\n ...LinkedControlsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment LinkedControlsCardFragment on Control {\n id\n name\n sectionTitle\n framework {\n id\n name\n }\n}\n" + "text": "query DocumentControlListQuery(\n $after: CursorKey\n $before: CursorKey = null\n $filter: ControlFilter = null\n $first: Int = 20\n $last: Int = null\n $order: ControlOrder = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...DocumentControlListFragment_4cFWzS\n id\n }\n}\n\nfragment DocumentControlListFragment_4cFWzS on Document {\n id\n controls(first: $first, after: $after, last: $last, before: $before, orderBy: $order, filter: $filter) {\n edges {\n node {\n id\n ...LinkedControlsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment LinkedControlsCardFragment on Control {\n id\n name\n sectionTitle\n framework {\n id\n name\n }\n}\n" } }; })(); -(node as any).hash = "c1b6d5212b3fa33f60c02ddee32d5cea"; +(node as any).hash = "564d18d5d5fb4c71f137e236bc16d138"; export default node; diff --git a/apps/console/src/__generated__/core/DocumentControlsTab_attachControlMutation.graphql.ts b/apps/console/src/__generated__/core/DocumentControlList_attachControlMutation.graphql.ts similarity index 87% rename from apps/console/src/__generated__/core/DocumentControlsTab_attachControlMutation.graphql.ts rename to apps/console/src/__generated__/core/DocumentControlList_attachControlMutation.graphql.ts index 245f852ad..ce02805fc 100644 --- a/apps/console/src/__generated__/core/DocumentControlsTab_attachControlMutation.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentControlList_attachControlMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<443d3250386ad406f7dc62c35297ed8f>> * @lightSyntaxTransform * @nogrep */ @@ -14,11 +14,11 @@ export type CreateControlDocumentMappingInput = { controlId: string; documentId: string; }; -export type DocumentControlsTab_attachControlMutation$variables = { +export type DocumentControlList_attachControlMutation$variables = { connections: ReadonlyArray; input: CreateControlDocumentMappingInput; }; -export type DocumentControlsTab_attachControlMutation$data = { +export type DocumentControlList_attachControlMutation$data = { readonly createControlDocumentMapping: { readonly controlEdge: { readonly node: { @@ -28,9 +28,9 @@ export type DocumentControlsTab_attachControlMutation$data = { }; }; }; -export type DocumentControlsTab_attachControlMutation = { - response: DocumentControlsTab_attachControlMutation$data; - variables: DocumentControlsTab_attachControlMutation$variables; +export type DocumentControlList_attachControlMutation = { + response: DocumentControlList_attachControlMutation$data; + variables: DocumentControlList_attachControlMutation$variables; }; const node: ConcreteRequest = (function(){ @@ -73,7 +73,7 @@ return { ], "kind": "Fragment", "metadata": null, - "name": "DocumentControlsTab_attachControlMutation", + "name": "DocumentControlList_attachControlMutation", "selections": [ { "alias": null, @@ -125,7 +125,7 @@ return { (v0/*: any*/) ], "kind": "Operation", - "name": "DocumentControlsTab_attachControlMutation", + "name": "DocumentControlList_attachControlMutation", "selections": [ { "alias": null, @@ -201,16 +201,16 @@ return { ] }, "params": { - "cacheID": "5506b27c88242f338e0d004c27f644de", + "cacheID": "b9968838fb5f70316d9245f390a881c8", "id": null, "metadata": {}, - "name": "DocumentControlsTab_attachControlMutation", + "name": "DocumentControlList_attachControlMutation", "operationKind": "mutation", - "text": "mutation DocumentControlsTab_attachControlMutation(\n $input: CreateControlDocumentMappingInput!\n) {\n createControlDocumentMapping(input: $input) {\n controlEdge {\n node {\n id\n ...LinkedControlsCardFragment\n }\n }\n }\n}\n\nfragment LinkedControlsCardFragment on Control {\n id\n name\n sectionTitle\n framework {\n id\n name\n }\n}\n" + "text": "mutation DocumentControlList_attachControlMutation(\n $input: CreateControlDocumentMappingInput!\n) {\n createControlDocumentMapping(input: $input) {\n controlEdge {\n node {\n id\n ...LinkedControlsCardFragment\n }\n }\n }\n}\n\nfragment LinkedControlsCardFragment on Control {\n id\n name\n sectionTitle\n framework {\n id\n name\n }\n}\n" } }; })(); -(node as any).hash = "273f0d619a2be7df7451e7354c53315a"; +(node as any).hash = "8598ac5c4d0f83519b134549cf6f3353"; export default node; diff --git a/apps/console/src/__generated__/core/DocumentControlsTab_detachControlMutation.graphql.ts b/apps/console/src/__generated__/core/DocumentControlList_detachControlMutation.graphql.ts similarity index 78% rename from apps/console/src/__generated__/core/DocumentControlsTab_detachControlMutation.graphql.ts rename to apps/console/src/__generated__/core/DocumentControlList_detachControlMutation.graphql.ts index 0ab2dc982..1c1755dc8 100644 --- a/apps/console/src/__generated__/core/DocumentControlsTab_detachControlMutation.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentControlList_detachControlMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<5c230fb025256fb7a5281ee5ecd3ccf4>> + * @generated SignedSource<<25dfecd5fa953558409d2a4d1daa32c3>> * @lightSyntaxTransform * @nogrep */ @@ -13,18 +13,18 @@ export type DeleteControlDocumentMappingInput = { controlId: string; documentId: string; }; -export type DocumentControlsTab_detachControlMutation$variables = { +export type DocumentControlList_detachControlMutation$variables = { connections: ReadonlyArray; input: DeleteControlDocumentMappingInput; }; -export type DocumentControlsTab_detachControlMutation$data = { +export type DocumentControlList_detachControlMutation$data = { readonly deleteControlDocumentMapping: { readonly deletedControlId: string; }; }; -export type DocumentControlsTab_detachControlMutation = { - response: DocumentControlsTab_detachControlMutation$data; - variables: DocumentControlsTab_detachControlMutation$variables; +export type DocumentControlList_detachControlMutation = { + response: DocumentControlList_detachControlMutation$data; + variables: DocumentControlList_detachControlMutation$variables; }; const node: ConcreteRequest = (function(){ @@ -60,7 +60,7 @@ return { ], "kind": "Fragment", "metadata": null, - "name": "DocumentControlsTab_detachControlMutation", + "name": "DocumentControlList_detachControlMutation", "selections": [ { "alias": null, @@ -85,7 +85,7 @@ return { (v0/*: any*/) ], "kind": "Operation", - "name": "DocumentControlsTab_detachControlMutation", + "name": "DocumentControlList_detachControlMutation", "selections": [ { "alias": null, @@ -118,16 +118,16 @@ return { ] }, "params": { - "cacheID": "fce801689ab578a47c33a50c60fc4cd7", + "cacheID": "5d78356c860e344801d99117b599665d", "id": null, "metadata": {}, - "name": "DocumentControlsTab_detachControlMutation", + "name": "DocumentControlList_detachControlMutation", "operationKind": "mutation", - "text": "mutation DocumentControlsTab_detachControlMutation(\n $input: DeleteControlDocumentMappingInput!\n) {\n deleteControlDocumentMapping(input: $input) {\n deletedControlId\n }\n}\n" + "text": "mutation DocumentControlList_detachControlMutation(\n $input: DeleteControlDocumentMappingInput!\n) {\n deleteControlDocumentMapping(input: $input) {\n deletedControlId\n }\n}\n" } }; })(); -(node as any).hash = "39c5b39c08ba37d06f5e0cfedc707a25"; +(node as any).hash = "fc76faa3002641acaf89856a94d37942"; export default node; diff --git a/apps/console/src/__generated__/core/DocumentControlsPageQuery.graphql.ts b/apps/console/src/__generated__/core/DocumentControlsPageQuery.graphql.ts new file mode 100644 index 000000000..ce61d96d5 --- /dev/null +++ b/apps/console/src/__generated__/core/DocumentControlsPageQuery.graphql.ts @@ -0,0 +1,263 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type DocumentControlsPageQuery$variables = { + documentId: string; +}; +export type DocumentControlsPageQuery$data = { + readonly document: { + readonly " $fragmentSpreads": FragmentRefs<"DocumentControlListFragment">; + }; +}; +export type DocumentControlsPageQuery = { + response: DocumentControlsPageQuery$data; + variables: DocumentControlsPageQuery$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "documentId" + } +], +v1 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "documentId" + } +], +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}, +v4 = [ + { + "kind": "Literal", + "name": "first", + "value": 20 + } +], +v5 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "name", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "DocumentControlsPageQuery", + "selections": [ + { + "alias": "document", + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "args": null, + "kind": "FragmentSpread", + "name": "DocumentControlListFragment" + } + ], + "storageKey": null + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "DocumentControlsPageQuery", + "selections": [ + { + "alias": "document", + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + (v3/*: any*/), + { + "kind": "InlineFragment", + "selections": [ + { + "alias": null, + "args": (v4/*: any*/), + "concreteType": "ControlConnection", + "kind": "LinkedField", + "name": "controls", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "ControlEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "Control", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v3/*: any*/), + (v5/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "sectionTitle", + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "Framework", + "kind": "LinkedField", + "name": "framework", + "plural": false, + "selections": [ + (v3/*: any*/), + (v5/*: any*/) + ], + "storageKey": null + }, + (v2/*: any*/) + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "PageInfo", + "kind": "LinkedField", + "name": "pageInfo", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasPreviousPage", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "startCursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] + } + ], + "storageKey": "controls(first:20)" + }, + { + "alias": null, + "args": (v4/*: any*/), + "filters": [ + "orderBy", + "filter" + ], + "handle": "connection", + "key": "DocumentControlsTab_controls", + "kind": "LinkedHandle", + "name": "controls" + } + ], + "type": "Document", + "abstractKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "94cf68d78b8b5d80bf25b716644a6950", + "id": null, + "metadata": {}, + "name": "DocumentControlsPageQuery", + "operationKind": "query", + "text": "query DocumentControlsPageQuery(\n $documentId: ID!\n) {\n document: node(id: $documentId) {\n __typename\n ...DocumentControlListFragment\n id\n }\n}\n\nfragment DocumentControlListFragment on Document {\n id\n controls(first: 20) {\n edges {\n node {\n id\n ...LinkedControlsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment LinkedControlsCardFragment on Control {\n id\n name\n sectionTitle\n framework {\n id\n name\n }\n}\n" + } +}; +})(); + +(node as any).hash = "847158fb93fde696fbaa2cb5098bc0e3"; + +export default node; diff --git a/apps/console/src/__generated__/core/DocumentDescriptionPageQuery.graphql.ts b/apps/console/src/__generated__/core/DocumentDescriptionPageQuery.graphql.ts new file mode 100644 index 000000000..a289b1d19 --- /dev/null +++ b/apps/console/src/__generated__/core/DocumentDescriptionPageQuery.graphql.ts @@ -0,0 +1,316 @@ +/** + * @generated SignedSource<<2842b2f8f4ab4a912666b7d7a15cf6d4>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +export type DocumentDescriptionPageQuery$variables = { + documentId: string; + versionId: string; + versionSpecified: boolean; +}; +export type DocumentDescriptionPageQuery$data = { + readonly document: { + readonly __typename: "Document"; + readonly lastVersion?: { + readonly edges: ReadonlyArray<{ + readonly node: { + readonly content: string; + }; + }>; + }; + } | { + // This will never be '%other', but we need some + // value in case none of the concrete values match. + readonly __typename: "%other"; + }; + readonly version?: { + readonly __typename: "DocumentVersion"; + readonly content: string; + } | { + // This will never be '%other', but we need some + // value in case none of the concrete values match. + readonly __typename: "%other"; + }; +}; +export type DocumentDescriptionPageQuery = { + response: DocumentDescriptionPageQuery$data; + variables: DocumentDescriptionPageQuery$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "documentId" + }, + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "versionId" + }, + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "versionSpecified" + } +], +v1 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "versionId" + } +], +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "content", + "storageKey": null +}, +v4 = [ + (v3/*: any*/) +], +v5 = { + "kind": "InlineFragment", + "selections": (v4/*: any*/), + "type": "DocumentVersion", + "abstractKey": null +}, +v6 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "documentId" + } +], +v7 = [ + { + "kind": "Literal", + "name": "first", + "value": 1 + }, + { + "kind": "Literal", + "name": "orderBy", + "value": { + "direction": "DESC", + "field": "CREATED_AT" + } + } +], +v8 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "DocumentDescriptionPageQuery", + "selections": [ + { + "condition": "versionSpecified", + "kind": "Condition", + "passingValue": true, + "selections": [ + { + "alias": "version", + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + (v5/*: any*/) + ], + "storageKey": null + } + ] + }, + { + "alias": "document", + "args": (v6/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + { + "kind": "InlineFragment", + "selections": [ + { + "condition": "versionSpecified", + "kind": "Condition", + "passingValue": false, + "selections": [ + { + "alias": "lastVersion", + "args": (v7/*: any*/), + "concreteType": "DocumentVersionConnection", + "kind": "LinkedField", + "name": "versions", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "DocumentVersionEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "DocumentVersion", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": (v4/*: any*/), + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" + } + ] + } + ], + "type": "Document", + "abstractKey": null + } + ], + "storageKey": null + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "DocumentDescriptionPageQuery", + "selections": [ + { + "condition": "versionSpecified", + "kind": "Condition", + "passingValue": true, + "selections": [ + { + "alias": "version", + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + (v5/*: any*/), + (v8/*: any*/) + ], + "storageKey": null + } + ] + }, + { + "alias": "document", + "args": (v6/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + { + "kind": "InlineFragment", + "selections": [ + { + "condition": "versionSpecified", + "kind": "Condition", + "passingValue": false, + "selections": [ + { + "alias": "lastVersion", + "args": (v7/*: any*/), + "concreteType": "DocumentVersionConnection", + "kind": "LinkedField", + "name": "versions", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "DocumentVersionEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "DocumentVersion", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v3/*: any*/), + (v8/*: any*/) + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})" + } + ] + } + ], + "type": "Document", + "abstractKey": null + }, + (v8/*: any*/) + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "4646502b657225d9ba8f985892e6896f", + "id": null, + "metadata": {}, + "name": "DocumentDescriptionPageQuery", + "operationKind": "query", + "text": "query DocumentDescriptionPageQuery(\n $documentId: ID!\n $versionId: ID!\n $versionSpecified: Boolean!\n) {\n version: node(id: $versionId) @include(if: $versionSpecified) {\n __typename\n ... on DocumentVersion {\n content\n }\n id\n }\n document: node(id: $documentId) {\n __typename\n ... on Document {\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) @skip(if: $versionSpecified) {\n edges {\n node {\n content\n id\n }\n }\n }\n }\n id\n }\n}\n" + } +}; +})(); + +(node as any).hash = "a0db3f402544a630895fb0b55efd916f"; + +export default node; diff --git a/apps/console/src/__generated__/core/DocumentLayoutQuery.graphql.ts b/apps/console/src/__generated__/core/DocumentLayoutQuery.graphql.ts index d30eb4494..28ed4fc95 100644 --- a/apps/console/src/__generated__/core/DocumentLayoutQuery.graphql.ts +++ b/apps/console/src/__generated__/core/DocumentLayoutQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<50f02328ff252b0ce2af4637d8f002c7>> * @lightSyntaxTransform * @nogrep */ @@ -27,7 +27,6 @@ export type DocumentLayoutQuery$data = { readonly lastVersion?: { readonly edges: ReadonlyArray<{ readonly node: { - readonly content: string; readonly id: string; readonly signatures: { readonly totalCount: number; @@ -41,7 +40,7 @@ export type DocumentLayoutQuery$data = { }>; }; readonly title: string; - readonly " $fragmentSpreads": FragmentRefs<"DocumentActionsDropdown_documentFragment" | "DocumentControlsTabFragment" | "DocumentLayoutDrawer_documentFragment" | "DocumentTitleFormFragment">; + readonly " $fragmentSpreads": FragmentRefs<"DocumentActionsDropdown_documentFragment" | "DocumentLayoutDrawer_documentFragment" | "DocumentTitleFormFragment">; } | { // This will never be '%other', but we need some // value in case none of the concrete values match. @@ -49,7 +48,6 @@ export type DocumentLayoutQuery$data = { }; readonly version?: { readonly __typename: "DocumentVersion"; - readonly content: string; readonly id: string; readonly signatures: { readonly totalCount: number; @@ -117,28 +115,21 @@ v4 = { "storageKey": null }, v5 = { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "content", - "storageKey": null -}, -v6 = { "kind": "Literal", "name": "first", "value": 0 }, -v7 = { +v6 = { "alias": null, "args": null, "kind": "ScalarField", "name": "totalCount", "storageKey": null }, -v8 = [ - (v7/*: any*/) +v7 = [ + (v6/*: any*/) ], -v9 = { +v8 = { "alias": null, "args": [ { @@ -148,16 +139,16 @@ v9 = { "activeContract": true } }, - (v6/*: any*/) + (v5/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": (v8/*: any*/), + "selections": (v7/*: any*/), "storageKey": "signatures(filter:{\"activeContract\":true},first:0)" }, -v10 = { +v9 = { "alias": "signedSignatures", "args": [ { @@ -170,19 +161,18 @@ v10 = { ] } }, - (v6/*: any*/) + (v5/*: any*/) ], "concreteType": "DocumentVersionSignatureConnection", "kind": "LinkedField", "name": "signatures", "plural": false, - "selections": (v8/*: any*/), + "selections": (v7/*: any*/), "storageKey": "signatures(filter:{\"activeContract\":true,\"states\":[\"SIGNED\"]},first:0)" }, -v11 = [ +v10 = [ (v3/*: any*/), (v4/*: any*/), - (v5/*: any*/), { "args": null, "kind": "FragmentSpread", @@ -193,24 +183,24 @@ v11 = [ "kind": "FragmentSpread", "name": "DocumentLayoutDrawer_versionFragment" }, - (v9/*: any*/), - (v10/*: any*/) + (v8/*: any*/), + (v9/*: any*/) ], -v12 = [ +v11 = [ { "kind": "Variable", "name": "id", "variableName": "documentId" } ], -v13 = { +v12 = { "alias": null, "args": null, "kind": "ScalarField", "name": "title", "storageKey": null }, -v14 = { +v13 = { "alias": "canPublish", "args": [ { @@ -223,19 +213,19 @@ v14 = { "name": "permission", "storageKey": "permission(action:\"core:document-version:publish\")" }, -v15 = { +v14 = { "alias": "controlInfo", "args": [ - (v6/*: any*/) + (v5/*: any*/) ], "concreteType": "ControlConnection", "kind": "LinkedField", "name": "controls", "plural": false, - "selections": (v8/*: any*/), + "selections": (v7/*: any*/), "storageKey": "controls(first:0)" }, -v16 = [ +v15 = [ { "kind": "Literal", "name": "first", @@ -250,61 +240,21 @@ v16 = [ } } ], -v17 = [ +v16 = [ { "kind": "Literal", "name": "first", "value": 20 } ], -v18 = { - "kind": "ClientExtension", - "selections": [ - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "__id", - "storageKey": null - } - ] -}, -v19 = { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "cursor", - "storageKey": null -}, -v20 = { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "endCursor", - "storageKey": null -}, -v21 = { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "hasNextPage", - "storageKey": null -}, -v22 = { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "name", - "storageKey": null -}, -v23 = { +v17 = { "alias": null, "args": null, "kind": "ScalarField", "name": "version", "storageKey": null }, -v24 = { +v18 = { "alias": "canDeleteDraft", "args": [ { @@ -317,14 +267,14 @@ v24 = { "name": "permission", "storageKey": "permission(action:\"core:document-version:delete-draft\")" }, -v25 = { +v19 = { "alias": null, "args": null, "kind": "ScalarField", "name": "classification", "storageKey": null }, -v26 = { +v20 = { "alias": null, "args": null, "concreteType": "People", @@ -343,14 +293,14 @@ v26 = { ], "storageKey": null }, -v27 = { +v21 = { "alias": null, "args": null, "kind": "ScalarField", "name": "updatedAt", "storageKey": null }, -v28 = { +v22 = { "alias": null, "args": null, "kind": "ScalarField", @@ -380,7 +330,7 @@ return { (v2/*: any*/), { "kind": "InlineFragment", - "selections": (v11/*: any*/), + "selections": (v10/*: any*/), "type": "DocumentVersion", "abstractKey": null } @@ -391,7 +341,7 @@ return { }, { "alias": "document", - "args": (v12/*: any*/), + "args": (v11/*: any*/), "concreteType": null, "kind": "LinkedField", "name": "node", @@ -402,9 +352,9 @@ return { "kind": "InlineFragment", "selections": [ (v3/*: any*/), + (v12/*: any*/), (v13/*: any*/), (v14/*: any*/), - (v15/*: any*/), { "args": null, "kind": "FragmentSpread", @@ -420,11 +370,6 @@ return { "kind": "FragmentSpread", "name": "DocumentLayoutDrawer_documentFragment" }, - { - "args": null, - "kind": "FragmentSpread", - "name": "DocumentControlsTabFragment" - }, { "condition": "versionSpecified", "kind": "Condition", @@ -432,7 +377,7 @@ return { "selections": [ { "alias": "lastVersion", - "args": (v16/*: any*/), + "args": (v15/*: any*/), "concreteType": "DocumentVersionConnection", "kind": "LinkedField", "name": "versions", @@ -453,7 +398,7 @@ return { "kind": "LinkedField", "name": "node", "plural": false, - "selections": (v11/*: any*/), + "selections": (v10/*: any*/), "storageKey": null } ], @@ -483,7 +428,7 @@ return { "selections": [ { "alias": "document", - "args": (v12/*: any*/), + "args": (v11/*: any*/), "concreteType": null, "kind": "LinkedField", "name": "node", @@ -494,9 +439,9 @@ return { { "kind": "InlineFragment", "selections": [ + (v12/*: any*/), (v13/*: any*/), (v14/*: any*/), - (v15/*: any*/), { "alias": "canUpdate", "args": [ @@ -525,14 +470,25 @@ return { }, { "alias": null, - "args": (v17/*: any*/), + "args": (v16/*: any*/), "concreteType": "DocumentVersionConnection", "kind": "LinkedField", "name": "versions", "plural": false, "selections": [ - (v7/*: any*/), - (v18/*: any*/), + (v6/*: any*/), + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] + }, { "alias": null, "args": null, @@ -551,12 +507,24 @@ return { "selections": [ (v3/*: any*/), (v4/*: any*/), - (v5/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "content", + "storageKey": null + }, (v2/*: any*/) ], "storageKey": null }, - (v19/*: any*/) + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } ], "storageKey": null }, @@ -568,8 +536,20 @@ return { "name": "pageInfo", "plural": false, "selections": [ - (v20/*: any*/), - (v21/*: any*/) + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null + } ], "storageKey": null } @@ -578,7 +558,7 @@ return { }, { "alias": null, - "args": (v17/*: any*/), + "args": (v16/*: any*/), "filters": null, "handle": "connection", "key": "DocumentLayout_versions", @@ -592,103 +572,6 @@ return { "name": "documentType", "storageKey": null }, - { - "alias": null, - "args": (v17/*: any*/), - "concreteType": "ControlConnection", - "kind": "LinkedField", - "name": "controls", - "plural": false, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "ControlEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "Control", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v3/*: any*/), - (v22/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "sectionTitle", - "storageKey": null - }, - { - "alias": null, - "args": null, - "concreteType": "Framework", - "kind": "LinkedField", - "name": "framework", - "plural": false, - "selections": [ - (v3/*: any*/), - (v22/*: any*/) - ], - "storageKey": null - }, - (v2/*: any*/) - ], - "storageKey": null - }, - (v19/*: any*/) - ], - "storageKey": null - }, - { - "alias": null, - "args": null, - "concreteType": "PageInfo", - "kind": "LinkedField", - "name": "pageInfo", - "plural": false, - "selections": [ - (v20/*: any*/), - (v21/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "hasPreviousPage", - "storageKey": null - }, - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "startCursor", - "storageKey": null - } - ], - "storageKey": null - }, - (v18/*: any*/) - ], - "storageKey": "controls(first:20)" - }, - { - "alias": null, - "args": (v17/*: any*/), - "filters": [ - "orderBy", - "filter" - ], - "handle": "connection", - "key": "DocumentControlsTab_controls", - "kind": "LinkedHandle", - "name": "controls" - }, { "condition": "versionSpecified", "kind": "Condition", @@ -696,7 +579,7 @@ return { "selections": [ { "alias": "lastVersion", - "args": (v16/*: any*/), + "args": (v15/*: any*/), "concreteType": "DocumentVersionConnection", "kind": "LinkedField", "name": "versions", @@ -720,15 +603,14 @@ return { "selections": [ (v3/*: any*/), (v4/*: any*/), - (v5/*: any*/), - (v23/*: any*/), - (v24/*: any*/), - (v25/*: any*/), - (v26/*: any*/), - (v27/*: any*/), - (v28/*: any*/), - (v9/*: any*/), - (v10/*: any*/) + (v17/*: any*/), + (v18/*: any*/), + (v19/*: any*/), + (v20/*: any*/), + (v21/*: any*/), + (v22/*: any*/), + (v8/*: any*/), + (v9/*: any*/) ], "storageKey": null } @@ -766,15 +648,14 @@ return { "kind": "InlineFragment", "selections": [ (v4/*: any*/), - (v5/*: any*/), - (v23/*: any*/), - (v24/*: any*/), - (v25/*: any*/), - (v26/*: any*/), - (v27/*: any*/), - (v28/*: any*/), - (v9/*: any*/), - (v10/*: any*/) + (v17/*: any*/), + (v18/*: any*/), + (v19/*: any*/), + (v20/*: any*/), + (v21/*: any*/), + (v22/*: any*/), + (v8/*: any*/), + (v9/*: any*/) ], "type": "DocumentVersion", "abstractKey": null @@ -787,16 +668,16 @@ return { ] }, "params": { - "cacheID": "9d915bec70a2a5c1b9924d73e537d3b1", + "cacheID": "d59daf2c6257e5a744e20896c646fc38", "id": null, "metadata": {}, "name": "DocumentLayoutQuery", "operationKind": "query", - "text": "query DocumentLayoutQuery(\n $documentId: ID!\n $versionId: ID!\n $versionSpecified: Boolean!\n) {\n version: node(id: $versionId) @include(if: $versionSpecified) {\n __typename\n ... on DocumentVersion {\n id\n status\n content\n ...DocumentActionsDropdown_versionFragment\n ...DocumentLayoutDrawer_versionFragment\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 id\n }\n document: node(id: $documentId) {\n __typename\n ... on Document {\n id\n title\n canPublish: permission(action: \"core:document-version:publish\")\n controlInfo: controls(first: 0) {\n totalCount\n }\n ...DocumentTitleFormFragment\n ...DocumentActionsDropdown_documentFragment\n ...DocumentLayoutDrawer_documentFragment\n ...DocumentControlsTabFragment\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) @skip(if: $versionSpecified) {\n edges {\n node {\n id\n status\n content\n ...DocumentActionsDropdown_versionFragment\n ...DocumentLayoutDrawer_versionFragment\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 id\n }\n}\n\nfragment DocumentActionsDropdown_documentFragment on Document {\n id\n title\n canUpdate: permission(action: \"core:document:update\")\n canDelete: permission(action: \"core:document:delete\")\n versions(first: 20) {\n totalCount\n }\n ...UpdateVersionDialogFragment\n}\n\nfragment DocumentActionsDropdown_versionFragment on DocumentVersion {\n id\n version\n status\n canDeleteDraft: permission(action: \"core:document-version:delete-draft\")\n}\n\nfragment DocumentControlsTabFragment on Document {\n id\n controls(first: 20) {\n edges {\n node {\n id\n ...LinkedControlsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment DocumentLayoutDrawer_documentFragment on Document {\n id\n documentType\n canUpdate: permission(action: \"core:document:update\")\n}\n\nfragment DocumentLayoutDrawer_versionFragment on DocumentVersion {\n id\n classification\n owner {\n id\n fullName\n }\n version\n status\n updatedAt\n publishedAt\n}\n\nfragment DocumentTitleFormFragment on Document {\n id\n title\n canUpdate: permission(action: \"core:document:update\")\n}\n\nfragment LinkedControlsCardFragment on Control {\n id\n name\n sectionTitle\n framework {\n id\n name\n }\n}\n\nfragment UpdateVersionDialogFragment on Document {\n id\n versions(first: 20) {\n edges {\n node {\n id\n status\n content\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n" + "text": "query DocumentLayoutQuery(\n $documentId: ID!\n $versionId: ID!\n $versionSpecified: Boolean!\n) {\n version: node(id: $versionId) @include(if: $versionSpecified) {\n __typename\n ... on DocumentVersion {\n id\n status\n ...DocumentActionsDropdown_versionFragment\n ...DocumentLayoutDrawer_versionFragment\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 id\n }\n document: node(id: $documentId) {\n __typename\n ... on Document {\n id\n title\n canPublish: permission(action: \"core:document-version:publish\")\n controlInfo: controls(first: 0) {\n totalCount\n }\n ...DocumentTitleFormFragment\n ...DocumentActionsDropdown_documentFragment\n ...DocumentLayoutDrawer_documentFragment\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) @skip(if: $versionSpecified) {\n edges {\n node {\n id\n status\n ...DocumentActionsDropdown_versionFragment\n ...DocumentLayoutDrawer_versionFragment\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 id\n }\n}\n\nfragment DocumentActionsDropdown_documentFragment on Document {\n id\n title\n canUpdate: permission(action: \"core:document:update\")\n canDelete: permission(action: \"core:document:delete\")\n versions(first: 20) {\n totalCount\n }\n ...UpdateVersionDialogFragment\n}\n\nfragment DocumentActionsDropdown_versionFragment on DocumentVersion {\n id\n version\n status\n canDeleteDraft: permission(action: \"core:document-version:delete-draft\")\n}\n\nfragment DocumentLayoutDrawer_documentFragment on Document {\n id\n documentType\n canUpdate: permission(action: \"core:document:update\")\n}\n\nfragment DocumentLayoutDrawer_versionFragment on DocumentVersion {\n id\n classification\n owner {\n id\n fullName\n }\n version\n status\n updatedAt\n publishedAt\n}\n\nfragment DocumentTitleFormFragment on Document {\n id\n title\n canUpdate: permission(action: \"core:document:update\")\n}\n\nfragment UpdateVersionDialogFragment on Document {\n id\n versions(first: 20) {\n edges {\n node {\n id\n status\n content\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n" } }; })(); -(node as any).hash = "ef2d8e2f721cb77607af7421f76cd695"; +(node as any).hash = "2ae22db6e21db2cade3476a25b912eec"; export default node; diff --git a/apps/console/src/pages/organizations/documents/DocumentLayout.tsx b/apps/console/src/pages/organizations/documents/DocumentLayout.tsx index 8adcc0c0c..530bb4392 100644 --- a/apps/console/src/pages/organizations/documents/DocumentLayout.tsx +++ b/apps/console/src/pages/organizations/documents/DocumentLayout.tsx @@ -21,7 +21,6 @@ export const documentLayoutQuery = graphql` ... on DocumentVersion { id status - content # TODO: remove, is used on description tab ...DocumentActionsDropdown_versionFragment ...DocumentLayoutDrawer_versionFragment signatures(first: 0 filter: { activeContract: true }) { @@ -44,15 +43,12 @@ export const documentLayoutQuery = graphql` ...DocumentTitleFormFragment ...DocumentActionsDropdown_documentFragment ...DocumentLayoutDrawer_documentFragment - # TDOO: remove - ...DocumentControlsTabFragment # We use this on /documents/:documentId lastVersion: versions(first: 1 orderBy: { field: CREATED_AT, direction: DESC }) @skip(if: $versionSpecified) { edges { node { id status - content # TODO: remove, is used on description tab ...DocumentActionsDropdown_versionFragment ...DocumentLayoutDrawer_versionFragment signatures(first: 0 filter: { activeContract: true }) { @@ -176,8 +172,7 @@ export function DocumentLayout(props: { queryRef: PreloadedQuery - {/* TODO: remove context once control tab is using its own query */} - + diff --git a/apps/console/src/pages/organizations/documents/controls/DocumentControlsPage.tsx b/apps/console/src/pages/organizations/documents/controls/DocumentControlsPage.tsx new file mode 100644 index 000000000..4451d153e --- /dev/null +++ b/apps/console/src/pages/organizations/documents/controls/DocumentControlsPage.tsx @@ -0,0 +1,22 @@ +import { type PreloadedQuery, usePreloadedQuery } from "react-relay"; +import { graphql } from "relay-runtime"; + +import type { DocumentControlsPageQuery } from "#/__generated__/core/DocumentControlsPageQuery.graphql"; + +import { DocumentControlList } from "./_components/DocumentControlList"; + +export const documentControlsPagePageQuery = graphql` + query DocumentControlsPageQuery($documentId: ID!) { + document: node(id: $documentId) { + ...DocumentControlListFragment + } + } +`; + +export function DocumentControlsPage(props: { queryRef: PreloadedQuery }) { + const { queryRef } = props; + + const { document } = usePreloadedQuery(documentControlsPagePageQuery, queryRef); + + return ; +} diff --git a/apps/console/src/pages/organizations/documents/controls/DocumentControlsPageLoader.tsx b/apps/console/src/pages/organizations/documents/controls/DocumentControlsPageLoader.tsx new file mode 100644 index 000000000..7303c52a5 --- /dev/null +++ b/apps/console/src/pages/organizations/documents/controls/DocumentControlsPageLoader.tsx @@ -0,0 +1,38 @@ +import { useEffect } from "react"; +import { useQueryLoader } from "react-relay"; +import { useParams } from "react-router"; + +import type { DocumentControlsPageQuery } from "#/__generated__/core/DocumentControlsPageQuery.graphql"; +import { LinkCardSkeleton } from "#/components/skeletons/LinkCardSkeleton"; +import { CoreRelayProvider } from "#/providers/CoreRelayProvider"; + +import { DocumentControlsPage, documentControlsPagePageQuery } from "./DocumentControlsPage"; + +function DocumentControlsPageQueryLoader() { + const { documentId } = useParams(); + if (!documentId) { + throw new Error(":documentId missing in route params"); + } + + const [queryRef, loadQuery] = useQueryLoader(documentControlsPagePageQuery); + + useEffect(() => { + if (!queryRef) { + loadQuery({ documentId }); + } + }); + + if (!queryRef) { + return ; + } + + return ; +} + +export default function DocumentControlsPageLoader() { + return ( + + + + ); +} diff --git a/apps/console/src/pages/organizations/documents/tabs/DocumentControlsTab.tsx b/apps/console/src/pages/organizations/documents/controls/_components/DocumentControlList.tsx similarity index 67% rename from apps/console/src/pages/organizations/documents/tabs/DocumentControlsTab.tsx rename to apps/console/src/pages/organizations/documents/controls/_components/DocumentControlList.tsx index 704c7a64b..3ae44b8ec 100644 --- a/apps/console/src/pages/organizations/documents/tabs/DocumentControlsTab.tsx +++ b/apps/console/src/pages/organizations/documents/controls/_components/DocumentControlList.tsx @@ -1,13 +1,14 @@ +import type { ComponentProps } from "react"; import { useRefetchableFragment } from "react-relay"; -import { useOutletContext } from "react-router"; import { graphql } from "relay-runtime"; -import type { DocumentControlsTabFragment$key } from "#/__generated__/core/DocumentControlsTabFragment.graphql"; +import type { DocumentControlListFragment$key } from "#/__generated__/core/DocumentControlListFragment.graphql"; +import type { DocumentControlListQuery } from "#/__generated__/core/DocumentControlListQuery.graphql"; import { LinkedControlsCard } from "#/components/controls/LinkedControlsCard"; import { useMutationWithIncrement } from "#/hooks/useMutationWithIncrement"; -export const controlsFragment = graphql` - fragment DocumentControlsTabFragment on Document +const fragment = graphql` + fragment DocumentControlListFragment on Document @argumentDefinitions( first: { type: "Int", defaultValue: 20 } after: { type: "CursorKey" } @@ -16,7 +17,7 @@ export const controlsFragment = graphql` order: { type: "ControlOrder", defaultValue: null } filter: { type: "ControlFilter", defaultValue: null } ) - @refetchable(queryName: "DocumentControlsTabControlsQuery") { + @refetchable(queryName: "DocumentControlListQuery") { id controls( first: $first @@ -38,7 +39,7 @@ export const controlsFragment = graphql` `; const detachControlMutation = graphql` - mutation DocumentControlsTab_detachControlMutation( + mutation DocumentControlList_detachControlMutation( $input: DeleteControlDocumentMappingInput! $connections: [ID!]! ) { @@ -49,7 +50,7 @@ const detachControlMutation = graphql` `; const attachControlMutation = graphql` - mutation DocumentControlsTab_attachControlMutation( + mutation DocumentControlList_attachControlMutation( $input: CreateControlDocumentMappingInput! $connections: [ID!]! ) { @@ -64,14 +65,15 @@ const attachControlMutation = graphql` } `; -export default function DocumentControlsTab() { - const { document } = useOutletContext<{ - document: DocumentControlsTabFragment$key; - }>(); - const [data, refetch] = useRefetchableFragment(controlsFragment, document); - const controls = data.controls.edges.map(edge => edge.node); +export function DocumentControlList(props: { fragmentRef: DocumentControlListFragment$key }) { + const { fragmentRef } = props; + + const [document, refetch] = useRefetchableFragment( + fragment, + fragmentRef, + ); const incrementOptions = { - id: data.id, + id: document.id, node: "controls(first:0)", }; const [detachControl, isDetaching] = useMutationWithIncrement( @@ -91,15 +93,16 @@ export default function DocumentControlsTab() { }, ); const isLoading = isDetaching || isAttaching; + return ( node)} + params={{ documentId: document.id }} + connectionId={document.controls.__id} onDetach={detachControl} onAttach={attachControl} - refetch={refetch} + refetch={refetch as ComponentProps["refetch"]} /> ); } diff --git a/apps/console/src/pages/organizations/documents/description/DocumentDescriptionPage.tsx b/apps/console/src/pages/organizations/documents/description/DocumentDescriptionPage.tsx new file mode 100644 index 000000000..d00916cb7 --- /dev/null +++ b/apps/console/src/pages/organizations/documents/description/DocumentDescriptionPage.tsx @@ -0,0 +1,51 @@ +import { Markdown } from "@probo/ui"; +import { type PreloadedQuery, usePreloadedQuery } from "react-relay"; +import { graphql } from "relay-runtime"; + +import type { DocumentDescriptionPageQuery } from "#/__generated__/core/DocumentDescriptionPageQuery.graphql"; + +export const documentDescriptionPageQuery = graphql` + query DocumentDescriptionPageQuery($documentId: ID! $versionId: ID! $versionSpecified: Boolean!) { + # We use this on /documents/:documentId/versions/:versionId/description + version: node(id: $versionId) @include(if: $versionSpecified) { + __typename + ... on DocumentVersion { + content + } + } + document: node(id: $documentId) { + __typename + ... on Document { + # We use this on /documents/:documentId/description + lastVersion: versions(first: 1 orderBy: { field: CREATED_AT, direction: DESC }) @skip(if: $versionSpecified) { + edges { + node { + content + } + } + } + } + } + } +`; + +export function DocumentDescriptionPage(props: { queryRef: PreloadedQuery }) { + const { queryRef } = props; + + const { document, version } = usePreloadedQuery( + documentDescriptionPageQuery, + queryRef, + ); + if (document.__typename !== "Document" || (version && version.__typename !== "DocumentVersion")) { + throw new Error("invalid type for node"); + } + + const lastVersion = document.lastVersion?.edges[0].node; + const currentVersion = lastVersion ?? version as NonNullable; + + return ( +
+ +
+ ); +} diff --git a/apps/console/src/pages/organizations/documents/description/DocumentDescriptionPageLoader.tsx b/apps/console/src/pages/organizations/documents/description/DocumentDescriptionPageLoader.tsx new file mode 100644 index 000000000..b5e78b83a --- /dev/null +++ b/apps/console/src/pages/organizations/documents/description/DocumentDescriptionPageLoader.tsx @@ -0,0 +1,42 @@ +import { useEffect } from "react"; +import { useQueryLoader } from "react-relay"; +import { useParams } from "react-router"; + +import type { DocumentDescriptionPageQuery } from "#/__generated__/core/DocumentDescriptionPageQuery.graphql"; +import { LinkCardSkeleton } from "#/components/skeletons/LinkCardSkeleton"; +import { CoreRelayProvider } from "#/providers/CoreRelayProvider"; + +import { DocumentDescriptionPage, documentDescriptionPageQuery } from "./DocumentDescriptionPage"; + +function DocumentDescriptionPageQueryLoader() { + const { documentId, versionId } = useParams(); + if (!documentId) { + throw new Error(":documentId missing in route params"); + } + + const [queryRef, loadQuery] = useQueryLoader(documentDescriptionPageQuery); + + useEffect(() => { + if (!queryRef) { + loadQuery({ + documentId: documentId, + versionId: versionId ?? "", + versionSpecified: !!versionId, + }); + } + }); + + if (!queryRef) { + return ; + } + + return ; +} + +export default function DocumentDescriptionPageLoader() { + return ( + + + + ); +} diff --git a/apps/console/src/pages/organizations/documents/tabs/DocumentDescriptionTab.tsx b/apps/console/src/pages/organizations/documents/tabs/DocumentDescriptionTab.tsx deleted file mode 100644 index 3244947a9..000000000 --- a/apps/console/src/pages/organizations/documents/tabs/DocumentDescriptionTab.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Markdown } from "@probo/ui"; -import { useOutletContext } from "react-router"; - -import type { DocumentLayoutQuery$data } from "#/__generated__/core/DocumentLayoutQuery.graphql"; -import type { NodeOf } from "#/types"; - -export default function DocumentDescriptionTab() { - const { version } = useOutletContext<{ - version: NodeOf< - Extract["lastVersion"] - > | Extract; - }>(); - return ( -
- -
- ); -} diff --git a/apps/console/src/routes/documentsRoutes.ts b/apps/console/src/routes/documentsRoutes.ts index 56e414c5c..9f71c011f 100644 --- a/apps/console/src/routes/documentsRoutes.ts +++ b/apps/console/src/routes/documentsRoutes.ts @@ -29,7 +29,7 @@ const documentTabs = (prefix: string) => { Fallback: LinkCardSkeleton, Component: lazy( () => - import("../pages/organizations/documents/tabs/DocumentDescriptionTab"), + import("#/pages/organizations/documents/description/DocumentDescriptionPageLoader"), ), }, { @@ -37,7 +37,7 @@ const documentTabs = (prefix: string) => { Fallback: LinkCardSkeleton, Component: lazy( () => - import("../pages/organizations/documents/tabs/DocumentControlsTab"), + import("#/pages/organizations/documents/controls/DocumentControlsPageLoader"), ), }, {