Skip to content

refactor(graph): move the cell, validation and overlay members to their mixins - #1134

Draft
redfish4ktc wants to merge 1 commit into
refactor/move_viewport_translation_to_panning_mixinfrom
refactor/move_cells_validation_overlays_members_to_mixins
Draft

refactor(graph): move the cell, validation and overlay members to their mixins#1134
redfish4ktc wants to merge 1 commit into
refactor/move_viewport_translation_to_panning_mixinfrom
refactor/move_cells_validation_overlays_members_to_mixins

Conversation

@redfish4ktc

Copy link
Copy Markdown
Member

Note

Stacked on top of #1132, which is itself stacked on #1131. The base of this PR is refactor/move_viewport_translation_to_panning_mixin, so the diff shown here contains only this step.

Third implementation step of the plan recorded in ADR 0003 (#1130). No behavior change, and the public API is unchanged.

Problem

AbstractGraph holds members whose only consumers live in an existing mixin. Each of them forces that mixin to declare the member as an external dependency in its Pick<AbstractGraph, ...> list, which makes the list describe the class rather than the concern.

Changes

Target Members Only internal callers
CellsMixin defaultOverlap, getOverlap, isAllowOverlapParent, exportEnabled, isExportEnabled, importEnabled, isImportEnabled, recursiveResize, isRecursiveResize, setRecursiveResize resizeCells, canExportCell, canImportCell, constrainChild
ValidationMixin multigraph, isMultigraph, setMultigraph, allowLoops, isAllowLoops, setAllowLoops, alreadyConnectedResource, containsValidationErrorsResource and their getters getEdgeValidationError, validateCell
OverlaysMixin getWarningImage setCellWarning

The dependency lists shrink accordingly: CellsMixin stops declaring getOverlap, isRecursiveResize, isExportEnabled and isImportEnabled as external, and ValidationMixin stops declaring isAllowLoops, isMultigraph and the two resource getters.

AbstractGraph.ts loses 143 lines and its last use of isI18nEnabled.

One deliberate asymmetry

getWarningImage moves to OverlaysMixin but warningImage stays in AbstractGraph, in the per-instance group introduced in #1131. Its default is a mutable Image, so installing it on the prototype would share one instance across every graph, which is the failure mode the tests in #1131 now guard against.

The getter and its property are therefore split on purpose. They will be reunited when OverlaysMixin becomes a plugin, since plugins are instantiated per graph and the constraint disappears. This is step 6 of the ADR plan.

API note

Four of the moved accessors were arrow function properties and become prototype methods: isExportEnabled, isImportEnabled, getAlreadyConnectedResource and getContainsValidationErrorsResource.

Calling them on the graph is unaffected. Only detached references break, and TypeScript will not report it since both forms share the same type. The changelog entry introduced in #1132 for the scrollbar getters is extended to cover these four.

Validation

Run locally on Node 24 (.nvmrc): build, test-check, the full suite (505 tests, 60 suites), lint, check:circular-dependencies. All passing, and no test needed changing, which is the expected signal for a pure relocation.

@redfish4ktc redfish4ktc added the refactor Code refactoring label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f0a9587-2f09-4036-a489-7d6de3115b46

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ir mixins

Continue emptying AbstractGraph of members whose only consumers live in an existing mixin. Each move puts a member next
to the code that already uses it, and turns the mixin dependency lists into an accurate description of what each concern
actually needs: CellsMixin stops declaring getOverlap, isRecursiveResize, isExportEnabled and isImportEnabled as
external dependencies, and ValidationMixin stops declaring isAllowLoops, isMultigraph and the two resource getters.

To CellsMixin, whose resizeCells, canExportCell, canImportCell and constrainChild are the only internal callers:
defaultOverlap, getOverlap, isAllowOverlapParent, exportEnabled, isExportEnabled, importEnabled, isImportEnabled,
recursiveResize, isRecursiveResize and setRecursiveResize.

To ValidationMixin, whose getEdgeValidationError and validateCell are the only internal callers: multigraph,
isMultigraph, setMultigraph, allowLoops, isAllowLoops, setAllowLoops, and the alreadyConnectedResource and
containsValidationErrorsResource keys with their getters.

To OverlaysMixin, whose setCellWarning is the only consumer: getWarningImage. The warningImage property itself stays in
AbstractGraph, in the per-instance group, because its default is a mutable Image that would be shared across every graph
instance if it were installed on the prototype. The getter and its property are therefore split on purpose, until the
mixin becomes a plugin and the constraint disappears.

AbstractGraph loses 143 lines and its last use of isI18nEnabled. The public API is unchanged, mixin members are merged
into the AbstractGraph interface by declaration merging.

Four accessors were arrow function properties and become prototype methods, so detached references now need an explicit
bind. The changelog entry added for the scrollbar getters is extended to cover them.
@tbouffard
tbouffard force-pushed the refactor/move_cells_validation_overlays_members_to_mixins branch from 0aeaa4f to a8714bc Compare August 12, 2026 04:50
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant