Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Jan 6, 2025

Previously, it was not possible to update the “segment” default value globally.
This is now possible, as is resetting the value to the maxGraph default.

Notes

Covers #192

Summary by CodeRabbit

  • New Features

    • Introduced EntityRelationConnectorConfig for customizing Entity Relation connector styles
    • Added resetEntityRelationConnectorConfig function to reset connector configuration
  • Documentation

    • Updated documentation to explain new global configuration options for Entity Relation connectors
  • Refactor

    • Improved segment length configuration handling for Entity Relation connectors
    • Updated import and configuration management across multiple files

Previously, it was not possible to update the “segment” default value globally.
This is now possible, as is resetting the value to the maxGraph default.
@tbouffard tbouffard added the enhancement New feature or request label Jan 6, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2025

Walkthrough

This pull request introduces a new configuration mechanism for Entity Relation connectors in the maxGraph library. The changes include creating a new EntityRelationConnectorConfig configuration object, adding a reset function, and updating various files to use this new configuration approach. The modifications provide more flexible handling of the segment length for Entity Relation connectors across different parts of the library.

Changes

File Change Summary
packages/core/src/index.ts Added new export for style configuration
packages/core/src/util/Constants.ts Updated comment for ENTITY_SEGMENT constant
packages/core/src/view/style/config.ts Added EntityRelationConnectorConfig and resetEntityRelationConnectorConfig
packages/core/src/view/style/edge/EntityRelation.ts Updated import and segment calculation logic
packages/html/.storybook/preview.ts Added resetEntityRelationConnectorConfig() to reset function
packages/html/stories/Folding.stories.ts Updated segment configuration method
packages/website/docs/usage/global-configuration.md Added documentation for new configuration options

Possibly related PRs

Suggested labels

documentation


📜 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 bd13aa2 and f6a61ce.

📒 Files selected for processing (1)
  • packages/html/stories/Folding.stories.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/html/stories/Folding.stories.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/html/.storybook/preview.ts (1)

6-6: Use consistent naming for import statements.
While this import is valid, ensure that naming and ordering align with the rest of your styling for consistency and readability.

packages/core/src/view/style/config.ts (1)

17-33: Consider using a type definition for EntityRelationConnectorConfig.
Defining an explicit interface could improve TypeScript IntelliSense and prevent accidental property name changes.

-export const EntityRelationConnectorConfig = {
+interface EntityRelationConnectorConfigType {
+  segment: number;
+}
+
+export const EntityRelationConnectorConfig: EntityRelationConnectorConfigType = {
   segment: ENTITY_SEGMENT,
 };
packages/html/stories/Folding.stories.ts (1)

21-21: Ensure consistent grouping of imports.
EntityRelationConnectorConfig is an experimental feature. Consider grouping these imports under a commented remark to indicate their status.

packages/website/docs/usage/global-configuration.md (1)

17-17: Fix markdown list indentation.

The unordered lists have incorrect indentation. According to markdownlint, the indentation should be 0 instead of 2 spaces.

Apply this diff to fix the indentation:

-  - `EntityRelationConnectorConfig` (since 0.15.0): for the `EntityRelation` Connector/EdgeStyle.
+- `EntityRelationConnectorConfig` (since 0.15.0): for the `EntityRelation` Connector/EdgeStyle.

-  - `resetEntityRelationConnectorConfig` (since 0.15.0)
+- `resetEntityRelationConnectorConfig` (since 0.15.0)

Also applies to: 27-27

🧰 Tools
🪛 Markdownlint (0.37.0)

17-17: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a46cbab and bd13aa2.

📒 Files selected for processing (7)
  • packages/core/src/index.ts (1 hunks)
  • packages/core/src/util/Constants.ts (1 hunks)
  • packages/core/src/view/style/config.ts (1 hunks)
  • packages/core/src/view/style/edge/EntityRelation.ts (2 hunks)
  • packages/html/.storybook/preview.ts (2 hunks)
  • packages/html/stories/Folding.stories.ts (2 hunks)
  • packages/website/docs/usage/global-configuration.md (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/core/src/util/Constants.ts
🧰 Additional context used
🪛 Markdownlint (0.37.0)
packages/website/docs/usage/global-configuration.md

17-17: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


27-27: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (10)
packages/html/.storybook/preview.ts (1)

23-23: Validate reset order or potential side effects.
Adding resetEntityRelationConnectorConfig after resetEdgeHandlerConfig() is fine, but verify there isn't a dependency on any prior reset calls that might alter the default connector state.

packages/core/src/view/style/config.ts (2)

1-15: License header compliance confirmed.
The file appropriately includes the Apache License header, adhering to open-source standards.


35-45: Sufficient documentation for reset function.
The reset execution path is straightforward and documented. Ensure to keep it in sync if new fields are added to EntityRelationConnectorConfig.

packages/core/src/view/style/edge/EntityRelation.ts (3)

22-22: Confirm usage of DIRECTION_MASK.
Although no issues are apparent here, verify that it is necessary for your logic. Otherwise, consider importing only what you use.


25-25: Good use of the configuration object.
This import aligns with the new global config changes.


35-36: Nullable style check is correct.
Using state.style?.segment is a best practice to avoid runtime errors if style is undefined.

packages/html/stories/Folding.stories.ts (1)

49-49: Globally modifying the config at story level.
Altering EntityRelationConnectorConfig.segment within a Story might carry over to subsequent stories if not reset. Validate or call a reset function as a cleanup step.

packages/website/docs/usage/global-configuration.md (2)

17-17: LGTM! Documentation clearly describes the new configuration.

The addition of EntityRelationConnectorConfig is well-documented and properly versioned.

🧰 Tools
🪛 Markdownlint (0.37.0)

17-17: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


27-27: LGTM! Reset function properly documented.

The addition of resetEntityRelationConnectorConfig complements the configuration object.

🧰 Tools
🪛 Markdownlint (0.37.0)

27-27: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

packages/core/src/index.ts (1)

162-162: LGTM! Export statement correctly placed.

The new export for style configuration is well-placed among other style-related exports and follows the established pattern.

@tbouffard tbouffard merged commit 1fa79e2 into main Jan 7, 2025
1 check passed
@tbouffard tbouffard deleted the feat/configure_entity_relation_segment_default branch January 7, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant