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: remove StyleUtils #2550

Merged
merged 4 commits into from
Feb 27, 2023
Merged

refactor: remove StyleUtils #2550

merged 4 commits into from
Feb 27, 2023

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 26, 2023

Replace StyleUtils methods by direct calls: the methods were used only once, so this was an extra indirection (the inline code is explicit enough).

Extract only the getBpmnIsInstantiating function because it is used twice and make it internal.

It also changes the way we store bpmn.isInitiating in the mxGraph style. Previously, we stored the value from the BPMN Semantic as a string which required a subsequent parsing to know whether it was an "instantiate" value. This was also not consistent with the property name which suggests to store a boolean value.
We now store a boolean value which can be directly used in the Shapes implementation.


BREAKING CHANGES: StyleUtils may have been used in rare cases to redefine the way the shapes are rendered. It wasn't used in the examples of bpmn-visualization.
StyleUtils was mark as experimental and as subject to change as part of BPMN Theme refactoring. So users already knew that a deletion could take place.

Notes

This has been detected during the [email protected] migration POC: #2366

Replace `StyleUtils` methods by direct calls: the methods were used only once, so this was an extra indirection (the
inline code is explicit enough).

Extract only the `getBpmnIsInstantiating` function because it is used twice and make it internal.

It also changes the way we store `bpmn.isInitiating` in the mxGraph style.
Previously, we stored the value from the BPMN Semantic as a string which required a subsequent parsing to know whether
it was an "instantiate" value. This was also not consistent with the property name which suggests to store a boolean
value.
We now store a boolean value which can be directly used in the Shapes implementation.

--------------------------------------------------------------------------------
BREAKING CHANGES: `StyleUtils` may have been used in rare cases to redefine the way the shapes are rendered.
It wasn't used in the examples of `bpmn-visualization`.
@tbouffard tbouffard added the refactoring Code refactoring label Feb 26, 2023
@github-actions
Copy link

github-actions bot commented Feb 26, 2023

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

🤖 By surge-preview

@github-actions
Copy link

github-actions bot commented Feb 26, 2023

🎊 PR Preview 5022bdf has been successfully built and deployed to https://process-analytics-bpmn-visualization-js-doc_preview-pr-2550.surge.sh

🕐 Build time: 0.022s

🤖 By surge-preview

@tbouffard tbouffard marked this pull request as ready for review February 26, 2023 11:53
@tbouffard tbouffard requested a review from csouchet February 27, 2023 08:23
@@ -158,7 +158,7 @@ export default class StyleComputer {
}

computeMessageFlowIconStyle(edge: Edge): string {
return `shape=${BpmnStyleIdentifier.MESSAGE_FLOW_ICON};${BpmnStyleIdentifier.IS_INITIATING}=${edge.messageVisibleKind}`;
return `shape=${BpmnStyleIdentifier.MESSAGE_FLOW_ICON};${BpmnStyleIdentifier.IS_INITIATING}=${edge.messageVisibleKind === MessageVisibleKind.INITIATING}`;
Copy link
Member

Choose a reason for hiding this comment

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

issue (non-blocking):
In the BPMN specification, we can have 3 states for the messageVisibleKind: unspecified, initiating and non-initiating.

So we shouldn't add BpmnStyleIdentifier.IS_INITIATING to the style if messageVisibleKind is unspecified.

image

Copy link
Member Author

Choose a reason for hiding this comment

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

computeMessageFlowIconStyle is only called when we detect that a message flow icon must be drawn, so the check is not done here but in insertMessageFlowIconIfNeeded.

private insertMessageFlowIconIfNeeded(edge: Edge, mxEdge: mxCell): void {
if (edge.bpmnElement instanceof MessageFlow && edge.messageVisibleKind !== MessageVisibleKind.NONE) {
const cell = this.graph.insertVertex(mxEdge, messageFowIconId(mxEdge.id), undefined, 0, 0, 20, 14, this.styleComputer.computeMessageFlowIconStyle(edge));

With the old and new implementation, once the bpmn.isInitiating style is present, an icon is displayed (filled or not). Here, we only change how the information is stored, not when it is stored.

All tests including e2e visual an integration tests pass. They may miss some use cases related to the BPMN specification.
In that case, they must be added (both integration and visual tests) but only because, at present, we may not support the unspecified messageVisibleKind.

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I understand, we cover everything in the tests and in the implementation.
A MessageFlow always have the messageVisibleKind property set. NONE is set when it was undefined in the BPMN diagram.

const messageVisibleKind = edge.messageVisibleKind ? (edge.messageVisibleKind as unknown as MessageVisibleKind) : MessageVisibleKind.NONE;

Copy link
Member

Choose a reason for hiding this comment

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

I though when we compute the classes that we always added messageVisibleKind 😄 
It's ok for me like this 👍

# Conflicts:
#	test/unit/component/mxgraph/renderer/StyleComputer.test.ts
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

94.4% 94.4% Coverage
0.0% 0.0% Duplication

@tbouffard tbouffard merged commit 80c0279 into master Feb 27, 2023
@tbouffard tbouffard deleted the refactor/remove_StyleUtils branch February 27, 2023 13:56
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