Skip to content

VPR-158 fix(raps): confirm role template saves and keep nav highlighted - #308

Open
rlorenzo wants to merge 2 commits into
mainfrom
fix/VPR-158-role-template-improvements
Open

VPR-158 fix(raps): confirm role template saves and keep nav highlighted#308
rlorenzo wants to merge 2 commits into
mainfrom
fix/VPR-158-role-template-improvements

Conversation

@rlorenzo

Copy link
Copy Markdown
Contributor

Fixes both defects reported in VPR-158.

What was wrong

  1. Saving roles on a template gave no feedback. The PUT was fired without
    being awaited and the page stayed put, so there was no way to tell the
    save had worked.
  2. The "Role Templates" left nav item was not highlighted while on the
    add-roles page. LeftNav/Default.cshtml matched by exact path only, and
    RoleTemplateRoles / RoleTemplateApply have no nav entry of their own.

Changes

  • NavMenuItem.ChildPageURLs lets a nav item declare pages it covers, and
    "Role Templates" declares RoleTemplateRoles and RoleTemplateApply.
  • Nav matching moved out of the Razor view into LeftNavHighlight so it is
    unit testable. 11 tests cover the new child-page case plus behaviour that
    already existed with no coverage: instance-link promotion, secondary
    highlight, query-string stripping, and /2 PathBase resolution.
  • Saving template roles awaits the PUT, then redirects to the listing with a
    queued success message (queueStatusNotification /
    showQueuedStatusNotification, because a toast cannot survive navigation).

Also included, beyond the ticket's scope

These are in this PR already. Calling them out because a reviewer expecting
only the two reported defects would otherwise be surprised by them.

  • Data-loss guard on TemplateRoles. If either initial GET failed,
    selectedRoles stayed empty and submitting sent an empty list, wiping the
    template's roles. With the new redirect that wipe would have been followed
    by a success message, so the guard became necessary rather than optional.
    Submit is now disabled until both reads succeed, mirroring the guard
    already in DelegateRoles.cshtml. This also removes a latent crash:
    .filter() was called on the result of a failed fetch.
  • DelegateRoles.cshtml had the identical missing-confirmation bug and
    is fixed the same way (message only; that page has no listing to return
    to).
  • eslint.config.mjs declares the two new JS globals. Without it the
    cshtml lint gate fails on no-undef.

Verification

  • 2720 backend tests pass, lint clean on all changed files.
  • Smoke tested against VMACS.VMTH: highlight correct on both child pages,
    RoleList unaffected, save redirects and the message renders with
    role="status" / aria-live="polite", 0 console errors. The submit used
    an unchanged selection so the PUT was a data no-op, confirmed afterwards
    by the template still holding its 7 roles.

CA1502 on RAPSController.Nav shows up in lint output. It reads 35 both
with and without this change, so it is pre-existing, not introduced here.

@codecov-commenter

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov-commenter

codecov-commenter commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.38889% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.83%. Comparing base (394ae2d) to head (9c35962).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
web/Areas/RAPS/Controllers/RAPSController.cs 0.00% 7 Missing ⚠️
web/Views/Shared/Components/LeftNav/Default.cshtml 0.00% 6 Missing ⚠️
web/Classes/LeftNavHighlight.cs 93.10% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #308      +/-   ##
==========================================
- Coverage   41.88%   41.83%   -0.05%     
==========================================
  Files         986      993       +7     
  Lines       49488    49735     +247     
  Branches     5843     5857      +14     
==========================================
+ Hits        20726    20806      +80     
- Misses      27852    28016     +164     
- Partials      910      913       +3     
Flag Coverage Δ
backend 39.89% <76.38%> (-0.05%) ⬇️
frontend 58.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
web/Areas/RAPS/Views/Roles/DelegateRoles.cshtml 0.00% <ø> (ø)
web/Areas/RAPS/Views/Roles/TemplateRoles.cshtml 0.00% <ø> (ø)
web/Areas/RAPS/Views/Roles/Templates.cshtml 0.00% <ø> (ø)
web/Classes/NavMenuItem.cs 100.00% <100.00%> (+20.00%) ⬆️
web/Classes/LeftNavHighlight.cs 93.10% <93.10%> (ø)
web/Views/Shared/Components/LeftNav/Default.cshtml 0.00% <0.00%> (ø)
web/Areas/RAPS/Controllers/RAPSController.cs 23.80% <0.00%> (-0.39%) ⬇️

... and 42 files with indirect coverage changes

@rlorenzo

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change centralizes left-navigation matching, adds child-page metadata, hardens RAPS role-loading and submission flows, and adds session-backed status notifications shown after redirects.

Changes

Navigation highlighting

Layer / File(s) Summary
Highlighting contract and matching
web/Classes/NavMenuItem.cs, web/Classes/LeftNavHighlight.cs, test/Classes/LeftNavHighlightTests.cs
NavMenuItem now supports child-page URLs. LeftNavHighlight.FindActive matches normalized relative and instance links. Tests cover URL forms, path bases, and invalid links.
Navigation rendering and RAPS wiring
web/Areas/RAPS/Controllers/RAPSController.cs, web/Views/Shared/Components/LeftNav/Default.cshtml
Role Templates child pages are registered. The shared view uses centralized active and secondary indices.

RAPS role interactions and notifications

Layer / File(s) Summary
Role loading and submission flow
web/Areas/RAPS/Views/Roles/DelegateRoles.cshtml, web/Areas/RAPS/Views/Roles/TemplateRoles.cshtml
Role requests run concurrently and deduplicate IDs. Submission remains disabled until loading succeeds and waits for successful updates.
Queued status notification flow
web/wwwroot/js/qtable.js, web/wwwroot/js/site.js, web/Areas/RAPS/Views/Roles/Templates.cshtml, eslint.config.mjs
Status messages persist in session storage, are consumed once during mounting, and use declared CSHTML globals.

Estimated code review effort: 4 (Complex) | ~45 minutes

Mergeability Score: 🟡 Moderate · up to bc07c

The PR improves role-template saving and navigation highlighting, but the current implementation can lose save confirmation when storage fails, render confirmation in an inaccessible form, and miss navigation highlighting for some deployed URL configurations. These bounded correctness and usability issues should be fixed before merging.

Sequence Diagram(s)

sequenceDiagram
  participant RolePage as RAPS role page
  participant Storage as sessionStorage
  participant Templates as Templates Vue app
  participant Renderer as status notification renderer
  RolePage->>Storage: queueStatusNotification(message)
  Templates->>Storage: showQueuedStatusNotification()
  Storage-->>Templates: retrieve and remove queued message
  Templates->>Renderer: display status notification
Loading

Suggested labels: javascript, .NET

Suggested reviewers: bsedwards, bniedzie

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes both primary fixes: role-save confirmation and persistent navigation highlighting.
Description check ✅ Passed The description directly explains the reported defects, implemented fixes, additional safeguards, and verification results.
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.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/VPR-158-role-template-improvements

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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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 `@web/Classes/LeftNavHighlight.cs`:
- Around line 71-75: Update the absolute-URL guard in the URL handling logic of
LeftNavHighlight so root-relative values beginning with "/" are excluded from
the Uri.TryCreate check. Continue rejecting empty and genuinely external
absolute URLs while allowing root-relative URLs to reach the existing matching
branch.

In `@web/Views/Shared/Components/LeftNav/Default.cshtml`:
- Line 7: Update the LeftNavHighlight.FindActive call to include
Request.PathBase together with Request.Path when constructing the request path
input, so it matches the application-base-prefixed paths returned by Url.Content
and correctly applies leftNavActiveSecondary.

In `@web/wwwroot/js/qtable.js`:
- Around line 38-42: The queued-message flow should return and clear the message
from showQueuedStatusNotification in web/wwwroot/js/qtable.js:38-42 without
calling showStatusNotification or creating global DOM. In
web/Areas/RAPS/Views/Roles/Templates.cshtml:150-150, consume that return value
into Vue app state and render it with q-banner, including role="status" and the
page’s accessible classes.
- Around line 30-31: Update queueStatusNotification to catch and suppress
failures from putItemInStorage, keeping notification persistence best effort so
callers can continue to location.href even when storage is unavailable.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7a39f6b9-211c-46d3-b430-877a0bfc47c2

📥 Commits

Reviewing files that changed from the base of the PR and between 21551ff and bc07c19.

📒 Files selected for processing (11)
  • eslint.config.mjs
  • test/Classes/LeftNavHighlightTests.cs
  • web/Areas/RAPS/Controllers/RAPSController.cs
  • web/Areas/RAPS/Views/Roles/DelegateRoles.cshtml
  • web/Areas/RAPS/Views/Roles/TemplateRoles.cshtml
  • web/Areas/RAPS/Views/Roles/Templates.cshtml
  • web/Classes/LeftNavHighlight.cs
  • web/Classes/NavMenuItem.cs
  • web/Views/Shared/Components/LeftNav/Default.cshtml
  • web/wwwroot/js/qtable.js
  • web/wwwroot/js/site.js

Comment thread web/Classes/LeftNavHighlight.cs
Comment thread web/Views/Shared/Components/LeftNav/Default.cshtml Outdated
Comment thread web/wwwroot/js/qtable.js Outdated
Comment thread web/wwwroot/js/qtable.js
@rlorenzo
rlorenzo force-pushed the fix/VPR-158-role-template-improvements branch from bc07c19 to 4bad52c Compare August 12, 2026 22:47
- Saving roles on a template now returns to the listing with a success
  message instead of silently staying put
- Role Templates stays highlighted on the edit and apply pages, which
  have no nav entry of their own, via NavMenuItem.ChildPageURLs
- Move nav match logic out of the Razor view into LeftNavHighlight so
  it is unit testable, and cover the existing instance-link behaviour
- Disable submit until both role reads succeed; a failed read left the
  selection empty and saving wiped the template's roles
- Apply the same missing-confirmation fix to the delegate roles page
@rlorenzo
rlorenzo force-pushed the fix/VPR-158-role-template-improvements branch from 4bad52c to f81b664 Compare August 13, 2026 01:16
- The guidelines named q-banner as the only way a Razor page shows a
  status message, so a reviewer reading them flags the established
  status toast as non-compliant, and a developer following them would
  build a banner where every existing call site uses a toast
- Record when each applies and why Notify cannot be used in the Razor
  pages, in both the bot-facing instructions and DESIGN.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants