Add admin moderation and sync acknowledgements
This commit is contained in:
@@ -12,7 +12,7 @@ import { requireInitialSetup } from "@/lib/setup";
|
||||
import { DataTable, EmptyState, MetricTile, PageHeader, Panel, StatusDot, Tabs } from "@/components/ui";
|
||||
import { getAppSettings, type AppSettings } from "@/lib/settings";
|
||||
import { updateInstanceSettings, updateSecuritySettings } from "@/lib/settings-actions";
|
||||
import { createInstanceInvite, disableUser, enableUser, grantAdminRole, revokeAdminRole, revokeInvite } from "@/lib/admin-actions";
|
||||
import { banUser, createInstanceInvite, disableUser, enableUser, grantAdminRole, removeUserFriendships, revokeAdminRole, revokeInvite } from "@/lib/admin-actions";
|
||||
import { deleteRoom } from "@/lib/room-actions";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -34,7 +34,10 @@ export default async function AdminPage({ searchParams }: { searchParams: Promis
|
||||
|
||||
const [users, rooms, roles, pendingRequests, appSettings, invites, auditEvents] = await Promise.all([
|
||||
prisma.user.findMany({
|
||||
include: { roles: { include: { role: true } }, _count: { select: { ownedRooms: true, roomMembers: true } } },
|
||||
include: {
|
||||
roles: { include: { role: true } },
|
||||
_count: { select: { ownedRooms: true, roomMembers: true, sentFriends: true, gotFriends: true } }
|
||||
},
|
||||
orderBy: { createdAt: "asc" }
|
||||
}),
|
||||
prisma.room.findMany({
|
||||
@@ -129,7 +132,7 @@ function UsersTable({
|
||||
disabledAt: Date | null;
|
||||
createdAt: Date;
|
||||
roles: Array<{ roleId: string; role: { name: string } }>;
|
||||
_count: { ownedRooms: number; roomMembers: number };
|
||||
_count: { ownedRooms: number; roomMembers: number; sentFriends: number; gotFriends: number };
|
||||
}>;
|
||||
currentUserId: string;
|
||||
}) {
|
||||
@@ -141,6 +144,7 @@ function UsersTable({
|
||||
<th>User</th>
|
||||
<th>Roles</th>
|
||||
<th>Rooms</th>
|
||||
<th>Friends</th>
|
||||
<th>Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
@@ -168,6 +172,7 @@ function UsersTable({
|
||||
</div>
|
||||
</td>
|
||||
<td>{account._count.ownedRooms + account._count.roomMembers}</td>
|
||||
<td>{account._count.sentFriends + account._count.gotFriends}</td>
|
||||
<td>{account.disabledAt ? <StatusBadge tone="danger">disabled</StatusBadge> : formatDate(account.createdAt)}</td>
|
||||
<td>
|
||||
<div className="row-actions">
|
||||
@@ -193,6 +198,18 @@ function UsersTable({
|
||||
<button className="button compact-button danger" type="submit" disabled={account.id === currentUserId}>Disable</button>
|
||||
</form>
|
||||
)}
|
||||
<form action={removeUserFriendships}>
|
||||
<input type="hidden" name="userId" value={account.id} />
|
||||
<button className="button compact-button danger" type="submit" disabled={account.id === currentUserId || account._count.sentFriends + account._count.gotFriends === 0}>
|
||||
Remove friends
|
||||
</button>
|
||||
</form>
|
||||
<form action={banUser}>
|
||||
<input type="hidden" name="userId" value={account.id} />
|
||||
<button className="button compact-button danger" type="submit" disabled={account.id === currentUserId || Boolean(account.disabledAt)}>
|
||||
Ban
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user