Skip to content

feat: add attachments support for single page exports - #1440

Merged
Philipinho merged 3 commits into
mainfrom
fix/export-attachment
Aug 4, 2025
Merged

Philipinho merged 3 commits into
mainfrom
fix/export-attachment

Conversation

@Philipinho

@Philipinho Philipinho commented Aug 3, 2025 •

Copy link
Copy Markdown
Member
  • Add includeAttachments option to page export modal and API
  • Fix internal page url in single page exports in cloud

Summary by CodeRabbit

  • New Features

    • Added an option in the page export modal to include or exclude attachments when exporting a page.
    • Users can now control attachment inclusion using a toggle switch in the export interface.
  • Refactor

    • Improved export functionality to handle both single page and multi-page (with children) exports through a unified process.
    • Streamlined export response to always deliver a ZIP file for page exports.
  • Bug Fixes

    • Enhanced error handling for cases where a single page cannot be found during export.

- Add includeAttachments option to page export modal and API
- Fix internal page url in single page exports in cloud
@coderabbitai

coderabbitai Bot commented Aug 3, 2025 •

Copy link
Copy Markdown

Walkthrough

The changes introduce an option to include or exclude attachments when exporting pages. This is implemented by adding a UI switch in the export modal, updating the export parameter types and DTOs, and refactoring the backend export logic to support the new includeAttachments flag. Related service and controller logic were consolidated and updated accordingly.

Changes

Cohort / File(s) Change Summary
Export Modal UI Update
apps/client/src/components/common/export-modal.tsx
Added a switch to toggle attachment inclusion in page export; initial state for attachments set to false; export handler updated to pass includeAttachments flag.
Removed Old Page Export Modal
apps/client/src/features/page/components/page-export-modal.tsx
Deleted the previous modal component for page export, which handled format selection, subpage inclusion, and export actions.
Type Definitions Update
apps/client/src/features/page/types/page.types.ts
Added optional includeAttachments boolean to IExportPageParams interface.
DTO Update
apps/server/src/integrations/export/dto/export-dto.ts
Added optional includeAttachments boolean property to ExportPageDto with validation decorators.
Controller Refactor
apps/server/src/integrations/export/export.controller.ts
Refactored exportPage to always call exportPages with new parameters; simplified response to always return ZIP; removed dynamic content type logic.
Service Refactor & API Change
apps/server/src/integrations/export/export.service.ts
Renamed and expanded exportPageWithChildren to exportPages with new parameters; updated zipPages to require explicit includeAttachments; added error handling for missing pages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ExportModal
    participant BackendAPI
    participant ExportController
    participant ExportService

    User->>ExportModal: Opens export modal
    ExportModal->>User: Shows attachments switch (default: off)
    User->>ExportModal: Selects options, toggles attachments, clicks Export
    ExportModal->>BackendAPI: POST /exportPage (includeAttachments flag)
    BackendAPI->>ExportController: Receives request
    ExportController->>ExportService: Calls exportPages(pageId, format, includeAttachments, includeChildren)
    ExportService->>ExportService: Builds page tree, zips pages (with/without attachments)
    ExportService-->>ExportController: Returns ZIP buffer
    ExportController-->>BackendAPI: Sends ZIP file response
    BackendAPI-->>ExportModal: Receives ZIP file
    ExportModal-->>User: Triggers file download
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops with glee and pride,
Attachments now can come—or hide!
With switches flipped and logic neat,
The export’s power is complete.
Zip your pages, big or small—
With or without files, you have it all!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b43658 and 36183b9.

📒 Files selected for processing (1)
  • apps/client/src/components/common/export-modal.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/client/src/components/common/export-modal.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/export-attachment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
apps/client/src/components/common/export-modal.tsx (1)

44-44: Fix inconsistent state reset logic.

The reset logic sets includeAttachments to true after export, but the initial state is false. This creates inconsistent behavior where the toggle would unexpectedly change after each export.

Apply this diff to maintain consistent state:

-      setIncludeAttachments(true);
+      setIncludeAttachments(false);
🧹 Nitpick comments (1)
apps/server/src/integrations/export/export.service.ts (1)

98-114: Consider using consistent exception types.

The conditional logic is clear and well-implemented. However, consider using NotFoundException instead of BadRequestException for missing pages to maintain consistency with other parts of the codebase (like line 50 in the controller).

-        throw new BadRequestException('Page not found');
+        throw new NotFoundException('Page not found');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1615e0f and c62512e.

📒 Files selected for processing (6)
  • apps/client/src/components/common/export-modal.tsx (2 hunks)
  • apps/client/src/features/page/components/page-export-modal.tsx (0 hunks)
  • apps/client/src/features/page/types/page.types.ts (1 hunks)
  • apps/server/src/integrations/export/dto/export-dto.ts (1 hunks)
  • apps/server/src/integrations/export/export.controller.ts (1 hunks)
  • apps/server/src/integrations/export/export.service.ts (4 hunks)
💤 Files with no reviewable changes (1)
  • apps/client/src/features/page/components/page-export-modal.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (11)
apps/client/src/features/page/types/page.types.ts (1)

82-82: LGTM!

The optional includeAttachments property is properly typed and follows the established pattern of other optional properties in the interface.

apps/server/src/integrations/export/dto/export-dto.ts (1)

27-29: LGTM!

The includeAttachments property is properly validated with appropriate decorators and maintains consistency with the existing code style.

apps/client/src/components/common/export-modal.tsx (3)

32-32: LGTM!

Defaulting includeAttachments to false is a reasonable choice that allows users to opt-in to including attachments.


38-38: LGTM!

The includeAttachments parameter is correctly passed to the exportPage function call.


100-110: LGTM!

The UI control for toggling attachment inclusion is well-implemented and follows the established pattern of other export options.

apps/server/src/integrations/export/export.controller.ts (2)

58-63: LGTM!

The refactoring to use a unified exportPages method with explicit parameters is cleaner and more maintainable than the previous conditional logic.


65-73: LGTM!

Consistently returning ZIP files simplifies the response handling and aligns with the unified export approach.

apps/server/src/integrations/export/export.service.ts (4)

92-97: LGTM!

The method rename and explicit parameters improve clarity and maintainability. The signature clearly indicates what options are available.


127-127: LGTM!

Passing the includeAttachments parameter explicitly improves method clarity and removes ambiguity about default behavior.


190-190: LGTM!

Making the includeAttachments parameter explicit instead of defaulting to true is a good improvement that makes the method behavior more predictable.


222-224: LGTM!

The formatting change improves readability while maintaining the same functionality.

@Philipinho
Philipinho merged commit dddfd48 into main Aug 4, 2025
github-actions Bot added a commit to antiagingrecord/docmost that referenced this pull request Oct 9, 2025
4231ba9 Merge commit '042836cb6d7cc1f71af3ce44c7957f8abbbf8f25' into feat/aar_edition
042836c sync
4f1f0ba fix
3164b69 feat: api keys management (EE) (docmost#1665)
16c1e86 fix comment space
c9b1cad sync
bf8cf62 feat: Typesense search driver (EE) (docmost#1664)
5a2e16a Merge commit '31350303760163384113bf49d07127e886f94907' into feat/aar_edition
3bc710d Adds CLAUDE.md documentation
16914f1 Block search for non-indexed shares
ca75e29 Set default page mode to Read
3135030 fix editor converter (docmost#1647)
3fae41a fix: editor performance improvements (docmost#1648)
b50e256 sync
1f3b0c7 cloud fix
3c4cab0 v0.23.2
4de25a8 invalidate queries on space deletion
cf5bbb1 fix import html processing
ac17521 sync
9ac180f fix: enhance page import (docmost#1570)
46669fe (cloud) disable page sharing in trial mode
fe6ecdf fix: update combobox props in SpaceSelect component (docmost#1564)
04ae1d7 Allow lastColumnResizable in table
1280f96 feat: implement space and workspace icons (docmost#1558)
61d1cf8 fix: reset file inputs after import
f413720 - sync - reinstantiate S3 client to fix file upload errors during import - delete import zip file after use
8e16ad9 v0.23.1
7ada3cb fix: page import task (docmost#1551)
47c5417 sync
dc06502 sync
091e790 fix attachment search in cloud
ae24ea2 v0.23.0
9df6061 lock file
31053e2 update mermaid
eb8e850 use debug
c99bfb8 make print better
26ea04e sync
6cc58c5 sync
7d2ff34 UI fixes
b08d37f fix
d43ee77 remove debug log
5d91eb4 feat: queue imported attachments for indexing
3e9f6b1 Remove version from docker-compose.yml [deprecated] (docmost#1011)
db55de9 feat: progressive web app (docmost#614)
1919eba New Crowdin updates (docmost#1522)
7951b2e New Crowdin updates (docmost#1509)
73b78f6 more translations
cf7534d fix version display
adec36d fix: adjust margins - use default browser highlight background
f9e1080 sync
00e499b Fixing extra page bug on print (docmost#1478)
5ee6e46 checkbox aligned to text (docmost#1486)
1f797c3 fix: confluence drawio import (docmost#1518)
f12866c feat(EE): full-text search in attachments (docmost#1502)
dcbb65d feat(EE): LDAP integration (docmost#1515)
5968764 feat: emoji callout icon (docmost#1323)
242fb6b fix: set mermaid theme based on computed color scheme (docmost#1438)
74cd890 feat(EE): implement SSO group sync for SAML and OIDC (docmost#1452)
509622a ignore type error
937386e fix: hide table handles in readonly mode
60a373f fix: readonly editor table responsiveness
73ee6ee feat: subpages (child pages) list node (docmost#1462)
7d1e5bc feat: table row/column drag and drop (docmost#1467)
aa58e27 fix: exclude deleted pages (docmost#1494)
08135a2 sync
d92a942 sync
5012a68 sync
5a33777 feat: debug mode env variable (docmost#1450)
3b85f4b fix: enforce C collation for page position ordering to ensure consistent behavior in Postgres 17+ (docmost#1446)
cb2a039 fix: invalidate trashed page from tree state
95b7be6 fix: hide trash from can view permission (docmost#1445)
b0c5572 fix nested taskList in markdown export (docmost#1443)
dddfd48 feat: add attachments support for single page exports (docmost#1440)
aa6eec7 fix: exclude trashed pages from position generation
97a7701 fix local storage copy function (docmost#1442)
b97eb85 sync

git-subtree-dir: vendor/app
git-subtree-split: 4231ba9
@Philipinho
Philipinho deleted the fix/export-attachment branch December 14, 2025 19:07
nulluserid pushed a commit to N2con-Inc/docmost that referenced this pull request Dec 17, 2025
* feat: add attachments support for single page exports
- Add includeAttachments option to page export modal and API
- Fix internal page url in single page exports in cloud

* remove redundant line

* preserve export state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant