Skip to content

Commit

Permalink
🆕 feat(PermissionView): add FallbackContent to PermissionView (#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Jul 2, 2024
1 parent af96e03 commit e6cd691
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Masa.Blazor/Components/PermissionView/PermissionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class PermissionView : ComponentBase
[Parameter]
public RenderFragment? ChildContent { get; set; }

[Parameter]
public RenderFragment? FallbackContent { get; set; }

[Parameter, EditorRequired]
public string Code { get; set; } = null!;

Expand All @@ -37,13 +40,11 @@ protected override async Task OnInitializedAsync()

protected override void BuildRenderTree(RenderTreeBuilder builder)
{
if (User == null || Validator == null)
if (User == null || Validator == null || !Validator.Validate(Code, User))
{
return;
builder.AddContent(0, FallbackContent);
}

var valid = Validator.Validate(Code, User);
if (valid)
else
{
builder.AddContent(0, ChildContent);
}
Expand Down

0 comments on commit e6cd691

Please sign in to comment.