]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add role bans tab to the bans admin window (#20388)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Fri, 22 Sep 2023 21:08:28 +0000 (14:08 -0700)
committerGitHub <noreply@github.com>
Fri, 22 Sep 2023 21:08:28 +0000 (14:08 -0700)
23 files changed:
Content.Client/Administration/UI/BanList/BanListControl.xaml.cs [deleted file]
Content.Client/Administration/UI/BanList/BanListEui.cs
Content.Client/Administration/UI/BanList/BanListLine.xaml.cs [deleted file]
Content.Client/Administration/UI/BanList/BanListWindow.xaml
Content.Client/Administration/UI/BanList/BanListWindow.xaml.cs
Content.Client/Administration/UI/BanList/Bans/BanListControl.xaml [moved from Content.Client/Administration/UI/BanList/BanListControl.xaml with 58% similarity]
Content.Client/Administration/UI/BanList/Bans/BanListControl.xaml.cs [new file with mode: 0644]
Content.Client/Administration/UI/BanList/Bans/BanListHeader.xaml [moved from Content.Client/Administration/UI/BanList/BanListHeader.xaml with 97% similarity]
Content.Client/Administration/UI/BanList/Bans/BanListHeader.xaml.cs [moved from Content.Client/Administration/UI/BanList/BanListHeader.xaml.cs with 83% similarity]
Content.Client/Administration/UI/BanList/Bans/BanListLine.xaml [moved from Content.Client/Administration/UI/BanList/BanListLine.xaml with 91% similarity]
Content.Client/Administration/UI/BanList/Bans/BanListLine.xaml.cs [new file with mode: 0644]
Content.Client/Administration/UI/BanList/IBanListLine.cs [new file with mode: 0644]
Content.Client/Administration/UI/BanList/RoleBans/RoleBanListControl.xaml [new file with mode: 0644]
Content.Client/Administration/UI/BanList/RoleBans/RoleBanListControl.xaml.cs [new file with mode: 0644]
Content.Client/Administration/UI/BanList/RoleBans/RoleBanListHeader.xaml [new file with mode: 0644]
Content.Client/Administration/UI/BanList/RoleBans/RoleBanListHeader.xaml.cs [new file with mode: 0644]
Content.Client/Administration/UI/BanList/RoleBans/RoleBanListLine.xaml [new file with mode: 0644]
Content.Client/Administration/UI/BanList/RoleBans/RoleBanListLine.xaml.cs [new file with mode: 0644]
Content.Server/Administration/BanList/BanListEui.cs
Content.Shared/Administration/BanList/BanListEuiState.cs
Content.Shared/Administration/BanList/SharedServerBan.cs
Content.Shared/Administration/BanList/SharedServerRoleBan.cs [new file with mode: 0644]
Resources/Locale/en-US/administration/ui/ban-list.ftl

diff --git a/Content.Client/Administration/UI/BanList/BanListControl.xaml.cs b/Content.Client/Administration/UI/BanList/BanListControl.xaml.cs
deleted file mode 100644 (file)
index f7fe770..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-using System.Linq;
-using System.Numerics;
-using Content.Client.Administration.UI.CustomControls;
-using Content.Shared.Administration.BanList;
-using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.XAML;
-
-namespace Content.Client.Administration.UI.BanList;
-
-[GenerateTypedNameReferences]
-public sealed partial class BanListControl : Control
-{
-    private BanListIdsPopup? _popup;
-
-    public BanListControl()
-    {
-        RobustXamlLoader.Load(this);
-    }
-
-    public void SetBans(List<SharedServerBan> bans)
-    {
-        foreach (var control in Bans.Children.ToArray()[1..])
-        {
-            control.Orphan();
-        }
-
-        foreach (var ban in bans)
-        {
-            Bans.AddChild(new HSeparator());
-
-            var line = new BanListLine(ban);
-            line.OnIdsClicked += LineIdsClicked;
-
-            Bans.AddChild(line);
-        }
-    }
-
-    private void ClosePopup()
-    {
-        _popup?.Close();
-        _popup = null;
-    }
-
-    private bool LineIdsClicked(BanListLine line)
-    {
-        ClosePopup();
-
-        var ban = line.Ban;
-        var id = ban.Id == null ? string.Empty : Loc.GetString("ban-list-id", ("id", ban.Id.Value));
-        var ip = ban.Address == null
-            ? string.Empty
-            : Loc.GetString("ban-list-ip", ("ip", ban.Address.Value.address));
-        var hwid = ban.HWId == null ? string.Empty : Loc.GetString("ban-list-hwid", ("hwid", ban.HWId));
-        var guid = ban.UserId == null
-            ? string.Empty
-            : Loc.GetString("ban-list-guid", ("guid", ban.UserId.Value.ToString()));
-
-        _popup = new BanListIdsPopup(id, ip, hwid, guid);
-
-        var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, new Vector2(1, 1));
-        _popup.Open(box);
-
-        return true;
-    }
-
-    protected override void Dispose(bool disposing)
-    {
-        base.Dispose(disposing);
-
-        if (_popup != null)
-        {
-            UserInterfaceManager.PopupRoot.RemoveChild(_popup);
-        }
-    }
-}
index 07eb2e61f4b8bdb2dc393c6c414f7b0ad162515c..2fca1dee5235535724ba35bbdd9545d4ef63c131 100644 (file)
@@ -1,21 +1,47 @@
-using Content.Client.Eui;
+using System.Numerics;
+using Content.Client.Administration.UI.BanList.Bans;
+using Content.Client.Administration.UI.BanList.RoleBans;
+using Content.Client.Eui;
 using Content.Shared.Administration.BanList;
 using Content.Shared.Eui;
-using Content.Shared.Ghost.Roles;
+using JetBrains.Annotations;
+using Robust.Client.UserInterface;
 
 namespace Content.Client.Administration.UI.BanList;
 
+[UsedImplicitly]
 public sealed class BanListEui : BaseEui
 {
+    [Dependency] private readonly IUserInterfaceManager _ui = default!;
+
+    private BanListIdsPopup? _popup;
+
     public BanListEui()
     {
         BanWindow = new BanListWindow();
         BanWindow.OnClose += OnClosed;
+
         BanControl = BanWindow.BanList;
+        BanControl.LineIdsClicked += OnLineIdsClicked;
+
+        RoleBanControl = BanWindow.RoleBanList;
+        RoleBanControl.LineIdsClicked += OnLineIdsClicked;
     }
 
+    private BanListWindow BanWindow { get; }
+
+    private BanListControl BanControl { get; }
+    private RoleBanListControl RoleBanControl { get; }
+
     private void OnClosed()
     {
+        if (_popup != null)
+        {
+            _popup.Close();
+            _popup.Dispose();
+            _popup = null;
+        }
+
         SendMessage(new CloseEuiMessage());
     }
 
@@ -25,10 +51,6 @@ public sealed class BanListEui : BaseEui
         BanWindow.Close();
     }
 
-    private BanListWindow BanWindow { get; }
-
-    private BanListControl BanControl { get; }
-
     public override void HandleState(EuiStateBase state)
     {
         if (state is not BanListEuiState s)
@@ -38,10 +60,58 @@ public sealed class BanListEui : BaseEui
 
         s.Bans.Sort((a, b) => a.BanTime.CompareTo(b.BanTime));
         BanControl.SetBans(s.Bans);
+        RoleBanControl.SetRoleBans(s.RoleBans);
     }
 
     public override void Opened()
     {
         BanWindow.OpenCentered();
     }
