[PR #1100] [MERGED] fix: update document deletion logic #1385

Closed
opened 2026-02-26 19:33:01 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1100
Author: @dguyen
Created: 4/11/2024
Status: Merged
Merged: 4/19/2024
Merged by: @dguyen

Base: mainHead: fix/document-deletion


📝 Commits (4)

📊 Changes

20 files changed (+644 additions, -207 deletions)

View changed files

📝 apps/marketing/src/app/(marketing)/singleplayer/client.tsx (+1 -0)
📝 apps/web/src/app/(dashboard)/documents/[id]/document-page-view-dropdown.tsx (+17 -13)
📝 apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (+5 -2)
📝 apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx (+22 -19)
📝 apps/web/src/app/(dashboard)/documents/data-table.tsx (+1 -1)
📝 apps/web/src/app/(dashboard)/documents/delete-document-dialog.tsx (+73 -33)
📝 apps/web/src/app/(dashboard)/documents/documents-page-view.tsx (+3 -1)
📝 apps/web/src/app/(dashboard)/documents/empty-state.tsx (+4 -1)
📝 packages/app-tests/e2e/document-flow/signers-step.spec.ts (+2 -2)
📝 packages/app-tests/e2e/document-flow/stepper-component.spec.ts (+1 -1)
📝 packages/app-tests/e2e/documents/delete-documents.spec.ts (+157 -15)
packages/app-tests/e2e/fixtures/documents.ts (+17 -0)
📝 packages/app-tests/e2e/teams/team-documents.spec.ts (+115 -26)
📝 packages/email/template-components/template-document-cancel.tsx (+4 -0)
📝 packages/lib/server-only/document/delete-document.ts (+133 -64)
📝 packages/lib/server-only/document/find-documents.ts (+48 -7)
📝 packages/lib/server-only/document/get-stats.ts (+9 -2)
packages/prisma/migrations/20240408142543_add_recipient_document_delete/migration.sql (+13 -0)
📝 packages/prisma/schema.prisma (+18 -17)
📝 packages/ui/primitives/document-flow/add-signers.tsx (+1 -3)

📄 Description

Description

Full rework on how documents are deleted.

Deleting a document as owner

Draft: Hard deleted
Pending: Hard deleted & emails sent out to all recipients
Completed: Soft deleted

Deleting a document as a recipient

Draft: N/A
Pending: Document will be hidden from recipient
Completed: Document will be hidden from recipient

🚨🚨 Migrations 🚨🚨

The following custom SQL migrations have been added:

  • Delete all pending documents that have been soft deleted
  • Documents that the owner has soft deleted AND are also a recipient will automatically be hidden from them
  • New documentDeletedAt field on Recipient model

Document owner or team member perspective

Draft document

image

Pending document

image

Completed document

image

Recipient perspective

Pending

image

Completed

image

Testing Performed

  • Added E2E tests
  • Manually tested to ensure recipients can still see completed documents that have been deleted by the owner until they themselves delete it

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced email notifications for document deletion.
    • Added a new field to track the deletion time of documents.
    • Enhanced document management capabilities with updated permission checks.
    • New visual indicator ("Document deleted" badge) for deleted documents.
  • Enhancements

    • Improved user interface for document actions based on user permissions and document status.
    • Updated document-related components to include team email information.
  • Bug Fixes

    • Refined document deletion logic to respect user permissions and team associations.
  • Tests

    • Enhanced end-to-end tests to include checks for document tab counts and deletion scenarios.
  • Refactor

    • Streamlined conditions in document flow components.
    • Refined backend logic for document retrieval and statistics calculation.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1100 **Author:** [@dguyen](https://github.com/dguyen) **Created:** 4/11/2024 **Status:** ✅ Merged **Merged:** 4/19/2024 **Merged by:** [@dguyen](https://github.com/dguyen) **Base:** `main` ← **Head:** `fix/document-deletion` --- ### 📝 Commits (4) - [`ba7d937`](https://github.com/documenso/documenso/commit/ba7d937e425468d3a37780f32774bcc630fd7f0a) fix: update document deletion logic - [`c5e202e`](https://github.com/documenso/documenso/commit/c5e202ec62a1688cce74fd21ac1131d6334848bc) fix: tests - [`fe639bd`](https://github.com/documenso/documenso/commit/fe639bd04960140af3f5805f42044b9f8956e909) fix: refactor - [`ae8385a`](https://github.com/documenso/documenso/commit/ae8385a84e692b521ee9a7839faf431347788434) fix: update email template ### 📊 Changes **20 files changed** (+644 additions, -207 deletions) <details> <summary>View changed files</summary> 📝 `apps/marketing/src/app/(marketing)/singleplayer/client.tsx` (+1 -0) 📝 `apps/web/src/app/(dashboard)/documents/[id]/document-page-view-dropdown.tsx` (+17 -13) 📝 `apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx` (+5 -2) 📝 `apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx` (+22 -19) 📝 `apps/web/src/app/(dashboard)/documents/data-table.tsx` (+1 -1) 📝 `apps/web/src/app/(dashboard)/documents/delete-document-dialog.tsx` (+73 -33) 📝 `apps/web/src/app/(dashboard)/documents/documents-page-view.tsx` (+3 -1) 📝 `apps/web/src/app/(dashboard)/documents/empty-state.tsx` (+4 -1) 📝 `packages/app-tests/e2e/document-flow/signers-step.spec.ts` (+2 -2) 📝 `packages/app-tests/e2e/document-flow/stepper-component.spec.ts` (+1 -1) 📝 `packages/app-tests/e2e/documents/delete-documents.spec.ts` (+157 -15) ➕ `packages/app-tests/e2e/fixtures/documents.ts` (+17 -0) 📝 `packages/app-tests/e2e/teams/team-documents.spec.ts` (+115 -26) 📝 `packages/email/template-components/template-document-cancel.tsx` (+4 -0) 📝 `packages/lib/server-only/document/delete-document.ts` (+133 -64) 📝 `packages/lib/server-only/document/find-documents.ts` (+48 -7) 📝 `packages/lib/server-only/document/get-stats.ts` (+9 -2) ➕ `packages/prisma/migrations/20240408142543_add_recipient_document_delete/migration.sql` (+13 -0) 📝 `packages/prisma/schema.prisma` (+18 -17) 📝 `packages/ui/primitives/document-flow/add-signers.tsx` (+1 -3) </details> ### 📄 Description ## Description Full rework on how documents are deleted. ### Deleting a document as owner **Draft:** Hard deleted **Pending:** Hard deleted & emails sent out to all recipients **Completed:** Soft deleted ### Deleting a document as a recipient **Draft:** N/A **Pending:** Document will be hidden from recipient **Completed:** Document will be hidden from recipient ## 🚨🚨 Migrations 🚨🚨 The following custom SQL migrations have been added: - Delete all pending documents that have been soft deleted - Documents that the owner has soft deleted AND are also a recipient will automatically be hidden from them - New `documentDeletedAt` field on `Recipient` model ## Document owner or team member perspective ### Draft document <img width="551" alt="image" src="https://github.com/documenso/documenso/assets/20962767/f621198e-b5d0-4a7b-9d6c-4d66715214ea"> ### Pending document <img width="541" alt="image" src="https://github.com/documenso/documenso/assets/20962767/b2cda152-51ac-416a-963a-84730ba5a5d7"> ### Completed document <img width="551" alt="image" src="https://github.com/documenso/documenso/assets/20962767/fb71062c-628e-41c0-8f29-a1c0bdbae0cb"> ## Recipient perspective ### Pending <img width="551" alt="image" src="https://github.com/documenso/documenso/assets/20962767/a448e0e2-600f-4274-aa6e-cc077fca1cfe"> ### Completed <img width="551" alt="image" src="https://github.com/documenso/documenso/assets/20962767/90596d3a-cc97-4232-a1ca-1d84ffcf20cd"> ## Testing Performed - Added E2E tests - Manually tested to ensure recipients can still see **completed** documents that have been deleted by the owner until they themselves delete it ## Checklist - [X] I have tested these changes locally and they work as expected. - [X] I have added/updated tests that prove the effectiveness of these changes. - [X] I have updated the documentation to reflect these changes, if applicable. - [X] I have followed the project's coding style guidelines. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Introduced email notifications for document deletion. - Added a new field to track the deletion time of documents. - Enhanced document management capabilities with updated permission checks. - New visual indicator ("Document deleted" badge) for deleted documents. - **Enhancements** - Improved user interface for document actions based on user permissions and document status. - Updated document-related components to include team email information. - **Bug Fixes** - Refined document deletion logic to respect user permissions and team associations. - **Tests** - Enhanced end-to-end tests to include checks for document tab counts and deletion scenarios. - **Refactor** - Streamlined conditions in document flow components. - Refined backend logic for document retrieval and statistics calculation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:33:01 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1385
No description provided.