Remove deprecated ModulePlaceholderPage component for dashboard modules. This file was previously used as a catch-all for remaining modules but is no longer needed due to the introduction of dedicated route folders for Batch A modules.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { CommandOverrideDashboardUpsertSchema } from '@nexumi/shared';
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
import { requireGuildAccess, toApiErrorResponse } from '@/lib/auth';
|
||||
import { writeDashboardAudit } from '@/lib/audit';
|
||||
import { resetCommandOverrideDashboard, upsertCommandOverrideDashboard } from '@/lib/module-configs/commands';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
interface RouteParams {
|
||||
params: Promise<{ guildId: string; commandName: string }>;
|
||||
}
|
||||
|
||||
export async function PATCH(request: NextRequest, { params }: RouteParams) {
|
||||
const { guildId, commandName } = await params;
|
||||
try {
|
||||
const session = await requireGuildAccess(guildId);
|
||||
const body = await request.json();
|
||||
const input = CommandOverrideDashboardUpsertSchema.parse({ ...body, commandName });
|
||||
|
||||
const updated = await upsertCommandOverrideDashboard(guildId, input);
|
||||
|
||||
await writeDashboardAudit(prisma, {
|
||||
guildId,
|
||||
actorUserId: session.user.id,
|
||||
action: 'commands.update',
|
||||
path: `/dashboard/${guildId}/commands`,
|
||||
after: updated
|
||||
});
|
||||
|
||||
return NextResponse.json(updated);
|
||||
} catch (error) {
|
||||
return toApiErrorResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(_request: NextRequest, { params }: RouteParams) {
|
||||
const { guildId, commandName } = await params;
|
||||
try {
|
||||
const session = await requireGuildAccess(guildId);
|
||||
const reset = await resetCommandOverrideDashboard(guildId, commandName);
|
||||
|
||||
await writeDashboardAudit(prisma, {
|
||||
guildId,
|
||||
actorUserId: session.user.id,
|
||||
action: 'commands.reset',
|
||||
path: `/dashboard/${guildId}/commands`,
|
||||
after: reset
|
||||
});
|
||||
|
||||
return NextResponse.json(reset);
|
||||
} catch (error) {
|
||||
return toApiErrorResponse(error);
|
||||
}
|
||||
}
|
||||
18
apps/webui/src/app/api/guilds/[guildId]/commands/route.ts
Normal file
18
apps/webui/src/app/api/guilds/[guildId]/commands/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
import { requireGuildAccess, toApiErrorResponse } from '@/lib/auth';
|
||||
import { listCommandOverridesDashboard } from '@/lib/module-configs/commands';
|
||||
|
||||
interface RouteParams {
|
||||
params: Promise<{ guildId: string }>;
|
||||
}
|
||||
|
||||
export async function GET(_request: NextRequest, { params }: RouteParams) {
|
||||
const { guildId } = await params;
|
||||
try {
|
||||
await requireGuildAccess(guildId);
|
||||
const commands = await listCommandOverridesDashboard(guildId);
|
||||
return NextResponse.json({ commands });
|
||||
} catch (error) {
|
||||
return toApiErrorResponse(error);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import { DASHBOARD_MODULES, type DashboardModuleId } from '@nexumi/shared';
|
||||
import { Construction } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { getLocale, t } from '@/lib/i18n';
|
||||
|
||||
/**
|
||||
* Batch A modules (Phase 7) got dedicated route folders (e.g.
|
||||
* `dashboard/[guildId]/moderation/page.tsx`), which Next.js prefers over this
|
||||
* catch-all - so they never reach this component. This placeholder now only
|
||||
* serves the remaining Batch B/C modules until they get dedicated pages too.
|
||||
*/
|
||||
const REMAINING_MODULE_IDS: ReadonlySet<DashboardModuleId> = new Set([
|
||||
'giveaways',
|
||||
'tickets',
|
||||
'selfroles',
|
||||
'tags',
|
||||
'starboard',
|
||||
'suggestions',
|
||||
'birthdays',
|
||||
'tempvoice',
|
||||
'stats',
|
||||
'feeds',
|
||||
'scheduler',
|
||||
'guildbackup'
|
||||
]);
|
||||
|
||||
interface ModulePlaceholderPageProps {
|
||||
params: Promise<{ guildId: string; module: string }>;
|
||||
}
|
||||
|
||||
export default async function ModulePlaceholderPage({ params }: ModulePlaceholderPageProps) {
|
||||
const { guildId, module: moduleHref } = await params;
|
||||
const moduleEntry = DASHBOARD_MODULES.find((entry) => entry.href === moduleHref);
|
||||
|
||||
if (!moduleEntry || !REMAINING_MODULE_IDS.has(moduleEntry.id)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const locale = await getLocale();
|
||||
const moduleLabel = t(locale, `modules.${moduleEntry.id}.label`);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardContent className="flex flex-col items-center gap-4 py-16 text-center">
|
||||
<div className="flex size-12 items-center justify-center rounded-full bg-muted">
|
||||
<Construction className="size-6 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<h1 className="text-xl font-semibold">{t(locale, 'modulePlaceholder.title', { module: moduleLabel })}</h1>
|
||||
<p className="text-sm text-muted-foreground">{t(locale, 'modulePlaceholder.message')}</p>
|
||||
</div>
|
||||
<Link href={`/dashboard/${guildId}/modules`} className="text-sm text-primary hover:underline">
|
||||
{t(locale, 'modulePlaceholder.backToModules')}
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
14
apps/webui/src/app/dashboard/[guildId]/backup/loading.tsx
Normal file
14
apps/webui/src/app/dashboard/[guildId]/backup/loading.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
|
||||
export default function BackupLoading() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-8 w-48" />
|
||||
<Skeleton className="h-4 w-80" />
|
||||
</div>
|
||||
<Skeleton className="h-48 rounded-lg" />
|
||||
<Skeleton className="h-64 rounded-lg" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
30
apps/webui/src/app/dashboard/[guildId]/backup/page.tsx
Normal file
30
apps/webui/src/app/dashboard/[guildId]/backup/page.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { GuildBackupManager } from '@/components/modules/guild-backup-manager';
|
||||
import { requireAuthOrRedirect } from '@/lib/auth';
|
||||
import { fetchDiscordUserGuildsCached } from '@/lib/discord-oauth';
|
||||
import { getLocale, t } from '@/lib/i18n';
|
||||
import { listGuildBackupsDashboard } from '@/lib/module-configs/guildbackup';
|
||||
|
||||
interface BackupPageProps {
|
||||
params: Promise<{ guildId: string }>;
|
||||
}
|
||||
|
||||
export default async function BackupPage({ params }: BackupPageProps) {
|
||||
const { guildId } = await params;
|
||||
const session = await requireAuthOrRedirect();
|
||||
const [locale, backups, discordGuilds] = await Promise.all([
|
||||
getLocale(),
|
||||
listGuildBackupsDashboard(guildId),
|
||||
fetchDiscordUserGuildsCached(session.accessToken)
|
||||
]);
|
||||
const isOwner = discordGuilds.find((guild) => guild.id === guildId)?.owner ?? false;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">{t(locale, 'modules.guildbackup.label')}</h1>
|
||||
<p className="text-sm text-muted-foreground">{t(locale, 'modules.guildbackup.description')}</p>
|
||||
</div>
|
||||
<GuildBackupManager guildId={guildId} initialBackups={backups} isOwner={isOwner} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user