+
+    private static string FormatDate(DateTimeOffset date)
+    {
+        return date.ToString("MM/dd/yyyy h:mm tt");
+    }
+
+    public static void SetData<T>(IBanListLine<T> line, SharedServerBan ban) where T : SharedServerBan
+    {
+        line.Reason.Text = ban.Reason;
+        line.BanTime.Text = FormatDate(ban.BanTime);
+        line.Expires.Text = ban.ExpirationTime == null
+            ? Loc.GetString("ban-list-permanent")
+            : FormatDate(ban.ExpirationTime.Value);
+
+        if (ban.Unban is { } unban)
+        {
+            var unbanned = Loc.GetString("ban-list-unbanned", ("date", FormatDate(unban.UnbanTime)));
+            var unbannedBy = unban.UnbanningAdmin == null
+                ? string.Empty
+                : $"\n{Loc.GetString("ban-list-unbanned-by", ("unbanner", unban.UnbanningAdmin))}";
+
+            line.Expires.Text += $"\n{unbanned}{unbannedBy}";
+        }
+
+        line.BanningAdmin.Text = ban.BanningAdminName;
+    }
+
+    private void OnLineIdsClicked<T>(IBanListLine<T> line) where T : SharedServerBan
+    {
+        _popup?.Close();
+        _popup = null;
+
+        var ban = line.Ban;
+        var id = ban.Id == null ? string.Empty : Loc.GetString("ban-list-id", ("id", ban.Id.Value));
+        var ip = ban.Address == null
+            ? string.Empty
+            : Loc.GetString("ban-list-ip", ("ip", ban.Address.Value.address));
+        var hwid = ban.HWId == null ? string.Empty : Loc.GetString("ban-list-hwid", ("hwid", ban.HWId));
+        var guid = ban.UserId == null
+            ? string.Empty
+            : Loc.GetString("ban-list-guid", ("guid", ban.UserId.Value.ToString()));
+
+        _popup = new BanListIdsPopup(id, ip, hwid, guid);
+
+        var box = UIBox2.FromDimensions(_ui.MousePositionScaled.Position, new Vector2(1, 1));
+        _popup.Open(box);
+    }
 }
diff --git a/Content.Client/Administration/UI/BanList/BanListLine.xaml.cs b/Content.Client/Administration/UI/BanList/BanListLine.xaml.cs
deleted file mode 100644 (file)
index a2287d8..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-using Content.Shared.Administration.BanList;
-using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface.Controls;
-using Robust.Client.UserInterface.XAML;
-
-namespace Content.Client.Administration.UI.BanList;
-
-[GenerateTypedNameReferences]
-public sealed partial class BanListLine : BoxContainer
-{
-    public readonly SharedServerBan Ban;
-
-    public event Func<BanListLine, bool>? OnIdsClicked;
-
-    public BanListLine(SharedServerBan ban)
-    {
-        RobustXamlLoader.Load(this);
-
-        Ban = ban;
-
-        IdsHidden.OnPressed += IdsPressed;
-
-        Reason.Text = ban.Reason;
-        BanTime.Text = FormatDate(ban.BanTime);
-        Expires.Text = ban.ExpirationTime == null
-            ? Loc.GetString("ban-list-permanent")
-            : FormatDate(ban.ExpirationTime.Value);
-
-        if (ban.Unban is { } unban)
-        {
-            var unbanned = Loc.GetString("ban-list-unbanned", ("date", FormatDate(unban.UnbanTime)));
-            var unbannedBy = unban.UnbanningAdmin == null
-                ? string.Empty
-                : $"\n{Loc.GetString("ban-list-unbanned-by", ("unbanner", unban.UnbanningAdmin))}";
-
-            Expires.Text += $"\n{unbanned}{unbannedBy}";
-        }
-
-        BanningAdmin.Text = ban.BanningAdminName;
-    }
-
-    private static string FormatDate(DateTimeOffset date)
-    {
-        return date.ToString("MM/dd/yyyy h:mm tt");
-    }
-
-    private void IdsPressed(BaseButton.ButtonEventArgs buttonEventArgs)
-    {
-        OnIdsClicked?.Invoke(this);
-    }
-
-    protected override void Dispose(bool disposing)
-    {
-        base.Dispose(disposing);
-
-        IdsHidden.OnPressed -= IdsPressed;
-        OnIdsClicked = null;
-    }
-}
index d246a3e3a2a97cac2932563d60c91968963d9981..d11282468076cd14fa90b28dcb24ea7e425adeea 100644 (file)
@@ -1,6 +1,11 @@
 <controls:BanListWindow
     xmlns="https://spacestation14.io"
     xmlns:controls="clr-namespace:Content.Client.Administration.UI.BanList"
+    xmlns:bans="clr-namespace:Content.Client.Administration.UI.BanList.Bans"
+    xmlns:roleBans="clr-namespace:Content.Client.Administration.UI.BanList.RoleBans"
     SetSize="1400 400">
-    <controls:BanListControl Name="BanList" Access="Public"/>
+    <TabContainer Name="TabContainer">
+        <bans:BanListControl Name="BanList" Access="Public"/>
+        <roleBans:RoleBanListControl Name="RoleBanList" Access="Public"/>
+    </TabContainer>
 </controls:BanListWindow>
index 2bb08a88258f3c4df20b8aceee9a9224e31b11df..c95f8f204dd4a0bdad3ed93647f4cdbb7999ca5f 100644 (file)
@@ -10,6 +10,9 @@ public sealed partial class BanListWindow : DefaultWindow
     public BanListWindow()
     {
         RobustXamlLoader.Load(this);
+
+        TabContainer.SetTabTitle(0, Loc.GetString("ban-list-bans"));
+        TabContainer.SetTabTitle(1, Loc.GetString("ban-list-role-bans"));
     }
 
     public void SetTitlePlayer(string playerName)
similarity index 58%
rename from Content.Client/Administration/UI/BanList/BanListControl.xaml
rename to Content.Client/Administration/UI/BanList/Bans/BanListControl.xaml
index b3c480368936379bcaa4755d78f262e16dd0b2d8..e12199f4e7dfe7229e8dac1682d458a822eda572 100644 (file)
@@ -1,11 +1,11 @@
-<controls:BanListControl
+<bans:BanListControl
     xmlns="https://spacestation14.io"
-    xmlns:controls="clr-namespace:Content.Client.Administration.UI.BanList">
+    xmlns:bans="clr-namespace:Content.Client.Administration.UI.BanList.Bans">
     <PanelContainer StyleClasses="BackgroundDark">
         <ScrollContainer>
             <BoxContainer Name="Bans" Access="Public" Orientation="Vertical">
-                <controls:BanListHeader Name="BansHeader"/>
+                <bans:BanListHeader Name="BansHeader"/>
             </BoxContainer>
         </ScrollContainer>
     </PanelContainer>
-</controls:BanListControl>
+</bans:BanListControl>
diff --git a/Content.Client/Administration/UI/BanList/Bans/BanListControl.xaml.cs b/Content.Client/Administration/UI/BanList/Bans/BanListControl.xaml.cs
new file mode 100644 (file)
index 0000000..4310875
--- /dev/null
@@ -0,0 +1,36 @@
+using Content.Client.Administration.UI.CustomControls;
+using Content.Shared.Administration.BanList;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.Administration.UI.BanList.Bans;
+
+[GenerateTypedNameReferences]
+public sealed partial class BanListControl : Control
+{
+    public event Action<BanListLine>? LineIdsClicked;
+
+    public BanListControl()
+    {
+        RobustXamlLoader.Load(this);
+    }
+
+    public void SetBans(List<SharedServerBan> bans)
+    {
+        for (var i = Bans.ChildCount - 1; i >= 1; i--)
+        {
+            Bans.GetChild(i).Dispose();
+        }
+
+        foreach (var ban in bans)
+        {
+            Bans.AddChild(new HSeparator());
+
+            var line = new BanListLine(ban);
+            line.IdsClicked += LineIdsClicked;
+
+            Bans.AddChild(line);
+        }
+    }
+}
similarity index 97%
rename from Content.Client/Administration/UI/BanList/BanListHeader.xaml
rename to Content.Client/Administration/UI/BanList/Bans/BanListHeader.xaml
index af0202775899c367b11ee07af5a54757b9f13c7a..00a652175ca4495a1a45f8e4b64d8c6eb3707873 100644 (file)
@@ -25,7 +25,6 @@
             <Label Text="{Loc ban-list-header-banning-admin}"
                    SizeFlagsStretchRatio="2"
                    HorizontalExpand="True"/>
-            <cc:VSeparator/>
         </BoxContainer>
     </PanelContainer>
 </ContainerButton>
similarity index 83%
rename from Content.Client/Administration/UI/BanList/BanListHeader.xaml.cs
rename to Content.Client/Administration/UI/BanList/Bans/BanListHeader.xaml.cs
index 6c49ff3e5b548bf7b0333ea95e34970c9f51dfd0..c7cf73e1b2960a4d6baca358a85bae74a1a2fadf 100644 (file)
@@ -2,7 +2,7 @@
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
 
-namespace Content.Client.Administration.UI.BanList;
+namespace Content.Client.Administration.UI.BanList.Bans;
 
 [GenerateTypedNameReferences]
 public sealed partial class BanListHeader : ContainerButton
similarity index 91%
rename from Content.Client/Administration/UI/BanList/BanListLine.xaml
rename to Content.Client/Administration/UI/BanList/Bans/BanListLine.xaml
index 111588e61da7b2b95648eefc4d660b1396f5c30c..98265852726ffbe5edf5d4665bbea8dba64d5aa4 100644 (file)
     </BoxContainer>
     <cc:VSeparator/>
     <Label Name="Reason"
+           Access="Public"
            SizeFlagsStretchRatio="6"
            HorizontalExpand="True"
            VerticalExpand="True"/>
     <cc:VSeparator/>
     <Label Name="BanTime"
+           Access="Public"
            SizeFlagsStretchRatio="2"
            HorizontalExpand="True"
            ClipText="True"/>
     <cc:VSeparator/>
     <Label Name="Expires"
+           Access="Public"
            SizeFlagsStretchRatio="4"
            HorizontalExpand="True"
            ClipText="True"/>
     <cc:VSeparator/>
     <Label Name="BanningAdmin"
+           Access="Public"
            SizeFlagsStretchRatio="2"
            HorizontalExpand="True"
            ClipText="True"/>
-    <cc:VSeparator/>
 </BoxContainer>
