Skip to content

[NAE-2463] Builder change localStorage sets#341

Merged
mazarijuraj merged 5 commits into
release/6.5.0from
NAE-2463
Jul 17, 2026
Merged

[NAE-2463] Builder change localStorage sets#341
mazarijuraj merged 5 commits into
release/6.5.0from
NAE-2463

Conversation

@Kovy95

@Kovy95 Kovy95 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

  • change the setting and getting properties from localStorage
  • fix the change detection bug
  • fix the problem with sending two requests to backend

Fixes NAE-2463

Dependencies

no new dependencies

Third party dependencies

  • No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

manually

Test Configuration

Name Tested on
OS linux mint 21
Runtime node 20.18.0
Dependency Manager npm 10.8.2
Framework version angular 17
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • New Features
    • Builder dialogs and views now persist role/user, role master-detail, master-detail, and history sort preferences using tab/workflow-scoped local storage.
    • Builder data saving/loading now exposes loading status and improves update coordination; model/xml saving is included consistently.
  • Bug Fixes
    • Improved editor stability by guarding SVG/canvas updates when rendering isn’t ready.
    • Sorting state restores more reliably across sessions and histories.
  • Style
    • Updated modeler edit-mode to use OnPush change detection for performance consistency.
  • Tests
    • Adjusted builder test setups and imports to include the new local storage support.

- change the setting and getting properties from localStorage
- fix the change detection bug
- fix the problem with sending two requests on backend
@Kovy95 Kovy95 self-assigned this Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR relocates builder service imports, adds prefixed LocalStorageService persistence, updates builder integration loading and error handling, wires storage dependencies, and adjusts change detection, canvas registration, SVG coordinates, and an example import.

Changes

Builder services refactor and LocalStorage integration

