Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/community/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
21 changes: 18 additions & 3 deletions src/community/pages/Admin.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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'}
];

Expand All @@ -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('');
Expand Down Expand Up @@ -271,7 +286,7 @@ const Admin = () => {

{active === 'users' ? (
<section className={styles.card}>
<UserManager />
<UserManager selected={selectedUser} onSelect={selectUser} />
</section>
) : null}

Expand Down
243 changes: 241 additions & 2 deletions src/community/pages/Admin.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@

.userToolbar {
display: grid;
grid-template-columns: minmax(220px, 1fr) auto auto;
grid-template-columns: minmax(220px, 1fr) auto;
gap: 10px;
align-items: center;
margin-bottom: 16px;
margin-bottom: 12px;
}

.pagination {
Expand Down Expand Up @@ -815,3 +815,242 @@
.storageGrid {grid-template-columns: 1fr;}
.userToolbar {grid-template-columns: 1fr;}
}

.badgeWarn {
color: #E5A84B;
background: color-mix(in srgb, #E5A84B 14%, transparent);
border-color: transparent;
}

.userList,
.flatList {
display: flex;
flex-direction: column;
padding: 2px 16px;
border-radius: var(--radius-sm);
background: var(--bg-card);
}

.userRow,
.flatRow {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 0;
border-bottom: 1px solid var(--border-soft);
}

.userRow:last-child,
.flatRow:last-child {
border-bottom: 0;
}

.userRow:hover .row-title,
.userRow:focus-visible .row-title {
color: var(--accent-strong);
}

.dossier {
display: flex;
flex-direction: column;
gap: 16px;
}

.dossier > .backButton {
align-self: flex-start;
margin-bottom: 0;
}

.dossierHead {
display: flex;
align-items: flex-start;
gap: 16px;
padding: 18px;
border-radius: var(--radius);
background: var(--bg-card);
}

.dossierIdentity {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
flex: 1;
}

.dossierName {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
margin: 0;
font-size: var(--fs-xl);
}

.dossierName .badge {
margin-inline-start: 0;
}

.dossierBio {
margin: 4px 0 0;
font-size: var(--fs-sm);
color: var(--text-dim);
white-space: pre-wrap;
overflow-wrap: anywhere;
}

.idButton {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 2px 8px;
border: 0;
border-radius: var(--radius-2xs);
background: var(--bg-raised);
color: var(--text-dim);
font: inherit;
cursor: pointer;
}

.idButton code {
font-size: var(--fs-xs);
}

.idButton:hover {
color: var(--mw-text);
}

.facts {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
}

.fact {
display: flex;
flex-direction: column;
gap: 3px;
min-width: 0;
padding: 14px;
border-radius: var(--radius-sm);
background: var(--bg-card);
}

.factLabel {
font-size: var(--fs-xs);
color: var(--text-dim);
}

.factValue {
font-size: var(--fs-lg);
font-weight: 700;
color: var(--mw-text);
overflow-wrap: anywhere;
}

.factDetail {
font-size: var(--fs-xs);
color: var(--text-faint);
}

.dossierGrid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 12px;
align-items: start;
}

.panel {
display: flex;
flex-direction: column;
gap: 10px;
padding: 16px;
border-radius: var(--radius-sm);
background: var(--bg-card);
}

.panel .flatList {
padding: 0;
background: transparent;
}

.panelFooter {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}

.detailList {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
gap: 8px 16px;
margin: 0;
font-size: var(--fs-sm);
}

.detailList dt {
color: var(--text-dim);
}

.detailList dd {
display: flex;
flex-wrap: wrap;
gap: 4px 10px;
margin: 0;
color: var(--mw-text);
}

.inlineLink {
color: var(--accent-strong);
}

.mutedLine {
margin: 0;
font-size: var(--fs-sm);
color: var(--text-dim);
}

.snapshot {
padding: 8px 10px;
border-radius: var(--radius-xs);
background: var(--bg-raised);
font-size: var(--fs-sm);
color: var(--text-dim);
white-space: pre-wrap;
overflow-wrap: anywhere;
}

.commentText {
font-size: var(--fs-md);
white-space: pre-wrap;
overflow-wrap: anywhere;
}

.stack {
display: flex;
flex-direction: column;
gap: 20px;
}

@media (max-width: 620px) {
.facts {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dossierHead {
flex-wrap: wrap;
}

.dossierIdentity {
flex-basis: calc(100% - 72px);
}

.idButton code {
overflow-wrap: anywhere;
}

.userToolbar {
grid-template-columns: 1fr;
}
}
4 changes: 3 additions & 1 deletion src/community/pages/admin/BansSection.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable max-len */
import React from 'react';
import {Link} from 'react-router-dom';
import {useCommunityIntl as useCommunityText} from '../../i18n.jsx';
import {Ban} from 'lucide-react';
import Avatar from '../../components/Avatar.jsx';
Expand All @@ -8,6 +9,7 @@ import EmptyState from '../../components/ui/EmptyState.jsx';
import SectionHeading from '../../components/ui/SectionHeading.jsx';
import {timeAgo} from '../../format';
import styles from '../Admin.module.css';
import {adminUserPath} from './admin-links.js';

// Banned users, with a button to ban someone by name.
const BansSection = ({bans, banByName, unban}) => {
Expand All @@ -31,7 +33,7 @@ const BansSection = ({bans, banByName, unban}) => {
size={28}
/>
<div className={styles.rowInfo}>
<span className={styles.rowTitle}>{`@${ban.username}`}</span>
<span className={styles.rowTitle}><Link to={adminUserPath(ban.username)}>{`@${ban.username}`}</Link></span>
<span className={styles.rowMeta}>
{communityText('Banned by @{value1}{value2}', {value1: ban.by, value2: timeAgo(ban.created) ? ` · ${timeAgo(ban.created)} ago` : ''})}
{ban.reason ? ` · ${ban.reason}` : ''}
Expand Down
7 changes: 6 additions & 1 deletion src/community/pages/admin/ReportsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import {Link} from 'react-router-dom';
import {useCommunityIntl as useCommunityText} from '../../i18n.jsx';
import {Flag} from 'lucide-react';
import {Flag, UserSearch} from 'lucide-react';
import {projectUrl} from '../../api';
import Button from '../../components/ui/Button.jsx';
import EmptyState from '../../components/ui/EmptyState.jsx';
Expand All @@ -11,6 +11,7 @@ import StatusMessage from '../../components/ui/StatusMessage.jsx';
import {timeAgo} from '../../format';
import styles from '../Admin.module.css';
import EvidencePanel from './EvidencePanel.jsx';
import {adminUserPath} from './admin-links.js';

// The open moderation queue: reports and support requests with their actions.
const ReportsSection = ({reports, openCount, replyToSupport, act, warnFromReport, banFromReport}) => {
Expand Down Expand Up @@ -76,6 +77,10 @@ const ReportsSection = ({reports, openCount, replyToSupport, act, warnFromReport
) : null}
</div>
<div className={styles.rowActions}>
{report.type === 'support' || report.subject || report.targetUser || report.type === 'user' ? (
<Button as={Link} to={adminUserPath(report.type === 'support' ? report.reporter : (report.subject || report.targetUser || report.target))}>
<UserSearch size={15} />{communityText('View account')}</Button>
) : null}
{report.type === 'support' ? (
<Button onClick={() => replyToSupport(report)}>{communityText('Reply and close')}</Button>
) : null}
Expand Down
Loading
Loading