Better handling of document versions

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-08 15:12:06 +02:00
parent 81e7cd3574
commit a43328560a
12 changed files with 621 additions and 83 deletions

View File

@@ -3,6 +3,7 @@ import { graphql } from "relay-runtime";
import { useMutationWithToasts } from "../useMutationWithToasts";
import type { DocumentGraphDeleteMutation } from "./__generated__/DocumentGraphDeleteMutation.graphql";
import type { DocumentGraphSendSigningNotificationsMutation } from "./__generated__/DocumentGraphSendSigningNotificationsMutation.graphql";
import type { DocumentGraphDeleteDraftMutation } from "./__generated__/DocumentGraphDeleteDraftMutation.graphql";
export const documentsQuery = graphql`
query DocumentGraphListQuery($organizationId: ID!) {
@@ -13,15 +14,14 @@ export const documentsQuery = graphql`
}
`;
export const DocumentsConnectionKey = "DocumentsPageFragment_documents";
export const DocumentsConnectionKey = "DocumentsListQuery_documents";
const deleteDocumentMutation = graphql`
mutation DocumentGraphDeleteMutation(
$input: DeleteDocumentInput!
$connections: [ID!]!
) {
deleteDocument(input: $input) {
deletedDocumentId @deleteEdge(connections: $connections)
deletedDocumentId @deleteRecord
}
}
`;
@@ -38,6 +38,29 @@ export function useDeleteDocumentMutation() {
);
}
const deleteDraftDocumentVersionMutation = graphql`
mutation DocumentGraphDeleteDraftMutation(
$input: DeleteDraftDocumentVersionInput!
$connections: [ID!]!
) {
deleteDraftDocumentVersion(input: $input) {
deletedDocumentVersionId @deleteEdge(connections: $connections)
}
}
`;
export function useDeleteDraftDocumentVersionMutation() {
const { __ } = useTranslate();
return useMutationWithToasts<DocumentGraphDeleteDraftMutation>(
deleteDraftDocumentVersionMutation,
{
successMessage: __("Draft deleted successfully."),
errorMessage: __("Failed to delete draft. Please try again."),
}
);
}
const sendSigningNotificationsMutation = graphql`
mutation DocumentGraphSendSigningNotificationsMutation(
$input: SendSigningNotificationsInput!

View File

@@ -0,0 +1,132 @@
/**
* @generated SignedSource<<f114dd31b601c0097380450ab5029b01>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type DeleteDraftDocumentVersionInput = {
documentVersionId: string;
};
export type DocumentGraphDeleteDraftMutation$variables = {
connections: ReadonlyArray<string>;
input: DeleteDraftDocumentVersionInput;
};
export type DocumentGraphDeleteDraftMutation$data = {
readonly deleteDraftDocumentVersion: {
readonly deletedDocumentVersionId: string;
};
};
export type DocumentGraphDeleteDraftMutation = {
response: DocumentGraphDeleteDraftMutation$data;
variables: DocumentGraphDeleteDraftMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "deletedDocumentVersionId",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "DocumentGraphDeleteDraftMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteDraftDocumentVersionPayload",
"kind": "LinkedField",
"name": "deleteDraftDocumentVersion",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "DocumentGraphDeleteDraftMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteDraftDocumentVersionPayload",
"kind": "LinkedField",
"name": "deleteDraftDocumentVersion",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "deleteEdge",
"key": "",
"kind": "ScalarHandle",
"name": "deletedDocumentVersionId",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "cd7e8253362e1d7e719e4ae2c206756e",
"id": null,
"metadata": {},
"name": "DocumentGraphDeleteDraftMutation",
"operationKind": "mutation",
"text": "mutation DocumentGraphDeleteDraftMutation(\n $input: DeleteDraftDocumentVersionInput!\n) {\n deleteDraftDocumentVersion(input: $input) {\n deletedDocumentVersionId\n }\n}\n"
}
};
})();
(node as any).hash = "d43940b41e3838fd03c3341c13b4c5c5";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<64c2c92a2a0806f34243f8fc9904167c>>
* @generated SignedSource<<6b7916e6ff46a629bf97a7b072db2d8b>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -13,7 +13,6 @@ export type DeleteDocumentInput = {
documentId: string;
};
export type DocumentGraphDeleteMutation$variables = {
connections: ReadonlyArray<string>;
input: DeleteDocumentInput;
};
export type DocumentGraphDeleteMutation$data = {
@@ -27,24 +26,21 @@ export type DocumentGraphDeleteMutation = {
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
var v0 = [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
}
],
v1 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v3 = {
v2 = {
"alias": null,
"args": null,
"kind": "ScalarField",
@@ -53,23 +49,20 @@ v3 = {
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "DocumentGraphDeleteMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"args": (v1/*: any*/),
"concreteType": "DeleteDocumentPayload",
"kind": "LinkedField",
"name": "deleteDocument",
"plural": false,
"selections": [
(v3/*: any*/)
(v2/*: any*/)
],
"storageKey": null
}
@@ -79,37 +72,27 @@ return {
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "DocumentGraphDeleteMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"args": (v1/*: any*/),
"concreteType": "DeleteDocumentPayload",
"kind": "LinkedField",
"name": "deleteDocument",
"plural": false,
"selections": [
(v3/*: any*/),
(v2/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "deleteEdge",
"handle": "deleteRecord",
"key": "",
"kind": "ScalarHandle",
"name": "deletedDocumentId",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
"name": "deletedDocumentId"
}
],
"storageKey": null
@@ -127,6 +110,6 @@ return {
};
})();
(node as any).hash = "355f3a70caecabb2146075657665633e";
(node as any).hash = "471020248ed9d398ab80655e04cb823d";
export default node;