]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Revert "Show ban and note count in ahelp window" (#15347)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 12 Apr 2023 09:43:33 +0000 (19:43 +1000)
committerGitHub <noreply@github.com>
Wed, 12 Apr 2023 09:43:33 +0000 (19:43 +1000)
13 files changed:
Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml
Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml.cs
Content.Server/Administration/Notes/AdminNotesManager.cs
Content.Server/Administration/Notes/IAdminNotesManager.cs
Content.Server/Administration/Systems/AdminSystem.cs
Content.Server/Database/ServerDbBase.cs
Content.Server/Database/ServerDbManager.cs
Content.Server/Database/ServerDbPostgres.cs
Content.Server/Database/ServerDbSqlite.cs
Content.Shared/Administration/PlayerInfo.cs
Resources/Locale/en-US/administration/ui/actions.ftl

index ef7aa2af652f3f15b7b6a00ba891b4d4d3d70d57..89e5694b0d3ec75814291db3d4f3c7e94b388845 100644 (file)
             <cc:PlayerListControl Access="Public" Name="ChannelSelector" HorizontalExpand="True" SizeFlagsStretchRatio="1" />
             <BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
                 <BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
-                <BoxContainer Orientation="Horizontal" HorizontalExpand="True">
-                    <Button Margin="0 0 10 0" Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}"
-                            HorizontalAlignment="Left"/>
-                    <Button Visible="False" Name="Bans" />
-                    <Button Visible="False" Name="Notes" />
+                <BoxContainer Orientation="Horizontal" HorizontalAlignment="Right">
+                    <Button Margin="0 0 10 0" Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}"/>
+                    <Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" />
+                    <Button Visible="False" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" />
                     <Button Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" />
                     <Button Visible="False" Name="Ban" Text="{Loc 'admin-player-actions-ban'}" />
                     <Button Visible="False" Name="Respawn" Text="{Loc 'admin-player-actions-respawn'}" />
index cc05d0c06ac51b819adf763e3dd1e4e14ba6cf60..664ba220722a2d5285dfa769ae0e07454db991cc 100644 (file)
@@ -6,11 +6,13 @@ using Content.Client.Administration.UI.CustomControls;
 using Content.Client.Administration.UI.Tabs.AdminTab;
 using Content.Client.Stylesheets;
 using Content.Client.UserInterface.Systems.Bwoink;
+using Content.Client.UserInterface.Systems.Chat.Controls;
 using Content.Shared.Administration;
 using Robust.Client.AutoGenerated;
 using Robust.Client.Console;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.CustomControls;
 using Robust.Client.UserInterface.XAML;
 using Robust.Shared.Network;
 using Robust.Shared.Utility;
@@ -49,17 +51,9 @@ namespace Content.Client.Administration.UI.Bwoink
             ChannelSelector.OnSelectionChanged += sel =>
             {
                 _currentPlayer = sel;
-                if (sel == null)
-                {
-                    SetPlayerActionsVisibility(false);
-                }
-                else
+                if (sel is not null)
                 {
                     SwitchToChannel(sel.SessionId);
-
-                    SetPlayerActionsVisibility(true);
-                    Bans.Text = Loc.GetString("admin-player-actions-bans", ("count", sel.Bans));
-                    Notes.Text = Loc.GetString("admin-player-actions-notes", ("count", sel.Notes));
                 }
 
                 ChannelSelector.PlayerListContainer.DirtyList();
@@ -170,8 +164,6 @@ namespace Content.Client.Administration.UI.Bwoink
             {
                 uiController.PopOut();
             };
-
-            SetPlayerActionsVisibility(_currentPlayer != null);
         }
 
         private Dictionary<Control, (CancellationTokenSource cancellation, string? originalText)> Confirmations { get; } = new();
@@ -253,7 +245,8 @@ namespace Content.Client.Administration.UI.Bwoink
         {
             foreach (var bw in BwoinkArea.Children)
                 bw.Visible = false;
-            AHelpHelper.EnsurePanel(ch).Visible = true;
+            var panel = AHelpHelper.EnsurePanel(ch);
+            panel.Visible = true;
         }
 
         private bool TryConfirm(Button button)
@@ -280,15 +273,5 @@ namespace Content.Client.Administration.UI.Bwoink
             button.Text = Loc.GetString("admin-player-actions-confirm");
             return false;
         }
-
-        private void SetPlayerActionsVisibility(bool visible)
-        {
-            Bans.Visible = visible;
-            Notes.Visible = visible;
-            Kick.Visible = visible;
-            Ban.Visible = visible;
-            Respawn.Visible = visible;
-            Teleport.Visible = visible;
-        }
     }
 }
index 84b1667f1ff08aca4aead748a0c5456fde9d44e0..4e0156d7a050b9b26661e23ed32cd1465d8967ce 100644 (file)
@@ -1,6 +1,6 @@
 <DefaultWindow xmlns="https://spacestation14.io"
             xmlns:cc="clr-namespace:Content.Client.Administration.UI.Bwoink"
-            SetSize="1000 500"
+            SetSize="900 500"
             HeaderClass="windowHeaderAlert"
             TitleClass="windowTitleAlert"
             Title="{Loc 'bwoink-user-title'}" >
index c2b628f2632ecbbc52d83971db5819b3782f04ae..58217052b411bf4f194e336920fff676523f2138 100644 (file)
@@ -1,6 +1,20 @@
+using System.Text;
+using System.Threading;
+using Content.Client.Administration.Managers;
+using Content.Client.Administration.UI.CustomControls;
+using Content.Client.Administration.UI.Tabs.AdminTab;
+using Content.Client.Stylesheets;
+using Content.Client.UserInterface.Systems.Bwoink;
+using Content.Shared.Administration;
 using Robust.Client.AutoGenerated;
+using Robust.Client.Console;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.CustomControls;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Network;
+using Robust.Shared.Utility;
+using Timer = Robust.Shared.Timing.Timer;
 
 namespace Content.Client.Administration.UI.Bwoink
 {
index f6307e46c7f02f10db40803d24b2edfe7f718103..2ef1508084f508f17bb23107f2797d055eaeebd2 100644 (file)
@@ -124,11 +124,6 @@ public sealed class AdminNotesManager : IAdminNotesManager, IPostInjectInit
         return await _db.GetAdminNotes(player);
     }
 
-    public async Task<int> CountNotes(Guid player)
-    {
-        return await _db.CountAdminNotes(player);
-    }
-
     public async Task<string> GetPlayerName(Guid player)
     {
         return (await _db.GetPlayerRecordByUserId(new NetUserId(player)))?.LastSeenUserName ?? string.Empty;
index bf61a9ea8564be612313406f40525eb323ca301c..ae4e7712b27857631b65743436deccc9b2038e49 100644 (file)
@@ -20,6 +20,5 @@ public interface IAdminNotesManager
     Task DeleteNote(int noteId, IPlayerSession deletedBy);
     Task ModifyNote(int noteId, IPlayerSession editedBy, string message);
     Task<List<AdminNote>> GetNotes(Guid player);
-    Task<int> CountNotes(Guid player);
     Task<string> GetPlayerName(Guid player);
 }
index 1bae3894675a96f94603fa8051ddd3459bf09a21..48751e02c6af52165bebd283e851bd9e0daab985 100644 (file)
@@ -1,9 +1,7 @@
 using System.Globalization;
 using System.Linq;
-using System.Threading.Tasks;
 using Content.Server.Administration.Managers;
-using Content.Server.Administration.Notes;
-using Content.Server.Database;
+using Content.Server.GameTicking.Events;
 using Content.Server.IdentityManagement;
 using Content.Server.Players;
 using Content.Server.Roles;
@@ -15,7 +13,6 @@ using Robust.Server.GameObjects;
 using Robust.Server.Player;
 using Robust.Shared.Enums;
 using Robust.Shared.Network;
-using Job = Content.Server.Roles.Job;
 
 namespace Content.Server.Administration.Systems
 {
@@ -23,8 +20,6 @@ namespace Content.Server.Administration.Systems
     {
         [Dependency] private readonly IPlayerManager _playerManager = default!;
         [Dependency] private readonly IAdminManager _adminManager = default!;
-        [Dependency] private readonly IServerDbManager _db = default!;
-        [Dependency] private readonly IAdminNotesManager _notes = default!;
 
         private readonly Dictionary<NetUserId, PlayerInfo> _playerList = new();
 
@@ -49,7 +44,7 @@ namespace Content.Server.Administration.Systems
             SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestartCleanup);
         }
 
-        private async void OnRoundRestartCleanup(RoundRestartCleanupEvent ev)
+        private void OnRoundRestartCleanup(RoundRestartCleanupEvent ev)
         {
             _roundActivePlayers.Clear();
 
@@ -62,7 +57,7 @@ namespace Content.Server.Administration.Systems
                     return;
 
                 _playerManager.TryGetSessionById(id, out var session);
-                _playerList[id] = await GetPlayerInfo(playerData, session);
+                _playerList[id] = GetPlayerInfo(playerData, session);
             }
 
             var updateEv = new FullPlayerListEvent() { PlayersInfo = _playerList.Values.ToList() };
@@ -73,9 +68,9 @@ namespace Content.Server.Administration.Systems
             }
         }
 
-        public async void UpdatePlayerList(IPlayerSession player)
+        public void UpdatePlayerList(IPlayerSession player)
         {
-            _playerList[player.UserId] = await GetPlayerInfo(player.Data, player);
+            _playerList[player.UserId] = GetPlayerInfo(player.Data, player);
 
             var playerInfoChangedEvent = new PlayerInfoChangedEvent
             {
@@ -162,7 +157,7 @@ namespace Content.Server.Administration.Systems
             RaiseNetworkEvent(ev, playerSession.ConnectedClient);
         }
 
-        private async Task<PlayerInfo> GetPlayerInfo(IPlayerData data, IPlayerSession? session)
+        private PlayerInfo GetPlayerInfo(IPlayerData data, IPlayerSession? session)
         {
             var name = data.UserName;
             var entityName = string.Empty;
@@ -183,11 +178,8 @@ namespace Content.Server.Administration.Systems
 
             var connected = session != null && session.Status is SessionStatus.Connected or SessionStatus.InGame;
 
-            var bans = await _db.CountServerBansAsync(null, data.UserId, null);
-            var notes = await _notes.CountNotes(data.UserId);
-
             return new PlayerInfo(name, entityName, identityName, startingRole, antag, session?.AttachedEntity, data.UserId,
-                connected, _roundActivePlayers.Contains(data.UserId), bans, notes);
+                connected, _roundActivePlayers.Contains(data.UserId));
         }
     }
 }
index fedd0c96393242adf80f5fe159eba4a74c986f62..cb61f2422bb25ab74ba65862b9869812417defdd 100644 (file)
@@ -330,22 +330,6 @@ namespace Content.Server.Database
             ImmutableArray<byte>? hwId,
             bool includeUnbanned);
 
-        /// <summary>
-        ///     Counts an user's bans.
-        ///     This will return pardoned bans as well.
-        ///     One of <see cref="address"/> or <see cref="userId"/> need to not be null.
-        /// </summary>
-        /// <param name="address">The ip address of the user.</param>
-        /// <param name="userId">The id of the user.</param>
-        /// <param name="hwId">The HWId of the user.</param>
-        /// <param name="includeUnbanned">Include pardoned and expired bans.</param>
-        /// <returns>The user's ban history.</returns>
-        public abstract Task<int> CountServerBansAsync(
-            IPAddress? address,
-            NetUserId? userId,
-            ImmutableArray<byte>? hwId,
-            bool includeUnbanned);
-
         public abstract Task AddServerBanAsync(ServerBanDef serverBan);
         public abstract Task AddServerUnbanAsync(ServerUnbanDef serverUnban);
 
@@ -1012,19 +996,6 @@ namespace Content.Server.Database
                 .ToListAsync();
         }
 
-        public async Task<int> CountAdminNotes(Guid player)
-        {
-            await using var db = await GetDb();
-            return await db.DbContext.AdminNotes
-                .Where(note => note.PlayerUserId == player)
-                .Where(note => !note.Deleted)
-                .Include(note => note.Round)
-                .Include(note => note.CreatedBy)
-                .Include(note => note.LastEditedBy)
-                .Include(note => note.Player)
-                .CountAsync();
-        }
-
         public async Task DeleteAdminNote(int id, Guid deletedBy, DateTime deletedAt)
         {
             await using var db = await GetDb();
index 1b49655728c4060481e401fcd63504a244f0fa79..0a520706d1d80e8d72201cc00e31139931ff6101 100644 (file)
@@ -82,21 +82,6 @@ namespace Content.Server.Database
             ImmutableArray<byte>? hwId,
             bool includeUnbanned=true);
 
-        /// <summary>
-        ///     Counts an user's bans.
-        ///     One of <see cref="address"/> or <see cref="userId"/> need to not be null.
-        /// </summary>
-        /// <param name="address">The ip address of the user.</param>
-        /// <param name="userId">The id of the user.</param>
-        /// <param name="hwId">The HWId of the user.</param>
-        /// <param name="includeUnbanned">If true, bans that have been expired or pardoned are also included.</param>
-        /// <returns>The user's ban history.</returns>
-        Task<int> CountServerBansAsync(
-            IPAddress? address,
-            NetUserId? userId,
-            ImmutableArray<byte>? hwId,
-            bool includeUnbanned=true);
-
         Task AddServerBanAsync(ServerBanDef serverBan);
         Task AddServerUnbanAsync(ServerUnbanDef serverBan);
 
@@ -251,7 +236,6 @@ namespace Content.Server.Database
         Task<int> AddAdminNote(int? roundId, Guid player, string message, Guid createdBy, DateTime createdAt);
         Task<AdminNote?> GetAdminNote(int id);
         Task<List<AdminNote>> GetAdminNotes(Guid player);
-        Task<int> CountAdminNotes(Guid player);
         Task DeleteAdminNote(int id, Guid deletedBy, DateTime deletedAt);
         Task EditAdminNote(int id, string message, Guid editedBy, DateTime editedAt);
 
@@ -374,12 +358,6 @@ namespace Content.Server.Database
             return _db.GetServerBansAsync(address, userId, hwId, includeUnbanned);
         }
 
-        public Task<int> CountServerBansAsync(IPAddress? address, NetUserId? userId, ImmutableArray<byte>? hwId, bool includeUnbanned = true)
-        {
-            DbReadOpsMetric.Inc();
-            return _db.CountServerBansAsync(address, userId, hwId, includeUnbanned);
-        }
-
         public Task AddServerBanAsync(ServerBanDef serverBan)
         {
             DbWriteOpsMetric.Inc();
@@ -668,12 +646,6 @@ namespace Content.Server.Database
             return _db.GetAdminNotes(player);
         }
 
-        public Task<int> CountAdminNotes(Guid player)
-        {
-            DbReadOpsMetric.Inc();
-            return _db.CountAdminNotes(player);
-        }
-
         public Task DeleteAdminNote(int id, Guid deletedBy, DateTime deletedAt)
         {
             DbWriteOpsMetric.Inc();
index bf11817f200a4baf68cc5f49d1219b0de64d5618..cfc37da5460492bdd0f53d89563895fe82189ea9 100644 (file)
@@ -98,21 +98,6 @@ namespace Content.Server.Database
             return bans;
         }
 
-        public override async Task<int> CountServerBansAsync(IPAddress? address, NetUserId? userId, ImmutableArray<byte>? hwId, bool includeUnbanned)
-        {
-            if (address == null && userId == null && hwId == null)
-            {
-                throw new ArgumentException("Address, userId, and hwId cannot all be null");
-            }
-
-            await using var db = await GetDbImpl();
-
-            var exempt = await GetBanExemptionCore(db, userId);
-            var query = MakeBanLookupQuery(address, userId, hwId, db, includeUnbanned, exempt);
-
-            return await query.CountAsync();
-        }
-
         private static IQueryable<ServerBan> MakeBanLookupQuery(
             IPAddress? address,
             NetUserId? userId,
index f056847cb7129c0abc673e92ccc79f4110f0ef04..20b4f5c6288113eeb5055887603551e3b0b037e7 100644 (file)
@@ -97,22 +97,6 @@ namespace Content.Server.Database
                 .ToList()!;
         }
 
-        public override async Task<int> CountServerBansAsync(IPAddress? address, NetUserId? userId, ImmutableArray<byte>? hwId, bool includeUnbanned)
-        {
-            await using var db = await GetDbImpl();
-
-            var exempt = await GetBanExemptionCore(db, userId);
-
-            // SQLite can't do the net masking stuff we need to match IP address ranges.
-            // So just pull down the whole list into memory.
-            var queryBans = await GetAllBans(db.SqliteDbContext, includeUnbanned, exempt);
-
-            return queryBans
-                .Where(b => BanMatches(b, address, userId, hwId))
-                .Select(ConvertBan)
-                .Count();
-        }
-
         private static async Task<List<ServerBan>> GetAllBans(
             SqliteServerDbContext db,
             bool includeUnbanned,
index 3fc07d9e443ab7ce7286e59f7eead5a4233d6fe8..d6b3f0c0dcab1441052bfbe3d8cbbda7c62bdcc2 100644 (file)
@@ -13,7 +13,5 @@ namespace Content.Shared.Administration
         EntityUid? EntityUid,
         NetUserId SessionId,
         bool Connected,
-        bool ActiveThisRound,
-        int Bans,
-        int Notes);
+        bool ActiveThisRound);
 }
index fa790fb9f10bf6b6ce51a5a31ed3a709ad88e0b6..86a5e150392c7cd6fab26004ee0114253abb5be2 100644 (file)
@@ -1,5 +1,5 @@
-admin-player-actions-bans = Ban List ({$count})
-admin-player-actions-notes = Notes ({$count})
+admin-player-actions-bans = Ban List
+admin-player-actions-notes = Notes
 admin-player-actions-kick = Kick
 admin-player-actions-ban = Ban
 admin-player-actions-ahelp = AHelp