Skip to content

refactor: inject IconPainter in Shapes#3042

Merged
tbouffard merged 3 commits into
masterfrom
refactor/inject_icon_painter
Mar 1, 2024
Merged

refactor: inject IconPainter in Shapes#3042
tbouffard merged 3 commits into
masterfrom
refactor/inject_icon_painter

Conversation

@tbouffard

@tbouffard tbouffard commented Feb 22, 2024

Copy link
Copy Markdown
Member

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
@github-actions

github-actions Bot commented Feb 22, 2024

Copy link
Copy Markdown

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

🤖 By surge-preview

@github-actions

github-actions Bot commented Feb 22, 2024

Copy link
Copy Markdown

♻️ 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
@sonarqubecloud

sonarqubecloud Bot commented Mar 1, 2024

Copy link
Copy Markdown

@tbouffard tbouffard merged commit 9c8cb9a into master Mar 1, 2024
@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