import { ExternalLink, Server } from 'lucide-react' import Link from 'next/link' import { EmulatorSettingsForm } from '@/app/[locale]/admin/settings/emulator/emulator-settings-form' import { Button } from '@/components/ui/button' import type { Prisma } from '@/generated/prisma/client' import { calcPagination } from '@/lib/admin-helpers' import { prisma } from '@/lib/prisma' // SQL `LIKE` patterns that capture the user-facing strings inside // `emulator_settings`. Anything not matching is config (timeouts, ports, IDs) // and lives in /admin/settings/emulator instead. const TRANSLATION_KEY_PATTERNS = [ 'commands.description.%', 'commands.keys.%', 'commands.cmd_%', 'wordfilter.%', 'pet.%message%', 'matchmaking.%message%', 'message.%', 'notification.%', ] as const export default async function EmulatorTranslationsPage({ searchParams, }: { searchParams: Promise> }) { const sp = await searchParams const search = sp.search || '' const group = sp.group || '' const perPage = Math.min(Math.max(parseInt(sp.perPage || '50', 10), 10), 200) const page = Math.max(parseInt(sp.page || '1', 10), 1) const patternFilters: Prisma.EmulatorSettingWhereInput[] = TRANSLATION_KEY_PATTERNS.map((p) => ({ key: { contains: p.replace(/%/g, '') }, })) const baseFilter: Prisma.EmulatorSettingWhereInput = { OR: patternFilters } const conditions: Prisma.EmulatorSettingWhereInput[] = [baseFilter] if (group) conditions.push({ key: { startsWith: `${group}.` } }) if (search) { conditions.push({ OR: [{ key: { contains: search } }, { value: { contains: search } }], }) } const where: Prisma.EmulatorSettingWhereInput = { AND: conditions } const [settings, total, allKeys] = await Promise.all([ prisma.emulatorSetting.findMany({ where, orderBy: { key: 'asc' }, skip: (page - 1) * perPage, take: perPage, }), prisma.emulatorSetting.count({ where }), // Group chips reflect the WHOLE translation-pattern subset (so they don't // disappear when you click one); we ignore the group/search filters here. prisma.emulatorSetting.findMany({ where: baseFilter, select: { key: true }, }), ]) const groupCounts = new Map() for (const { key } of allKeys) { const g = key.includes('.') ? key.split('.')[0] : 'general' groupCounts.set(g, (groupCounts.get(g) ?? 0) + 1) } const allGroups = Array.from(groupCounts.entries()) .map(([name, count]) => ({ name, count })) .sort((a, b) => a.name.localeCompare(b.name)) const pagination = calcPagination(total, page, perPage) const settingsMap = settings.map((s) => ({ key: s.key, value: s.value })) return (

Emulator

Sottoinsieme di emulator_settings con stringhe utente (comandi, wordfilter, messaggi pet/matchmaking).

Le impostazioni di configurazione (porte, timeout, ID) non compaiono qui — usa il link «Impostazioni complete». Le modifiche salvate sono sincronizzate con l'emulatore via RCON.
) }