revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
@@ -1,55 +1,55 @@
|
||||
import { ExternalLink, Server } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { EmulatorSettingsForm } from "@/components/admin/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";
|
||||
import { ExternalLink, Server } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import { EmulatorSettingsForm } from '@/components/admin/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;
|
||||
'commands.description.%',
|
||||
'commands.keys.%',
|
||||
'commands.cmd_%',
|
||||
'wordfilter.%',
|
||||
'pet.%message%',
|
||||
'matchmaking.%message%',
|
||||
'message.%',
|
||||
'notification.%',
|
||||
] as const
|
||||
|
||||
export default async function EmulatorTranslationsPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<Record<string, string | undefined>>;
|
||||
searchParams: Promise<Record<string, string | undefined>>
|
||||
}) {
|
||||
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 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.EmulatorSettingsWhereInput[] = TRANSLATION_KEY_PATTERNS.map((p) => ({
|
||||
key: { contains: p.replace(/%/g, "") },
|
||||
}));
|
||||
key: { contains: p.replace(/%/g, '') },
|
||||
}))
|
||||
|
||||
const baseFilter: Prisma.EmulatorSettingsWhereInput = { OR: patternFilters };
|
||||
const baseFilter: Prisma.EmulatorSettingsWhereInput = { OR: patternFilters }
|
||||
|
||||
const conditions: Prisma.EmulatorSettingsWhereInput[] = [baseFilter];
|
||||
if (group) conditions.push({ key: { startsWith: `${group}.` } });
|
||||
const conditions: Prisma.EmulatorSettingsWhereInput[] = [baseFilter]
|
||||
if (group) conditions.push({ key: { startsWith: `${group}.` } })
|
||||
if (search) {
|
||||
conditions.push({
|
||||
OR: [{ key: { contains: search } }, { value: { contains: search } }],
|
||||
});
|
||||
})
|
||||
}
|
||||
const where: Prisma.EmulatorSettingsWhereInput = { AND: conditions };
|
||||
const where: Prisma.EmulatorSettingsWhereInput = { AND: conditions }
|
||||
|
||||
const [settings, total, allKeys] = await Promise.all([
|
||||
prisma.emulatorSettings.findMany({
|
||||
where,
|
||||
orderBy: { key: "asc" },
|
||||
orderBy: { key: 'asc' },
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
}),
|
||||
@@ -60,19 +60,19 @@ export default async function EmulatorTranslationsPage({
|
||||
where: baseFilter,
|
||||
select: { key: true },
|
||||
}),
|
||||
]);
|
||||
])
|
||||
|
||||
const groupCounts = new Map<string, number>();
|
||||
const groupCounts = new Map<string, number>()
|
||||
for (const { key } of allKeys) {
|
||||
const g = key.includes(".") ? key.split(".")[0] : "general";
|
||||
groupCounts.set(g, (groupCounts.get(g) ?? 0) + 1);
|
||||
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));
|
||||
.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 }));
|
||||
const pagination = calcPagination(total, page, perPage)
|
||||
const settingsMap = settings.map((s) => ({ key: s.key, value: s.value }))
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -83,8 +83,8 @@ export default async function EmulatorTranslationsPage({
|
||||
Emulator
|
||||
</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Sottoinsieme di <code className="text-xs">emulator_settings</code> con stringhe utente (comandi,
|
||||
wordfilter, messaggi pet/matchmaking).
|
||||
Sottoinsieme di <code className="text-xs">emulator_settings</code> con stringhe utente
|
||||
(comandi, wordfilter, messaggi pet/matchmaking).
|
||||
</p>
|
||||
</div>
|
||||
<Button asChild variant="outline" size="sm">
|
||||
@@ -96,8 +96,9 @@ export default async function EmulatorTranslationsPage({
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border bg-muted/40 px-3 py-2 text-xs text-muted-foreground">
|
||||
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.
|
||||
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.
|
||||
</div>
|
||||
|
||||
<EmulatorSettingsForm
|
||||
@@ -108,5 +109,5 @@ export default async function EmulatorTranslationsPage({
|
||||
activeGroup={group}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user