diff --git a/Content.Client/Administration/UI/BanList/Bans/BanListLine.xaml.cs b/Content.Client/Administration/UI/BanList/Bans/BanListLine.xaml.cs
new file mode 100644 (file)
index 0000000..0c4e6e6
--- /dev/null
@@ -0,0 +1,38 @@
+using Content.Shared.Administration.BanList;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+using static Robust.Client.UserInterface.Controls.BaseButton;
+
+namespace Content.Client.Administration.UI.BanList.Bans;
+
+[GenerateTypedNameReferences]
+public sealed partial class BanListLine : BoxContainer, IBanListLine<SharedServerBan>
+{
+    public SharedServerBan Ban { get; }
+
+    public event Action<BanListLine>? IdsClicked;
+
+    public BanListLine(SharedServerBan ban)
+    {
+        RobustXamlLoader.Load(this);
+
+        Ban = ban;
+        IdsHidden.OnPressed += IdsPressed;
+
+        BanListEui.SetData(this, ban);
+    }
+
+    private void IdsPressed(ButtonEventArgs buttonEventArgs)
+    {
+        IdsClicked?.Invoke(this);
+    }
+
+    protected override void Dispose(bool disposing)
+    {
+        base.Dispose(disposing);
+
+        IdsHidden.OnPressed -= IdsPressed;
+        IdsClicked = null;
+    }
+}
diff --git a/Content.Client/Administration/UI/BanList/IBanListLine.cs b/Content.Client/Administration/UI/BanList/IBanListLine.cs
new file mode 100644 (file)
index 0000000..097bae1
--- /dev/null
@@ -0,0 +1,13 @@
+using Content.Shared.Administration.BanList;
+using Robust.Client.UserInterface.Controls;
+
+namespace Content.Client.Administration.UI.BanList;
+
+public interface IBanListLine<T> where T : SharedServerBan
+{
+    T Ban { get; }
+    Label Reason { get; }
+    Label BanTime { get; }
+    Label Expires { get; }
+    Label BanningAdmin { get; }
+}
diff --git a/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListControl.xaml b/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListControl.xaml
new file mode 100644 (file)
index 0000000..695258c
--- /dev/null
@@ -0,0 +1,11 @@
+<roleBans:RoleBanListControl
+    xmlns="https://spacestation14.io"
+    xmlns:roleBans="clr-namespace:Content.Client.Administration.UI.BanList.RoleBans">
+    <PanelContainer StyleClasses="BackgroundDark">
+        <ScrollContainer>
+            <BoxContainer Name="RoleBans" Access="Public" Orientation="Vertical">
+                <roleBans:RoleBanListHeader Name="BansHeader"/>
+            </BoxContainer>
+        </ScrollContainer>
+    </PanelContainer>
+</roleBans:RoleBanListControl>
diff --git a/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListControl.xaml.cs b/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListControl.xaml.cs
new file mode 100644 (file)
index 0000000..1ea751d
--- /dev/null
@@ -0,0 +1,36 @@
+using Content.Client.Administration.UI.CustomControls;
+using Content.Shared.Administration.BanList;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.Administration.UI.BanList.RoleBans;
+
+[GenerateTypedNameReferences]
+public sealed partial class RoleBanListControl : Control
+{
+    public event Action<RoleBanListLine>? LineIdsClicked;
+
+    public RoleBanListControl()
+    {
+        RobustXamlLoader.Load(this);
+    }
+
+    public void SetRoleBans(List<SharedServerRoleBan> bans)
+    {
+        for (var i = RoleBans.ChildCount - 1; i >= 1; i--)
+        {
+            RoleBans.GetChild(i).Dispose();
+        }
+
+        foreach (var ban in bans)
+        {
+            RoleBans.AddChild(new HSeparator());
+
+            var line = new RoleBanListLine(ban);
+            line.IdsClicked += LineIdsClicked;
+
+            RoleBans.AddChild(line);
+        }
+    }
+}
diff --git a/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListHeader.xaml b/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListHeader.xaml
new file mode 100644 (file)
index 0000000..0302266
--- /dev/null
@@ -0,0 +1,34 @@
+<ContainerButton
+    xmlns="https://spacestation14.io"
+    xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
+    <PanelContainer Name="BackgroundPanel" Access="Public">
+        <BoxContainer
+            Orientation="Horizontal"
+            HorizontalExpand="True"
+            SeparationOverride="4">
+            <Label Text="{Loc ban-list-header-ids}"
+                   SizeFlagsStretchRatio="1"
+                   HorizontalExpand="True"/>
+            <cc:VSeparator/>
+            <Label Text="{Loc ban-list-header-reason}"
+                   SizeFlagsStretchRatio="4.5"
+                   HorizontalExpand="True"/>
+            <cc:VSeparator Name="ReasonSeparator" Access="Public"/>
+            <Label Text="{Loc ban-list-header-role}"
+                   SizeFlagsStretchRatio="1.5"
+                   HorizontalExpand="True"/>
+            <cc:VSeparator/>
+            <Label Text="{Loc ban-list-header-time}"
+                   SizeFlagsStretchRatio="2"
+                   HorizontalExpand="True"/>
+            <cc:VSeparator/>
+            <Label Text="{Loc ban-list-header-expires}"
+                   SizeFlagsStretchRatio="4"
+                   HorizontalExpand="True"/>
+            <cc:VSeparator/>
+            <Label Text="{Loc ban-list-header-banning-admin}"
+                   SizeFlagsStretchRatio="2"
+                   HorizontalExpand="True"/>
+        </BoxContainer>
+    </PanelContainer>
+</ContainerButton>
diff --git a/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListHeader.xaml.cs b/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListHeader.xaml.cs
new file mode 100644 (file)
index 0000000..e311e74
--- /dev/null
@@ -0,0 +1,14 @@
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.Administration.UI.BanList.RoleBans;
+
+[GenerateTypedNameReferences]
+public sealed partial class RoleBanListHeader : ContainerButton
+{
+    public RoleBanListHeader()
+    {
+        RobustXamlLoader.Load(this);
+    }
+}
diff --git a/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListLine.xaml b/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListLine.xaml
new file mode 100644 (file)
index 0000000..d3c99dd
--- /dev/null
@@ -0,0 +1,46 @@
+<BoxContainer
+    xmlns="https://spacestation14.io"
+    xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
+    Orientation="Horizontal"
+    HorizontalExpand="True"
+    SeparationOverride="4">
+    <BoxContainer Orientation="Vertical"
+                  SizeFlagsStretchRatio="1"
+                  HorizontalExpand="True"
+                  RectClipContent="True">
+        <Button Name="IdsHidden"
+                Text="{Loc 'ban-list-view'}"
+                HorizontalExpand="True"
+                VerticalExpand="True"
+                MouseFilter="Pass"/>
+    </BoxContainer>
+    <cc:VSeparator/>
+    <Label Name="Reason"
+           Access="Public"
+           SizeFlagsStretchRatio="4.5"
+           HorizontalExpand="True"
+           VerticalExpand="True"/>
+    <cc:VSeparator/>
+    <Label Name="Role"
+           SizeFlagsStretchRatio="1.5"
+           HorizontalExpand="True"
+           VerticalExpand="True"/>
+    <cc:VSeparator/>
+    <Label Name="BanTime"
+           Access="Public"
+           SizeFlagsStretchRatio="2"
+           HorizontalExpand="True"
+           ClipText="True"/>
+    <cc:VSeparator/>
+    <Label Name="Expires"
+           Access="Public"
+           SizeFlagsStretchRatio="4"
+           HorizontalExpand="True"
+           ClipText="True"/>
+    <cc:VSeparator/>
+    <Label Name="BanningAdmin"
+           Access="Public"
+           SizeFlagsStretchRatio="2"
+           HorizontalExpand="True"
+           ClipText="True"/>
+</BoxContainer>
diff --git a/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListLine.xaml.cs b/Content.Client/Administration/UI/BanList/RoleBans/RoleBanListLine.xaml.cs
new file mode 100644 (file)
index 0000000..4f77d66
--- /dev/null
@@ -0,0 +1,40 @@
+using Content.Shared.Administration.BanList;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+using static Robust.Client.UserInterface.Controls.BaseButton;
+
+namespace Content.Client.Administration.UI.BanList.RoleBans;
+
+[GenerateTypedNameReferences]
+public sealed partial class RoleBanListLine : BoxContainer, IBanListLine<SharedServerRoleBan>
+{
+    public SharedServerRoleBan Ban { get; }
+
+    public event Action<RoleBanListLine>? IdsClicked;
+
+    public RoleBanListLine(SharedServerRoleBan ban)
+    {
+        RobustXamlLoader.Load(this);
+
+        Ban = ban;
+        IdsHidden.OnPressed += IdsPressed;
+
+        BanListEui.SetData(this, ban);
+        Role.Text = ban.Role;
+    }
+
+    private void IdsPressed(ButtonEventArgs buttonEventArgs)
+    {
+        IdsClicked?.Invoke(this);
+    }
+
+    protected override void Dispose(bool disposing)
+    {
+        base.Dispose(disposing);
+
+        IdsHidden.OnPressed -= IdsPressed;
+        IdsClicked = null;
+    }
+}
+
index 8da2acf8292bf4a2b7bd6ff30e586c4918ed99b6..3a86a42d531a5ca48485bdcb3a7f3854d2f5cca4 100644 (file)
@@ -22,7 +22,8 @@ public sealed class BanListEui : BaseEui
 
     private Guid BanListPlayer { get; set; }
     private string BanListPlayerName { get; set; } = string.Empty;
