Skip to content

Fix save button visibility on add planning screen to respect runtime permissions#3317

Merged
kbeaugrand merged 4 commits into
mainfrom
copilot/fix-add-planning-screen-save-button
Feb 6, 2026
Merged

Fix save button visibility on add planning screen to respect runtime permissions#3317
kbeaugrand merged 4 commits into
mainfrom
copilot/fix-add-planning-screen-save-button

Conversation

Copilot AI commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Description

The EditPlanning component requires a CanWrite parameter to conditionally render the save button. CreatePlanningsPage was not passing this parameter, causing the button to never display.

Initial fix hardcoded CanWrite="true", which bypassed permission validation. Users with revoked write permissions during an active session would still see the save button.

Changes:

  • Add dynamic permission check using HasPermissionAsync(PortalPermissions.PlanningWrite)
  • Pass result to EditPlanning component via CanWrite="@canWrite"
  • Aligns with pattern used in PlanningDetailsPage and PlanningListPage
 <EditPlanning planning=@Planning 
               scheduleList=@ScheduleList 
               mode="New"
-              CanWrite="true" />
+              CanWrite="@canWrite" />

 @code {
     protected override PortalPermissions[] RequiredPermissions 
         = { PortalPermissions.PlanningWrite };
+    private bool canWrite;
     
     protected override async Task OnInitializedAsync()
     {
         await base.OnInitializedAsync();
         // ... initialization ...
+        canWrite = await HasPermissionAsync(PortalPermissions.PlanningWrite);
     }
 }

Provides defense-in-depth: RequiredPermissions gates page access, HasPermissionAsync controls UI element visibility at runtime.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 5, 2026 13:59
…rameter

Co-authored-by: kbeaugrand <9513635+kbeaugrand@users.noreply.github.com>
…anningWrite permission

Co-authored-by: kbeaugrand <9513635+kbeaugrand@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix save button display issue on add planning screen Fix missing save button on add planning screen Feb 5, 2026
Copilot AI requested a review from kbeaugrand February 5, 2026 14:07
Co-authored-by: kbeaugrand <9513635+kbeaugrand@users.noreply.github.com>
Copilot AI changed the title Fix missing save button on add planning screen Fix save button visibility on add planning screen to respect runtime permissions Feb 6, 2026
@codecov

codecov Bot commented Feb 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.32%. Comparing base (d4fe118) to head (c08eb83).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3317   +/-   ##
=======================================
  Coverage   81.32%   81.32%           
=======================================
  Files         376      376           
  Lines       14396    14397    +1     
  Branches     1230     1230           
=======================================
+ Hits        11708    11709    +1     
  Misses       2308     2308           
  Partials      380      380           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kbeaugrand
kbeaugrand marked this pull request as ready for review February 6, 2026 07:09
@kbeaugrand
kbeaugrand requested a review from a team as a code owner February 6, 2026 07:09
Copilot AI review requested due to automatic review settings February 6, 2026 07:09

Copilot AI 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.

Pull request overview

This PR fixes a bug where the save button was not visible on the Create Planning page. The EditPlanning component requires a CanWrite parameter to conditionally render write-related UI elements, but CreatePlanningsPage was not passing this parameter.

Changes:

  • Added dynamic permission checking using HasPermissionAsync(PortalPermissions.PlanningWrite) to determine write permission at runtime
  • Passed the permission check result to the EditPlanning component via the CanWrite parameter
  • Added a test to verify the save button is displayed when users have write permissions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/IoTHub.Portal.Client/Pages/Planning/CreatePlanningsPage.razor Added canWrite field and dynamic permission check, passed to EditPlanning component
src/IoTHub.Portal.Tests.Unit/Client/Pages/Planning/CreatePlanningsPageTest.cs Added test to verify save button displays with write permissions

@kbeaugrand
kbeaugrand merged commit 2e3e75e into main Feb 6, 2026
12 checks passed
@kbeaugrand
kbeaugrand deleted the copilot/fix-add-planning-screen-save-button branch February 6, 2026 07:20
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.

3 participants