Layer / File(s) Summary
Prefixed local storage and persistence wiring
projects/netgrif-components/src/lib/builder/services/local-storage.service.ts, projects/netgrif-components/src/lib/builder/dialogs/..., projects/netgrif-components/src/lib/builder/modeler/...
Adds prefixed storage access and uses it for role, master-detail, history, and permissions persistence.
Builder integration request state
projects/netgrif-components/src/lib/builder/services/builder-integration.service.ts
Adds loading accessors, overlap prevention, xml_text submission, and error handling.
Service import relocation
projects/netgrif-components/src/lib/builder/**/*.ts, projects/netgrif-components/src/lib/builder/**/*.spec.ts
Updates builder service imports and the public re-export to use services/ paths.
Component and canvas updates
projects/nae-example-app/src/app/doc/builder-example/*, projects/netgrif-components/src/lib/builder/modeler/edit-mode/*, projects/netgrif-components/src/lib/builder/modeler/services/canvas/canvas-mode-service.ts
Changes change-detection settings, guards canvas registration, defaults nullish arc coordinates, and consolidates the Case import.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: bugfix, improvement, new feature, Large, Medium

Sequence Diagram(s)

sequenceDiagram
  participant BuilderView
  participant BuilderIntegrationService
  participant LocalStorageService
  participant StorageOrAPI
  BuilderView->>BuilderIntegrationService: submit builder model data
  BuilderIntegrationService->>BuilderIntegrationService: set loading state
  BuilderIntegrationService->>StorageOrAPI: send model data and xml_text
  StorageOrAPI-->>BuilderIntegrationService: success or error
  BuilderIntegrationService->>BuilderIntegrationService: clear loading state
  BuilderView->>LocalStorageService: read or write scoped builder settings
  LocalStorageService->>StorageOrAPI: access prefixed local storage key
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main change: updating builder localStorage handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added bugfix improvement New feature or request Medium labels Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts (1)

337-346: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Guard the zero-length case before computing the arc ratio. ?? never applies here because finalX/finalY are always numbers, so arcLength === 0 can still propagate NaN into the SVG points attribute. Handle arcLength <= 0 explicitly and fall back to the intersection point.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts`
around lines 337 - 346, Guard the zero-length case in moveTemporaryArc before
calculating arcRatio, since finalX/finalY are always numbers and the current
fallback does not prevent NaN. In edit-mode.service.ts, update the
moveTemporaryArc logic to check arcLength <= 0 after computing the intersection
and, in that case, set the SVG points to the intersection point directly instead
of deriving the arrow position.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@projects/netgrif-components/src/lib/builder/services/builder-integration.service.ts`:
- Around line 99-101: The loading$ getter in BuilderIntegrationService is
exposing the internal LoadingEmitter directly instead of a read-only Observable,
unlike reloadCase$ and reloadModes$. Update loading$ to return the observable
view via asObservable() so callers can subscribe but cannot invoke next() on the
private emitter.

In
`@projects/netgrif-components/src/lib/builder/services/local-storage.service.ts`:
- Around line 18-20: The LocalStorageService.getItem method currently promises a
string but delegates to localStorage.getItem, which can return null. Update the
getItem signature to return string | null and make sure any callers of
LocalStorageService.getItem handle the nullable result correctly; use the
getItem method and _prefix field as the main reference points when adjusting the
API.

---

Outside diff comments:
In
`@projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts`:
- Around line 337-346: Guard the zero-length case in moveTemporaryArc before
calculating arcRatio, since finalX/finalY are always numbers and the current
fallback does not prevent NaN. In edit-mode.service.ts, update the
moveTemporaryArc logic to check arcLength <= 0 after computing the intersection
and, in that case, set the SVG points to the intersection point directly instead
of deriving the arrow position.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d163ce73-6957-4cf4-998e-4e4fc379bc21

📥 Commits

Reviewing files that changed from the base of the PR and between 6a78c83 and 20e9445.

📒 Files selected for processing (41)
  • projects/nae-example-app/src/app/doc/builder-example/builder-tabbed-case-view/builder-tabbed-case-view.component.ts
  • projects/nae-example-app/src/app/doc/builder-example/builder-tabs-example.component.ts
  • projects/netgrif-components/src/lib/builder/builder.component.spec.ts
  • projects/netgrif-components/src/lib/builder/builder.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-manage-roles/dialog-manage-roles.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-model-edit/dialog-model-edit.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-transition-edit/dialog-transition-edit.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/edit-panel/edit-panel.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/edit-panel/edit-panel.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/field-list/field-list.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/field-list/field-list.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/form-builder.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/form-builder.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/gridster/gridster.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/gridster/gridster.component.ts
  • projects/netgrif-components/src/lib/builder/form-builder/info-label/info-label.component.spec.ts
  • projects/netgrif-components/src/lib/builder/form-builder/info-label/info-label.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/actions-mode/actions-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/control-panel/control-panel.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/data-mode/data-detail/data-detail.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/data-mode/data-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/context-menu/menu-items/transition/edit-form-menu-item.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/context-menu/menu-items/transition/edit-transition-actions-menu-item.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/canvas-tool-context.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/canvas-tool.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/select-tool.ts
  • projects/netgrif-components/src/lib/builder/modeler/history-mode/history-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/model-import-service.ts
  • projects/netgrif-components/src/lib/builder/modeler/modeler.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/role-mode/role-detail/role-detail.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/role-mode/role-master-detail.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/services/canvas/canvas-mode-service.ts
  • projects/netgrif-components/src/lib/builder/modeler/services/history/history.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/task-mode/task-mode.component.ts
  • projects/netgrif-components/src/lib/builder/public-api.ts
  • projects/netgrif-components/src/lib/builder/services/builder-integration.service.ts
  • projects/netgrif-components/src/lib/builder/services/builder-mode.service.spec.ts
  • projects/netgrif-components/src/lib/builder/services/builder-mode.service.ts
  • projects/netgrif-components/src/lib/builder/services/local-storage.service.ts

Comment thread projects/netgrif-components/src/lib/builder/services/local-storage.service.ts Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 7, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 8, 2026
Retoocs
Retoocs previously approved these changes Jul 8, 2026
@Kovy95
Kovy95 dismissed stale reviews from Retoocs and coderabbitai[bot] via cf5567e July 16, 2026 10:43
@coderabbitai coderabbitai Bot added the Large label Jul 16, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts (1)

348-348: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Replace nullish coalescing with logical OR to correctly handle NaN.

Arithmetic operations on numbers (such as calculating finalX and finalY) evaluate to numbers or NaN, but never to null or undefined. Because the nullish coalescing operator (??) does not catch NaN values, an edge case where arcLength is 0 will still produce NaN and generate invalid SVG coordinates like NaN,NaN.

Using the logical OR operator (||) successfully falls back to 0 when encountering NaN.

🐛 Proposed fix
-        arcLine.setAttributeNS(null, 'points', `${intersect.x},${intersect.y} ${finalX ?? 0},${finalY ?? 0}`);
+        arcLine.setAttributeNS(null, 'points', `${intersect.x},${intersect.y} ${finalX || 0},${finalY || 0}`);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts`
at line 348, Replace the nullish coalescing operators for finalX and finalY in
the arcLine.setAttributeNS call with logical OR fallbacks so NaN values become
0. Preserve the existing SVG points format and intersect coordinates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts`:
- Line 348: Replace the nullish coalescing operators for finalX and finalY in
the arcLine.setAttributeNS call with logical OR fallbacks so NaN values become
0. Preserve the existing SVG points format and intersect coordinates.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6c6245b1-7c52-4305-9494-73dbd11dd044

📥 Commits

Reviewing files that changed from the base of the PR and between cf5567e and 945f9dd.

📒 Files selected for processing (7)
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-manage-roles/dialog-manage-roles.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-model-edit/dialog-model-edit.component.ts
  • projects/netgrif-components/src/lib/builder/dialogs/dialog-transition-edit/dialog-transition-edit.component.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/context-menu/menu-items/model/manage-model-permissions-menu-item.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/context-menu/menu-items/transition/edit-transition-permissions-menu-item.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/edit-mode.service.ts
  • projects/netgrif-components/src/lib/builder/modeler/edit-mode/services/modes/canvas-tool-context.ts

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
26.4% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

@mazarijuraj
mazarijuraj merged commit 718ca0b into release/6.5.0 Jul 17, 2026
9 of 11 checks passed
@mazarijuraj
mazarijuraj deleted the NAE-2463 branch July 17, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants