Skip to content

feat(data-modeling): export diagram to json COMPASS-9448 #7046

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 20 commits into from
Jun 24, 2025

Conversation

mabaasit
Copy link
Contributor

@mabaasit mabaasit commented Jun 20, 2025

Preview
Export.to.JSON.mov

Changes in toast

Before After
image image

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)

@github-actions github-actions bot added the feat label Jun 20, 2025
@mabaasit mabaasit added the no release notes Fix or feature not for release notes label Jun 20, 2025
@mabaasit mabaasit marked this pull request as ready for review June 20, 2025 10:56
@mabaasit mabaasit requested a review from a team as a code owner June 20, 2025 10:56

it('renders nothing if step is not EDITING', function () {
renderDiagramEditorToolbar({ step: 'ANALYSIS_CANCELED' });
expect(() => screen.getByTestId('diagram-editor-toolbar')).to.throw;
Copy link
Collaborator

Choose a reason for hiding this comment

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

throw needs to be called to assert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in b65f4c8

Comment on lines 102 to 106
<Radio value="json" aria-label="JSON">
<Icon glyph="CurlyBraces" />
{nbsp}
JSON
</Radio>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't match the designs where the icon is outside of the radio item, not sure if that's a deliberate choice not to follow the designs here. Also the alignments of items inside the label is slightly off, but catches the eye, in the designs everything is middle aligned, not baseline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed it as I was reusing some of the code from poc. I aligned it with the design in 6c41226

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how it looks now

image

Comment on lines 61 to 63
// TODO: Confirm all collections are selected by default (COMPASS-9309)
// Note: We'll need to change the UI, right now the labels are disconnected from the checkboxes
await browser.clickVisible(Selectors.CreateDataModelConfirmButton);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can count the checkboxes or check the <number> total collections selected text instead of waiting for this refactor

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 adc19a1

@paula-stacho
Copy link
Contributor

Small detail - the label isn't vertically aligned with the checkbox
Screenshot 2025-06-23 at 13 29 20

if (!exportFormat || !model) {
return;
}
exportToJson(diagramLabel, model);
Copy link
Member

@Anemy Anemy Jun 23, 2025

Choose a reason for hiding this comment

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

Should we try/catch this and show the error to the user? I'm wondering what happens if a user tries to save in a place where they might not have permissions or another error with file system saving that could happen like no space left.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that will be handled by the toasts which we show for file downloads as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's correct, both success and failure will be handled on the app level (for electron)

session.defaultSession.on(

link.click();
setTimeout(() => {
window.URL.revokeObjectURL(url);
link.remove();
Copy link
Member

Choose a reason for hiding this comment

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

Should we be showing a toast here? Or is that something that's planned in future work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are already showing toasts for all file downloads

Copy link
Contributor

Choose a reason for hiding this comment

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

This is using the browser download so it can benefit from the electron listeners we've added for Schema export. Added a section in our dev Q&A doc https://docs.google.com/document/d/1_yVsHyMwst62WsqcXaUkMIG4n5AwOBnqQzKQRR889Ig/edit?tab=t.0#heading=h.gr92v9azxldt

collections: Object.fromEntries(
collections.map((collection) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { displayPosition, indexes, ...restOfTheCollection } = collection;
Copy link
Contributor

@paula-stacho paula-stacho Jun 24, 2025

Choose a reason for hiding this comment

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

I wonder if we shouldn't whitelist the props that should be included instead of blacklisting like this. There is also shardKey and other stuff like samples would probably pop up here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that is better and i added it in 69e315f

Copy link
Contributor

@paula-stacho paula-stacho left a comment

Choose a reason for hiding this comment

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

🎉

@mabaasit mabaasit merged commit 7ac0cd8 into main Jun 24, 2025
53 of 56 checks passed
@mabaasit mabaasit deleted the COMPASS-9448-diagram-json-export branch June 24, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants