From ee9fa9e3a6ea69fa5d101225a7530df12929aae7 Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Tue, 6 Oct 2026 19:42:27 +0100
Subject: [PATCH] Turn the admin user view into a full account page
Users can be filtered to warned or banned, joined this week, under 18
or admins, and found by Rotur ID as well as name. Each row shows admin,
standing and under-18 badges and when they joined.
Opening someone shows their Rotur ID, plan, last sign-in and sessions,
storage, project totals and open reports at a glance, with tabs for an
overview (a private admin note, account details, spaces and classes),
projects, reports about them and by them, their recent comments,
activity, and moderation (standing with its history, ban record, a
message, profile comments).
The section and user live in the URL, so /admin?section=users&user=name
opens straight to someone, and reports and bans link to the person.
Errors move into the System group in the sidebar.
---
src/community/api.js | 6 +-
src/community/pages/Admin.jsx | 21 +-
src/community/pages/Admin.module.css | 243 +++++++-
src/community/pages/admin/BansSection.jsx | 4 +-
src/community/pages/admin/ReportsSection.jsx | 7 +-
src/community/pages/admin/UserDetailCard.jsx | 527 +++++++++++++----
src/community/pages/admin/UserManager.jsx | 89 ++-
src/community/pages/admin/admin-links.js | 18 +
src/community/translations/_sources.json | 542 ++++++++++++------
src/community/translations/en.json | 86 ++-
.../unit/community-admin-user-detail.test.jsx | 150 +++++
11 files changed, 1365 insertions(+), 328 deletions(-)
create mode 100644 src/community/pages/admin/admin-links.js
create mode 100644 test/unit/community-admin-user-detail.test.jsx
diff --git a/src/community/api.js b/src/community/api.js
index c3c540a4c1c..0643e5dfd2c 100644
--- a/src/community/api.js
+++ b/src/community/api.js
@@ -331,13 +331,15 @@ const api = {
request('/admin/user/message', {method: 'POST', body: {username, message}}),
updateUserProfile: (username, patch) =>
request('/admin/user/profile', {method: 'POST', body: {username, ...patch}}),
+ setUserNote: (username, note) =>
+ request('/admin/user/note', {method: 'POST', body: {username, note}}),
searchProjects: q => request(`/admin/projects?q=${encodeURIComponent(q)}`),
stats: (days = 30) => request(`/admin/stats?days=${encodeURIComponent(days)}`),
storage: () => request('/admin/storage'),
syncStorage: () => request('/admin/storage/sync', {method: 'POST'}),
- users: ({q = '', offset = 0, limit = 30, sort = 'name'} = {}) => request(
+ users: ({q = '', offset = 0, limit = 30, sort = 'name', filter = ''} = {}) => request(
`/admin/users?q=${encodeURIComponent(q)}&offset=${encodeURIComponent(offset)}` +
- `&limit=${encodeURIComponent(limit)}&sort=${encodeURIComponent(sort)}`
+ `&limit=${encodeURIComponent(limit)}&sort=${encodeURIComponent(sort)}&filter=${encodeURIComponent(filter)}`
),
extensions: () => request('/admin/extensions', {cache: false}),
setExtensionPolicy: (hash, status) =>
diff --git a/src/community/pages/Admin.jsx b/src/community/pages/Admin.jsx
index 030e9aa2a66..54b034bed8d 100644
--- a/src/community/pages/Admin.jsx
+++ b/src/community/pages/Admin.jsx
@@ -1,6 +1,7 @@
import {useCommunityIntl as useCommunityText} from '../i18n.jsx';
/* eslint-disable max-len */
import React, {useRef, useState} from 'react';
+import {useSearchParams} from 'react-router-dom';
import {
Activity, AlertTriangle, Ban, BarChart3, Flag, FolderOpen, HardDrive, Puzzle, ShieldCheck, User
} from 'lucide-react';
@@ -29,12 +30,12 @@ const SECTIONS = [
{key: 'overview', label: 'Overview', icon: BarChart3},
{key: 'storage', label: 'Storage and runtime', icon: HardDrive, group: 'System'},
{key: 'activity', label: 'Activity', icon: Activity, group: 'System'},
+ {key: 'errors', label: 'Errors', icon: AlertTriangle, group: 'System'},
{key: 'reports', label: 'Reports', icon: Flag, group: 'Moderation'},
{key: 'users', label: 'Users', icon: User, group: 'Moderation'},
{key: 'bans', label: 'Bans', icon: Ban, group: 'Moderation'},
{key: 'projects', label: 'Projects', icon: FolderOpen, group: 'Content'},
{key: 'extensions', label: 'Extensions', icon: Puzzle, group: 'Content'},
- {key: 'errors', label: 'Errors', icon: AlertTriangle, group: 'System'},
{key: 'admins', label: 'Admins', icon: ShieldCheck, group: 'Access'}
];
@@ -43,7 +44,21 @@ const Admin = () => {
const {user, loading} = useUser();
const {reports, openErrors, bans, admins, error, setError, load} = useAdminData(user);
const [newAdmin, setNewAdmin] = useState('');
- const [active, setActive] = useState('overview');
+ const [searchParams, setSearchParams] = useSearchParams();
+ const requested = searchParams.get('section');
+ const active = SECTIONS.some(section => section.key === requested) ? requested : 'overview';
+ const selectedUser = searchParams.get('user') || null;
+ const setActive = key => {
+ const params = new URLSearchParams();
+ if (key !== 'overview') params.set('section', key);
+ setSearchParams(params);
+ };
+ const selectUser = name => {
+ const params = new URLSearchParams();
+ params.set('section', 'users');
+ if (name) params.set('user', name);
+ setSearchParams(params);
+ };
const [dialog, setDialog] = useState(null);
const [dialogBusy, setDialogBusy] = useState(false);
const [dialogError, setDialogError] = useState('');
@@ -271,7 +286,7 @@ const Admin = () => {
{active === 'users' ? (
{empty}
+); + +ReportList.propTypes = { + reports: PropTypes.arrayOf(PropTypes.object).isRequired, + empty: PropTypes.node.isRequired, + communityText: PropTypes.func.isRequired +}; + const UserDetailCard = ({username, onBack}) => { const {text: communityText} = useCommunityText(); const [data, setData] = useState(null); const [error, setError] = useState(''); const [note, setNote] = useState(''); + const [tab, setTab] = useState('overview'); const [level, setLevel] = useState('good'); const [reasonText, setReasonText] = useState(''); const [message, setMessage] = useState(''); + const [adminNote, setAdminNote] = useState(''); + const [noteBusy, setNoteBusy] = useState(false); const [dialog, setDialog] = useState(null); const [dialogBusy, setDialogBusy] = useState(false); const [dialogError, setDialogError] = useState(''); @@ -35,6 +110,7 @@ const UserDetailCard = ({username, onBack}) => { setData(null); setError(''); setNote(''); + setTab('overview'); setDialog(null); setDialogError(''); setDialogBusy(false); @@ -43,6 +119,7 @@ const UserDetailCard = ({username, onBack}) => { if (!active) return; setData(result); setLevel((result.standing && result.standing.level) || 'good'); + setAdminNote((result.note && result.note.text) || ''); setReasonText(''); setMessage(''); }) @@ -66,54 +143,43 @@ const UserDetailCard = ({username, onBack}) => { .catch(() => {}); }; - const applyStanding = async () => { - if (!data) return; + const run = async (action, success) => { setError(''); setNote(''); try { - await api.admin.setStanding(data.username, level, reasonText.trim()); - setNote(communityText('Standing updated.')); + await action(); + if (success) setNote(success); refresh(); } catch (e) { setError(e.message || 'Action failed.'); } }; + const applyStanding = () => run( + () => api.admin.setStanding(data.username, level, reasonText.trim()), + communityText('Standing updated.') + ); + const sendMessage = async () => { - if (!data || !message.trim()) return; - setError(''); - setNote(''); - try { - await api.admin.messageUser(data.username, message.trim()); - setNote(communityText('Message sent.')); - setMessage(''); - } catch (e) { - setError(e.message || 'Action failed.'); - } + if (!message.trim()) return; + await run(() => api.admin.messageUser(data.username, message.trim()), communityText('Message sent.')); + setMessage(''); }; - const toggleComments = async () => { - if (!data) return; - setError(''); - setNote(''); - try { - await api.admin.updateUserProfile(data.username, {commentsOff: !data.commentsOff}); - refresh(); - } catch (e) { - setError(e.message || 'Action failed.'); - } + const toggleComments = () => run(() => api.admin.updateUserProfile(data.username, {commentsOff: !data.commentsOff})); + + const saveNote = async () => { + setNoteBusy(true); + await run(() => api.admin.setUserNote(data.username, adminNote.trim()), communityText('Note saved.')); + setNoteBusy(false); }; - const unshareProject = async pid => { - try { - await api.unpublish(pid); - setNote(communityText('Project unshared.')); - refresh(); - } catch (e) { - setError(e.message || 'Could not unshare.'); - } + const copyId = () => { + if (navigator.clipboard && data.userId) navigator.clipboard.writeText(data.userId).catch(() => {}); }; + const unshareProject = pid => run(() => api.unpublish(pid), communityText('Project unshared.')); + const deleteProject = pid => { if (deleteInFlight.current) return; const project = (data.projects || []).find(item => item.id === pid); @@ -149,7 +215,7 @@ const UserDetailCard = ({username, onBack}) => { } }; - if (error) { + if (error && !data) { return ({data.bio}
: null}+ {communityText('Rotur marks accounts without a date of birth as under 18, so this may be an adult who has not added one.')} +
+ ) : null} +{communityText('Goes back to good standing on {value1}.', {value1: formatDate(standing.recoverAt)})}
+ ) : null} + {data.banned && data.ban && data.ban.created ? ( ++ {communityText('Banned by @{value1} on {value2}.', {value1: data.ban.by || '', value2: formatDate(data.ban.created)})} + {data.ban.reason ? ` ${data.ban.reason}` : ''} +
+ ) : null} + {(standing.history || []).length ? ( +{communityText('No standing changes recorded.')}
} +