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

refactor: inject IconPainter in Shapes #3042

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 22, 2024

Previously, the shapes relied on IconPainterProvider to get the IconPainter instance. This instance is now injected at shape instantiation by BpmnCellRenderer. This reduces the adherence to a global state.

This is a first step to remove the IconPainterProvider global state. This may be done later as it would imply to:

  • introduce a new configuration options, for example a render.iconPainter property
  • change how the BpmnGraph is initialized and configured
  • manage the breaking changes introduced by the provider removal

Minor functional change

Previously, when a shape was rendered, the current instance of the IconPainter was injected. If, between two renders, a new instance of IconPainter was configured via IconPainterProvider, it was used in the next render. This was a side-effect, not a desired feature, and was not documented.
The interest is limited: we haven't yet seen a use case that requires it. The existing example of modifying the user task icon doesn't need it: in this case, we still want to display the customized icon.

With the changes proposed here, the behavior is modified. The IconPainter instance is defined when the library is initialized, so its modification in IconPainterProvider only applies to new instances of the library. All rendering of a shape will always use the IconPainter instance defined when the library was initialized.

Previously, the shapes relied on `IconPainterProvider` to get the `IconPainter` instance. This instance is now injected
at shape instantiation by `BpmnCellRenderer`. This reduces the adherence to a global state.

This is a first step to remove the `IconPainterProvider` global state. This may be done later as it would imply to:
  - introduce a new configuration options, for example a `render.iconPainter` property
  - change how the `BpmnGraph` is initialized and configured
  - manage the breaking changes introduced by the provider removal
@tbouffard tbouffard added the refactoring Code refactoring label Feb 22, 2024
Copy link

github-actions bot commented Feb 22, 2024

♻️ PR Preview d9055bd has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link

github-actions bot commented Feb 22, 2024

♻️ PR Preview d9055bd has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@tbouffard tbouffard changed the title refactor: inject IconPainter when possible refactor: inject IconPainter in Shapes Feb 22, 2024
@tbouffard tbouffard requested a review from csouchet March 1, 2024 08:31
@tbouffard tbouffard marked this pull request as ready for review March 1, 2024 08:31
Copy link

sonarqubecloud bot commented Mar 1, 2024

@tbouffard tbouffard merged commit 9c8cb9a into master Mar 1, 2024
23 checks passed
@tbouffard tbouffard deleted the refactor/inject_icon_painter branch March 1, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants