From c50e53ad9a419b30cf694fa033dbb38c4affd0bf Mon Sep 17 00:00:00 2001 From: koko Date: Mon, 10 Apr 2023 22:16:03 -0400 Subject: [PATCH] Display a lock icon next to locked levels (#738) * Display a lock icon next to locked levels * C# Return Switch shenanigans * No clue where that line break came from * Don't render a semicolon * Move permission level color/lock icon to website extension * Simplify GetLevelLockIcon --------- Co-authored-by: Josh --- .../Extensions/FormattingExtensions.cs | 19 +++++++++++++++++++ .../Partials/Links/UserLinkPartial.cshtml | 2 +- .../Pages/Partials/SlotCardPartial.cshtml | 8 ++++---- .../Pages/Partials/UserCardPartial.cshtml | 2 +- .../Types/Users/PermissionLevel.cs | 13 ------------- 5 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 ProjectLighthouse.Servers.Website/Extensions/FormattingExtensions.cs diff --git a/ProjectLighthouse.Servers.Website/Extensions/FormattingExtensions.cs b/ProjectLighthouse.Servers.Website/Extensions/FormattingExtensions.cs new file mode 100644 index 00000000..c90e5e51 --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Extensions/FormattingExtensions.cs @@ -0,0 +1,19 @@ +using LBPUnion.ProjectLighthouse.Types.Entities.Level; +using LBPUnion.ProjectLighthouse.Types.Users; + +namespace LBPUnion.ProjectLighthouse.Servers.Website.Extensions; + +public static class FormattingExtensions +{ + public static string GetLevelLockIcon(this SlotEntity slot) => slot.InitiallyLocked ? "icon lock" : ""; + + public static string ToHtmlColor(this PermissionLevel permissionLevel) + { + return permissionLevel switch + { + PermissionLevel.Administrator => "red", + PermissionLevel.Moderator => "rgb(200, 130, 0)", + _ => "", + }; + } +} \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/Links/UserLinkPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/Links/UserLinkPartial.cshtml index e60f8088..49903bea 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/Links/UserLinkPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/Links/UserLinkPartial.cshtml @@ -1,6 +1,6 @@ @using LBPUnion.ProjectLighthouse.Database @using LBPUnion.ProjectLighthouse.Localization -@using LBPUnion.ProjectLighthouse.Types.Users +@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions @model LBPUnion.ProjectLighthouse.Types.Entities.Profile.UserEntity @{ diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml index 4d07eed3..700edc45 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml @@ -54,13 +54,13 @@ @if (showLink) {

- @slotName + @slotName

} else {

- @slotName + @slotName

} } @@ -69,13 +69,13 @@ @if (showLink) {

- @slotName + @slotName

} else {

- @slotName + @slotName

} } diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml index 6a6561b9..8591d3c2 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml @@ -1,6 +1,6 @@ @using LBPUnion.ProjectLighthouse.Database @using LBPUnion.ProjectLighthouse.Localization -@using LBPUnion.ProjectLighthouse.Types.Users +@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions; @model LBPUnion.ProjectLighthouse.Types.Entities.Profile.UserEntity @{ diff --git a/ProjectLighthouse/Types/Users/PermissionLevel.cs b/ProjectLighthouse/Types/Users/PermissionLevel.cs index eca9d49d..b3644803 100644 --- a/ProjectLighthouse/Types/Users/PermissionLevel.cs +++ b/ProjectLighthouse/Types/Users/PermissionLevel.cs @@ -8,17 +8,4 @@ public enum PermissionLevel Default = 0, Moderator = 1, Administrator = 2, -} - -public static class PermissionLevelExtensions -{ - public static string ToHtmlColor(this PermissionLevel permissionLevel) - { - return permissionLevel switch - { - PermissionLevel.Administrator => "red", - PermissionLevel.Moderator => "rgb(200, 130, 0)", - _ => "", - }; - } } \ No newline at end of file