-    private List<SharedServerBan> Bans { get; set; } = new();
+    private List<SharedServerBan> Bans { get; } = new();
+    private List<SharedServerRoleBan> RoleBans { get; } = new();
 
     public override void Opened()
     {
@@ -40,7 +41,7 @@ public sealed class BanListEui : BaseEui
 
     public override EuiStateBase GetNewState()
     {
-        return new BanListEuiState(BanListPlayerName, Bans);
+        return new BanListEuiState(BanListPlayerName, Bans, RoleBans);
     }
 
     private void OnPermsChanged(AdminPermsChangedEventArgs args)
@@ -51,14 +52,8 @@ public sealed class BanListEui : BaseEui
         }
     }
 
-    private async Task LoadFromDb()
+    private async Task LoadBans(NetUserId userId)
     {
-        Bans.Clear();
-
-        var userId = new NetUserId(BanListPlayer);
-        BanListPlayerName = (await _playerLocator.LookupIdAsync(userId))?.Username ??
-                            string.Empty;
-
         foreach (var ban in await _db.GetServerBansAsync(null, userId, null))
         {
             SharedServerUnban? unban = null;
@@ -86,6 +81,51 @@ public sealed class BanListEui : BaseEui
                 unban
             ));
         }
+    }
+
+    private async Task LoadRoleBans(NetUserId userId)
+    {
+        foreach (var ban in await _db.GetServerRoleBansAsync(null, userId, null))
+        {
+            SharedServerUnban? unban = null;
+            if (ban.Unban is { } unbanDef)
+            {
+                var unbanningAdmin = unbanDef.UnbanningAdmin == null
+                    ? null
+                    : (await _playerLocator.LookupIdAsync(unbanDef.UnbanningAdmin.Value))?.Username;
+                unban = new SharedServerUnban(unbanningAdmin, ban.Unban.UnbanTime.UtcDateTime);
+            }
+
+            RoleBans.Add(new SharedServerRoleBan(
+                ban.Id,
+                ban.UserId,
+                ban.Address is { } address
+                    ? (address.address.ToString(), address.cidrMask)
+                    : null,
+                ban.HWId == null ? null : Convert.ToBase64String(ban.HWId.Value.AsSpan()),
+                ban.BanTime.UtcDateTime,
+                ban.ExpirationTime?.UtcDateTime,
+                ban.Reason,
+                ban.BanningAdmin == null
+                    ? null
+                    : (await _playerLocator.LookupIdAsync(ban.BanningAdmin.Value))?.Username,
+                unban,
+                ban.Role
+            ));
+        }
+    }
+
+    private async Task LoadFromDb()
+    {
+        Bans.Clear();
+        RoleBans.Clear();
+
+        var userId = new NetUserId(BanListPlayer);
+        BanListPlayerName = (await _playerLocator.LookupIdAsync(userId))?.Username ??
+                            string.Empty;
+
+        await LoadBans(userId);
+        await LoadRoleBans(userId);
 
         StateDirty();
     }
