diff --git a/Moonlight/Core/Models/Abstractions/UiComponent.cs b/Moonlight/Core/Models/Abstractions/UiComponent.cs index 60329f63..f994bad4 100644 --- a/Moonlight/Core/Models/Abstractions/UiComponent.cs +++ b/Moonlight/Core/Models/Abstractions/UiComponent.cs @@ -7,4 +7,6 @@ public class UiComponent public required RenderFragment Component { get; set; } public int Index { get; set; } = 0; + + public int RequiredPermissionLevel { get; set; } = 0; } \ No newline at end of file diff --git a/Moonlight/Core/UI/Views/Admin/Index.razor b/Moonlight/Core/UI/Views/Admin/Index.razor index a7c6747a..ab479889 100644 --- a/Moonlight/Core/UI/Views/Admin/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Index.razor @@ -1,30 +1,33 @@ @page "/admin" -@using MoonCore.Abstractions -@using Moonlight.Core.Database.Entities -@using Moonlight.Core.Interfaces @using Moonlight.Core.Interfaces.Ui.Admin @using Moonlight.Core.Models.Abstractions @using Moonlight.Core.Services -@using Moonlight.Features.Servers.Entities @inject PluginService PluginService +@inject IdentityService IdentityService @attribute [RequirePermission(999)]
- @foreach(var column in Columns.OrderBy(x => x.Index)) + @foreach (var column in Columns.OrderBy(x => x.Index)) { -
- @column.Component -
+ if (column.RequiredPermissionLevel <= IdentityService.CurrentUser.Permissions) + { +
+ @column.Component +
+ } }
@foreach (var component in Components.OrderBy(x => x.Index)) { -
- @component.Component -
+ if (component.RequiredPermissionLevel <= IdentityService.CurrentUser.Permissions) + { +
+ @component.Component +
+ } }
diff --git a/Moonlight/Core/UI/Views/Index.razor b/Moonlight/Core/UI/Views/Index.razor index e36cf092..acef82a3 100644 --- a/Moonlight/Core/UI/Views/Index.razor +++ b/Moonlight/Core/UI/Views/Index.razor @@ -4,13 +4,17 @@ @using Moonlight.Core.Services @inject PluginService PluginService +@inject IdentityService IdentityService @foreach (var component in Components.OrderBy(x => x.Index)) { -
- @component.Component -
+ if (component.RequiredPermissionLevel <= IdentityService.CurrentUser.Permissions) + { +
+ @component.Component +
+ } }
diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 6f369f1d..baf8e518 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -53,7 +53,6 @@ -