feat: introduce global config for the Entity Relation connector by tbouffard · Pull Request #620 · maxGraph/maxGraph · GitHub
Skip to content

feat: introduce global config for the Entity Relation connector#620

Merged
tbouffard merged 2 commits into
mainfrom
feat/configure_entity_relation_segment_default
Jan 7, 2025
Merged

feat: introduce global config for the Entity Relation connector#620
tbouffard merged 2 commits into
mainfrom
feat/configure_entity_relation_segment_default

Conversation

@tbouffard

@tbouffard tbouffard commented Jan 6, 2025

Copy link
Copy Markdown
Member

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

coderabbitai Bot commented Jan 6, 2025

Copy link
Copy Markdown

@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

🧹 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
@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