Skip to content

feat(data-modeling): download diagram COMPASS-9545 #7116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 17, 2025

Conversation

mabaasit
Copy link
Contributor

Added an option to download a data-model. It saves file as diagram-name.compass

Preview
Download.Diagram.mov

Description

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 09:48
@mabaasit mabaasit requested a review from a team as a code owner July 16, 2025 09:48
@github-actions github-actions bot added the feat label Jul 16, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a download feature for data models in Compass, allowing users to save diagrams as .compass files containing the diagram name and edit history. The implementation includes both the core functionality and comprehensive end-to-end testing.

  • Adds a download button to the diagram editor toolbar that exports the current diagram state
  • Implements file download functionality that saves diagrams with their edit history as JSON
  • Enhances the download status notification system with better toast management

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/compass/src/app/application.tsx Improves download completion toast handling with proper cleanup
packages/compass-data-modeling/src/store/diagram.ts Adds downloadDiagram action to export current diagram edits
packages/compass-data-modeling/src/services/export-diagram.tsx Implements exportEdits function for downloading diagram data as JSON
packages/compass-data-modeling/src/components/diagram-editor-toolbar.tsx Adds download button to the editor toolbar
packages/compass-data-modeling/src/components/diagram-editor-toolbar.spec.tsx Adds unit tests for the new download button functionality
packages/compass-data-modeling/src/store/export-diagram.ts Refactors model selection to only execute when needed for JSON export
packages/compass-e2e-tests/tests/data-modeling-tab.test.ts Adds comprehensive e2e test for download functionality and refactors node movement logic
packages/compass-e2e-tests/helpers/selectors.ts Adds selector for the new download button
packages/compass-e2e-tests/helpers/downloads.ts Improves error messaging for file download timeouts

@@ -63,12 +64,21 @@ describe('DiagramEditorToolbar', function () {
});
});

it('renders export buttona and calls onExportClick', function () {
it('renders export button and calls onExportClick', function () {
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

Fixed typo in test description - changed 'export buttona' to 'export button'.

Copilot uses AI. Check for mistakes.

@mabaasit mabaasit added feature flagged PRs labeled with this label will not be included in the release notes of the next release no release notes Fix or feature not for release notes labels Jul 16, 2025
Comment on lines 159 to 162
const json = { name: fileName, edits };
const blob = new Blob([JSON.stringify(json, null, 2)], {
type: 'application/json',
});
Copy link
Collaborator

@gribnoysup gribnoysup Jul 16, 2025

Choose a reason for hiding this comment

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

I think we discussed adding a version field here and maybe it's a good idea to completely obscure the content with something simple like base64-ing the the whole string? In the spirit of making it not easily parseable by users at all

Copy link
Collaborator

@gribnoysup gribnoysup Jul 16, 2025

Choose a reason for hiding this comment

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

Also maybe type: 'DataModel' in case we want to use .compass extension for some other saved items in compass and would want to differentiate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch - yeah, will do that. i forgot adding fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in 1cfac05

@mabaasit mabaasit merged commit 16b18d1 into main Jul 17, 2025
59 checks passed
@mabaasit mabaasit deleted the COMPASS-9545-save-diagram branch July 17, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat feature flagged PRs labeled with this label will not be included in the release notes of the next release no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants