Fix save button visibility on add planning screen to respect runtime permissions#3317
Merged
Merged
Conversation
…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
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
kbeaugrand
approved these changes
Feb 6, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
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
EditPlanningcomponent via theCanWriteparameter - 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
EditPlanningcomponent requires aCanWriteparameter to conditionally render the save button.CreatePlanningsPagewas 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:
HasPermissionAsync(PortalPermissions.PlanningWrite)EditPlanningcomponent viaCanWrite="@canWrite"PlanningDetailsPageandPlanningListPage<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:
RequiredPermissionsgates page access,HasPermissionAsynccontrols UI element visibility at runtime.What kind of change does this PR introduce?
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.