Skip to content
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

Update entity relationship diagram to use new renderer #5965

Merged
merged 49 commits into from
Mar 13, 2025

Conversation

yari-dewalt
Copy link
Collaborator

@yari-dewalt yari-dewalt commented Oct 15, 2024

📑 Summary

Updates the er diagram to the new unified way of rendering. Includes a new "erBox" shape to be used in diagrams as well as some other updates to bring it to the same level as the other diagrams including: support for styling nodes, the handDrawn look, the introduction of the classDef statement and class styling, support for styling the default class, support for unicode text and markdown formatting, and direction statements. Adds tests for all the new features and new rendered version.

📏 Design Decisions

  • The erDb gathers the necessary data and passes it to the v3 unified renderer.
  • The erBox shape is kind of complicated due to the placement and possibility of different text (attributes) and so it utilizes a helper text creation function (includes workaround for < and > syntax conflicts)
  • The style statement works the same as it does in other diagrams.
  • The classDef statement also works similarly as it does in other diagrams and defines a class that can be used in the diagram (either via the shorthand ::: or a class statement).
  • Style, classDef, and class statements, as well as the shorthand, are able to take in a list of ids (e.g. style entity1, entity2 color:red | classDef class1, class2 stroke:pink | class entity1, entity2 myClass | entity1:::class1,class2)
  • The erDiagram markers have been transitioned into the updated version.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Copy link

changeset-bot bot commented Oct 15, 2024

⚠️ No Changeset found

Latest commit: 00ca7ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 00ca7ac
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/67c20a047581630008a78b48
😎 Deploy Preview https://deploy-preview-5965--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Oct 16, 2024

Open in Stackblitz

npm i https://pkg.pr.new/mermaid-js/mermaid@5965
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@5965
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@5965
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@5965

commit: 00ca7ac

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 0.14771% with 676 lines in your changes missing coverage. Please review.

Project coverage is 3.84%. Comparing base (bc2bd3d) to head (00ca7ac).
Report is 64 commits behind head on develop.

Files with missing lines Patch % Lines
.../rendering-util/rendering-elements/shapes/erBox.ts 0.00% 282 Missing ⚠️
packages/mermaid/src/diagrams/er/erDb.ts 0.00% 193 Missing ⚠️
...d/src/rendering-util/rendering-elements/markers.js 0.00% 119 Missing ⚠️
...ages/mermaid/src/diagrams/er/erRenderer-unified.ts 0.00% 45 Missing ⚠️
packages/mermaid/src/diagrams/er/styles.ts 0.00% 23 Missing ⚠️
packages/mermaid/src/diagrams/er/erDiagram.ts 0.00% 6 Missing ⚠️
...rc/rendering-util/rendering-elements/edgeMarker.ts 0.00% 4 Missing ⚠️
...rc/rendering-util/layout-algorithms/dagre/index.js 0.00% 2 Missing ⚠️
...id/src/rendering-util/rendering-elements/shapes.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #5965      +/-   ##
==========================================
- Coverage     3.88%   3.84%   -0.05%     
==========================================
  Files          398     402       +4     
  Lines        42044   42603     +559     
  Branches       638     641       +3     
==========================================
+ Hits          1635    1636       +1     
- Misses       40409   40967     +558     
Flag Coverage Δ
unit 3.84% <0.14%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/config.type.ts 100.00% <ø> (ø)
packages/mermaid/src/diagrams/er/erTypes.ts 100.00% <100.00%> (ø)
...rc/rendering-util/layout-algorithms/dagre/index.js 0.00% <0.00%> (ø)
...id/src/rendering-util/rendering-elements/shapes.ts 0.24% <0.00%> (-0.01%) ⬇️
...rc/rendering-util/rendering-elements/edgeMarker.ts 2.08% <0.00%> (-0.19%) ⬇️
packages/mermaid/src/diagrams/er/erDiagram.ts 8.33% <0.00%> (-1.67%) ⬇️
packages/mermaid/src/diagrams/er/styles.ts 0.00% <0.00%> (ø)
...ages/mermaid/src/diagrams/er/erRenderer-unified.ts 0.00% <0.00%> (ø)
...d/src/rendering-util/rendering-elements/markers.js 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/er/erDb.ts 0.00% <0.00%> (ø)
... and 1 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

argos-ci bot commented Oct 16, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 17 changed, 581 added, 455 removed Feb 28, 2025, 7:25 PM

Copy link
Contributor

@jgreywolf jgreywolf left a comment

Choose a reason for hiding this comment

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

Couple of small comments to start :)

@yari-dewalt
Copy link
Collaborator Author

E2E tests failing because of screenshot capacity

An error was thrown in your plugins file while executing the handler for the after:run event.

The error we received was:

Error: You have reached the maximum screenshot capacity included in your Pro open source xl Plan. Please upgrade your Plan.
at throwAPIError (file:///__w/mermaid/mermaid/node_modules/.pnpm/@argos-ci+api-client@0.5.0/node_modules/@argos-ci/api-client/dist/index.mjs:28:15)
at upload (file:///__w/mermaid/mermaid/node_modules/.pnpm/@argos-ci+core@2.8.1/node_modules/@argos-ci/core/dist/index.mjs:886:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object. (file:///__w/mermaid/mermaid/node_modules/.pnpm/@argos-ci+cypress@2.2.2_cypress@13.15.0/node_modules/@argos-ci/cypress/dist/task.mjs:32:21)
at async Object.handlerThatCallsUserDefinedHandler [as handler] (/__w/mermaid/mermaid/node_modules/.pnpm/@applitools+eyes-cypress@3.44.9_encoding@0.1.13_typescript@5.4.5/node_modules/@applitools/eyes-cypress/dist/plugin/pluginExport.js:105:21)
Test run failed, code 1
More information might be available above
Cypress module has returned the following error message:
Could not find Cypress test run results
Error: Could not find Cypress test run results

@ashishjain0512
Copy link
Collaborator

@yari-dewalt See review comments from Applitools

@yari-dewalt
Copy link
Collaborator Author

@ashishjain0512
Took a look and fixed the label background and dotted edges stroke. I can't replicate the long text getting cut off. Currently working on the styling of the rows

@yari-dewalt
Copy link
Collaborator Author

@ashishjain0512 Styling of the rows now alternates between light and dark dependent on the theme. Previously it was dependent on specific theme variables attributeBackgroundColorOdd and attributeBackgroundColorEven however it looks like some were missing. I opted to use the secondaryColor and tertiaryColor variables from the themes so it's consistent or should we still use the previous variables and now expand it to make sure it works for every theme that didn't have it? We would have to come up with more colors

Before After

@ashishjain0512 ashishjain0512 merged commit 00ca7ac into mermaid-js:develop Mar 13, 2025
21 of 22 checks passed
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.

4 participants