From 7225db0bf12a324d058bc0171ae9313d74851889 Mon Sep 17 00:00:00 2001 From: Moritz <101179677+Moritz-Deiaco@users.noreply.github.com> Date: Tue, 14 May 2024 14:52:27 +0200 Subject: [PATCH] added some informations --- Moonlight/Core/CoreFeature.cs | 5 +++++ Moonlight/Core/Models/Abstractions/Feature/UiInitContext.cs | 2 ++ Moonlight/Core/UI/Views/Admin/Index.razor | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Moonlight/Core/CoreFeature.cs b/Moonlight/Core/CoreFeature.cs index 3316b1e..61870dd 100644 --- a/Moonlight/Core/CoreFeature.cs +++ b/Moonlight/Core/CoreFeature.cs @@ -208,8 +208,13 @@ public class CoreFeature : MoonlightFeature context.AddSidebarItem("Users", "bxs-group", "/admin/users", needsExactMatch: false, isAdmin: true); context.AddSidebarItem("System", "bxs-component", "/admin/sys", needsExactMatch: false, isAdmin: true); + // With this function, you can add an Admin Card to the Admin Page + // It references the Admin Card, which is a Razor component. context.AddAdminCard(index: int.MinValue); + // Same Thing could be used with the context.AddAdminComponent Function, which then renders the component + // under the cards, for fast informations + return Task.CompletedTask; } diff --git a/Moonlight/Core/Models/Abstractions/Feature/UiInitContext.cs b/Moonlight/Core/Models/Abstractions/Feature/UiInitContext.cs index 172885e..0a589b8 100644 --- a/Moonlight/Core/Models/Abstractions/Feature/UiInitContext.cs +++ b/Moonlight/Core/Models/Abstractions/Feature/UiInitContext.cs @@ -24,6 +24,7 @@ public class UiInitContext public void AddAdminComponent(int index = 0, int requiredPermissionLevel = 0) where T : IComponent { + // Loads the Component into a List of AdminComponents, with lots of more information for the Admin Page to render AdminPageComponents.Add( new AdminComponent() { @@ -40,6 +41,7 @@ public class UiInitContext public void AddAdminCard(int index = 0, int requiredPermissionLevel = 0) where T : IComponent { + // Loads the Card into a List of AdminComponents, with lots of more information for the Admin Page to render AdminPageCards.Add( new AdminComponent() { diff --git a/Moonlight/Core/UI/Views/Admin/Index.razor b/Moonlight/Core/UI/Views/Admin/Index.razor index 8d46947..2f1c8c6 100644 --- a/Moonlight/Core/UI/Views/Admin/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Index.razor @@ -15,6 +15,8 @@
@foreach (var adminCard in FeatureService.UiContext.AdminPageCards.OrderBy(x => x.Index).ToArray()) { + // basically renders the component if the permissions of the viewed item is lower or equal + // to the users permission, -> better developer experience for feature devs if (IdentityService.CurrentUser.Permissions >= adminCard.RequiredPermissionLevel) {
@@ -41,6 +43,5 @@ private async Task Load(LazyLoader arg) { await arg.SetText("Loading Information..."); - } } \ No newline at end of file