index 750043bb7db9f196a5c49245ef3e1e72678e6382..09faa9706ea31bbdb99635872449eb907c568e57 100644 (file)
@@ -6,12 +6,14 @@ namespace Content.Shared.Administration.BanList;
 [Serializable, NetSerializable]
 public sealed class BanListEuiState : EuiStateBase
 {
-    public BanListEuiState(string banListPlayerName, List<SharedServerBan> bans)
+    public BanListEuiState(string banListPlayerName, List<SharedServerBan> bans, List<SharedServerRoleBan> roleBans)
     {
         BanListPlayerName = banListPlayerName;
         Bans = bans;
+        RoleBans = roleBans;
     }
 
     public string BanListPlayerName { get; }
     public List<SharedServerBan> Bans { get; }
+    public List<SharedServerRoleBan> RoleBans { get; }
 }
index 4970869966cf1689ac98935c505356023fc84b06..a8b9ce0d9a1ce636f4fb2e381962886b16645ab0 100644 (file)
@@ -4,7 +4,7 @@ using Robust.Shared.Serialization;
 namespace Content.Shared.Administration.BanList;
 
 [Serializable, NetSerializable]
-public sealed record SharedServerBan(
+public record SharedServerBan(
     int? Id,
     NetUserId? UserId,
     (string address, int cidrMask)? Address,
diff --git a/Content.Shared/Administration/BanList/SharedServerRoleBan.cs b/Content.Shared/Administration/BanList/SharedServerRoleBan.cs
new file mode 100644 (file)
index 0000000..fca2ea1
--- /dev/null
@@ -0,0 +1,18 @@
+using Robust.Shared.Network;
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Administration.BanList;
+
+[Serializable, NetSerializable]
+public sealed record SharedServerRoleBan(
+    int? Id,
+    NetUserId? UserId,
+    (string address, int cidrMask)? Address,
+    string? HWId,
+    DateTime BanTime,
+    DateTime? ExpirationTime,
+    string Reason,
+    string? BanningAdminName,
+    SharedServerUnban? Unban,
+    string Role
+) : SharedServerBan(Id, UserId, Address, HWId, BanTime, ExpirationTime, Reason, BanningAdminName, Unban);
index 61158e8b65bcabbe3c6cb7f710bcc61abd9f7514..3aa1d081b5b9cacada0f9f1f87c890dee0af2de1 100644 (file)
@@ -1,6 +1,10 @@
 # UI
+ban-list-bans = Bans
+ban-list-role-bans = Role Bans
+
 ban-list-header-ids = Ids
 ban-list-header-reason = Reason
+ban-list-header-role = Role
 ban-list-header-time = Ban time
 ban-list-header-expires = Expires
 ban-list-header-banning-admin = Banning admin