Files
oqtane.framework/Oqtane.Client/Modules/Controls/TabPanel.razor
Leigh Pointer 01ad99b925 Enhance tab authorization with role and permission checks #5872
Add RoleName and PermissionName parameters to TabPanel for fine-grained tab visibility control. Update IsAuthorized logic in TabStrip to prioritize Host/Admin access, then check SecurityAccessLevel, and additionally require specified roles or permissions if provided. Removes redundant Admin/Host checks from the switch statement for clarity.
2025-12-13 18:13:37 +01:00

53 lines
1.4 KiB
Plaintext

@namespace Oqtane.Modules.Controls
@inherits LocalizableComponent
@if (Name == Parent.ActiveTab)
{
<div id="@(Parent.Id + Name)" class="tab-pane fade show active" role="tabpanel">
@ChildContent
</div>
}
else
{
<div id="@(Parent.Id + Name)" class="tab-pane fade" role="tabpanel">
@ChildContent
</div>
}
@code {
[CascadingParameter]
private TabStrip Parent { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public string Name { get; set; } // required - name of the TabPanel
[Parameter]
public string Heading { get; set; } // optional - defaults to name if not specified
[Parameter]
public SecurityAccessLevel? Security { get; set; } // optional - can be used to specify SecurityAccessLevel
[Parameter]
public string RoleName { get; set; } // optional - can be used to specify Role allowed to view this tab
[Parameter]
public string PermissionName { get; set; } // optional - can be used to specify Permission allowed to view this tab
protected override void OnParametersSet()
{
base.OnParametersSet();
Parent.AddTabPanel((TabPanel)this);
Heading = string.IsNullOrEmpty(Heading) ? Localize(nameof(Name), Name) : Localize(nameof(Heading), Heading);
}
public string DisplayHeading()
{
return (string.IsNullOrEmpty(Heading)) ? Name : Heading;
}
}