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: simplify shapes registration #3045

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 26, 2024

The private method that registered the shapes was a pure function, so it had been extracted from the ShapeConfigurator class.
The registration code has also been simplified to better reflect a configuration pattern (less explicit calls to the mxGraph registration code).

Notes

Part of initiative including #3041, #3042 and #3043 (more to come).

The private method that registered the shapes was a pure function, so it had been extracted from the ShapeConfigurator
class.
The registration code has also been simplified to better reflect a configuration pattern (less explicit calls to the
mxGraph registration code).
@tbouffard tbouffard added the refactoring Code refactoring label Feb 26, 2024
Copy link

github-actions bot commented Feb 26, 2024

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

🤖 By surge-preview

Copy link

github-actions bot commented Feb 26, 2024

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

🤖 By surge-preview

@@ -36,47 +38,53 @@ import { ComplexGatewayShape, EventBasedGatewayShape, ExclusiveGatewayShape, Inc
import { TextAnnotationShape } from '../shape/text-annotation-shapes';
import { BpmnStyleIdentifier } from '../style';

const registerShapes = (): void => {
Copy link
Member Author

@tbouffard tbouffard Feb 26, 2024

Choose a reason for hiding this comment

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

thought: the shapes are registered in a global state in mxGraph, so bpmn-visualization currently registers the same shapes at every instantiation of the BpmnVisualization class.

We could register the shapes only once.
This is what is done in maxGraph: https://github.com/maxGraph/maxGraph/blob/v0.8.0/packages/core/src/view/cell/register-shapes.ts#L36-L43

@tbouffard tbouffard marked this pull request as ready for review March 1, 2024 08:33
@tbouffard tbouffard requested a review from csouchet March 1, 2024 08:34
Copy link

sonarqubecloud bot commented Mar 1, 2024

@tbouffard tbouffard merged commit 1f1f232 into master Mar 1, 2024
23 checks passed
@tbouffard tbouffard deleted the refactor/shapes_registration branch March 1, 2024 10:06
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