Skip to content

Commit 2e3e75e

Browse files
Copilotkbeaugrand
andcommitted
Fix: Use dynamic permission check for CanWrite instead of hardcoded true
Co-authored-by: kbeaugrand <9513635+kbeaugrand@users.noreply.github.com>
1 parent b227172 commit 2e3e75e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/IoTHub.Portal.Client/Pages/Planning/CreatePlanningsPage.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
@attribute [Authorize]
66

77
<AuthorizedContent IsLoading="@IsLoading" IsAuthorized="@IsAuthorized">
8-
<EditPlanning planning=@Planning scheduleList=@ScheduleList mode="New" CanWrite="true" />
8+
<EditPlanning planning=@Planning scheduleList=@ScheduleList mode="New" CanWrite="@canWrite" />
99
</AuthorizedContent>
1010

1111
@code {
1212
// Specify which permissions are required for this page
1313
protected override PortalPermissions[] RequiredPermissions { get; } = { PortalPermissions.PlanningWrite };
14+
private bool canWrite;
1415

1516
public List<ScheduleDto> ScheduleList { get; set; } = new List<ScheduleDto> { };
1617
public PlanningDto Planning { get; set; } = new PlanningDto();
@@ -21,5 +22,8 @@
2122

2223
Planning.DayOff = DaysEnumFlag.DaysOfWeek.Saturday | DaysEnumFlag.DaysOfWeek.Sunday;
2324
ScheduleList.Add(new ScheduleDto { Start = "00:00" });
25+
26+
// Check if user has write permission for conditional UI elements
27+
canWrite = await HasPermissionAsync(PortalPermissions.PlanningWrite);
2428
}
2529
}

0 commit comments

Comments
 (0)