Add role bans tab to the bans admin window (#20388)

This commit is contained in:
DrSmugleaf
2023-09-22 14:08:28 -07:00
committed by GitHub
parent 8299fcbb65
commit 71ab660885
23 changed files with 437 additions and 160 deletions

View File

@@ -0,0 +1,11 @@
<bans:BanListControl
xmlns="https://spacestation14.io"
xmlns:bans="clr-namespace:Content.Client.Administration.UI.BanList.Bans">
<PanelContainer StyleClasses="BackgroundDark">
<ScrollContainer>
<BoxContainer Name="Bans" Access="Public" Orientation="Vertical">
<bans:BanListHeader Name="BansHeader"/>
</BoxContainer>
</ScrollContainer>
</PanelContainer>
</bans:BanListControl>

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,30 @@
<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="6"
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>

View File

@@ -0,0 +1,14 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Administration.UI.BanList.Bans;
[GenerateTypedNameReferences]
public sealed partial class BanListHeader : ContainerButton
{
public BanListHeader()
{
RobustXamlLoader.Load(this);
}
}

View File

@@ -0,0 +1,41 @@
<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="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"/>
</BoxContainer>

View File

@@ -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;
}
}