Added a Minimum Required Permission Level For the component
Masu you said it would be possible to handle this in the Components Razor file, but if nothing is shown there will still be an empty space (empty cols are still showing in boostrap, margin on the userdashboard and admindashboard components). I think this would be the best solution
This commit is contained in:
@@ -7,4 +7,6 @@ public class UiComponent
|
|||||||
public required RenderFragment Component { get; set; }
|
public required RenderFragment Component { get; set; }
|
||||||
|
|
||||||
public int Index { get; set; } = 0;
|
public int Index { get; set; } = 0;
|
||||||
|
|
||||||
|
public int RequiredPermissionLevel { get; set; } = 0;
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,34 @@
|
|||||||
@page "/admin"
|
@page "/admin"
|
||||||
@using MoonCore.Abstractions
|
|
||||||
@using Moonlight.Core.Database.Entities
|
|
||||||
@using Moonlight.Core.Interfaces
|
|
||||||
@using Moonlight.Core.Interfaces.Ui.Admin
|
@using Moonlight.Core.Interfaces.Ui.Admin
|
||||||
@using Moonlight.Core.Models.Abstractions
|
@using Moonlight.Core.Models.Abstractions
|
||||||
@using Moonlight.Core.Services
|
@using Moonlight.Core.Services
|
||||||
@using Moonlight.Features.Servers.Entities
|
|
||||||
|
|
||||||
@inject PluginService PluginService
|
@inject PluginService PluginService
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
|
||||||
@attribute [RequirePermission(999)]
|
@attribute [RequirePermission(999)]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<div class="row mb-8">
|
<div class="row mb-8">
|
||||||
@foreach(var column in Columns.OrderBy(x => x.Index))
|
@foreach (var column in Columns.OrderBy(x => x.Index))
|
||||||
|
{
|
||||||
|
if (column.RequiredPermissionLevel <= IdentityService.CurrentUser.Permissions)
|
||||||
{
|
{
|
||||||
<div class="col-12 col-lg-6 col-xl">
|
<div class="col-12 col-lg-6 col-xl">
|
||||||
@column.Component
|
@column.Component
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
@foreach (var component in Components.OrderBy(x => x.Index))
|
@foreach (var component in Components.OrderBy(x => x.Index))
|
||||||
|
{
|
||||||
|
if (component.RequiredPermissionLevel <= IdentityService.CurrentUser.Permissions)
|
||||||
{
|
{
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
@component.Component
|
@component.Component
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,18 @@
|
|||||||
@using Moonlight.Core.Services
|
@using Moonlight.Core.Services
|
||||||
|
|
||||||
@inject PluginService PluginService
|
@inject PluginService PluginService
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@foreach (var component in Components.OrderBy(x => x.Index))
|
@foreach (var component in Components.OrderBy(x => x.Index))
|
||||||
|
{
|
||||||
|
if (component.RequiredPermissionLevel <= IdentityService.CurrentUser.Permissions)
|
||||||
{
|
{
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
@component.Component
|
@component.Component
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
<Folder Include="Core\Database\Migrations\" />
|
<Folder Include="Core\Database\Migrations\" />
|
||||||
<Folder Include="Core\Http\Requests\" />
|
<Folder Include="Core\Http\Requests\" />
|
||||||
<Folder Include="Core\Http\Resources\" />
|
<Folder Include="Core\Http\Resources\" />
|
||||||
<Folder Include="Core\Implementations\UI\Admin\AdminComponents\" />
|
|
||||||
<Folder Include="Core\UI\Components\Forms\" />
|
<Folder Include="Core\UI\Components\Forms\" />
|
||||||
<Folder Include="Features\Dummy\Configuration\" />
|
<Folder Include="Features\Dummy\Configuration\" />
|
||||||
<Folder Include="Features\Dummy\Entities\" />
|
<Folder Include="Features\Dummy\Entities\" />
|
||||||
|
|||||||
Reference in New Issue
Block a user