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

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

View File

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

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.RoleBans;
[GenerateTypedNameReferences]
public sealed partial class RoleBanListHeader : ContainerButton
{
public RoleBanListHeader()
{
RobustXamlLoader.Load(this);
}
}

View File

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

View File

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