-
Notifications
You must be signed in to change notification settings - Fork 76
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 useBpmnModeler #14464
Conversation
Warning Rate limit exceeded@TomasEng has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 44 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request introduces significant changes to the BPMN modeler management in the process editor. The modifications involve removing the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14464 +/- ##
==========================================
- Coverage 95.68% 95.68% -0.01%
==========================================
Files 1891 1889 -2
Lines 24588 24579 -9
Branches 2822 2822
==========================================
- Hits 23528 23519 -9
Misses 799 799
Partials 261 261 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
frontend/packages/process-editor/src/hooks/useBpmnEditor.ts (2)
101-101
: Consider updating the comment to reflect the singleton pattern.The change to use
BpmnModelerInstance.getInstance
is good, but the comment above could be updated to better explain the singleton pattern and why multiple instances should be avoided.- // GetModeler can only be fetched from this hook once since the modeler creates a - // new instance and will attach the same canvasRef container to all instances it fetches. + // BpmnModelerInstance follows the singleton pattern to ensure only one instance exists. + // Multiple instances would cause issues as they would attach to the same canvasRef container.
Line range hint
101-114
: Well-structured refactoring to singleton pattern.The transition from
useBpmnModeler
hook toBpmnModelerInstance
singleton is well-executed. This architectural change:
- Better reflects the single-instance nature of the BPMN modeler
- Maintains the same initialization and cleanup flow
- Removes unnecessary React hook abstraction
The refactoring improves code clarity without changing the core functionality.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
frontend/packages/process-editor/src/hooks/useBpmnEditor.ts
(3 hunks)frontend/packages/process-editor/src/hooks/useBpmnModeler/index.ts
(0 hunks)frontend/packages/process-editor/src/hooks/useBpmnModeler/useBpmnModeler.test.ts
(0 hunks)frontend/packages/process-editor/src/hooks/useBpmnModeler/useBpmnModeler.ts
(0 hunks)
💤 Files with no reviewable changes (3)
- frontend/packages/process-editor/src/hooks/useBpmnModeler/index.ts
- frontend/packages/process-editor/src/hooks/useBpmnModeler/useBpmnModeler.test.ts
- frontend/packages/process-editor/src/hooks/useBpmnModeler/useBpmnModeler.ts
🔇 Additional comments (2)
frontend/packages/process-editor/src/hooks/useBpmnEditor.ts (2)
3-3
: LGTM! Import statement aligns with the refactoring goal.The import of
BpmnModelerInstance
from utils is properly structured and aligns with the PR's objective of removing theuseBpmnModeler
hook.
114-114
: Verify cleanup implementation in BpmnModelerInstance.The change to use
BpmnModelerInstance.destroyInstance
is appropriate. Let's verify the implementation ensures proper cleanup.✅ Verification successful
✓ Cleanup implementation is correct
The
destroyInstance()
implementation properly cleans up resources by detaching the BPMN.js modeler and clearing the instance reference.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the destroyInstance implementation ast-grep --pattern 'class BpmnModelerInstance { $$$ static destroyInstance() { $$$ } $$$ }'Length of output: 105
Script:
#!/bin/bash # Find the file containing BpmnModelerInstance fd BpmnModelerInstance frontend/packages/process-editor/src # Once found, examine its content fd BpmnModelerInstance frontend/packages/process-editor/src -x cat {}Length of output: 1597
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
Description
The
useBpmnModeler
function is named and used as a React hook, although it's not a hook (it doesn't depend on any other hooks). It's just a wrapper around the staticBpmnModelerInstance
class, so we can just use the class directly. I have therefore deleteduseBpmnModeler
.I have added the
skip-manual-testing
label since this is just a refactor and the automated tests should be sufficient to verify this change.Related Issue(s)
Verification
Summary by CodeRabbit
Refactor
useBpmnModeler
hook and related test filesBreaking Changes
useBpmnModeler
hook will need to be updated