sonda/web/src/pages/admin/AdminLayout.tsx
tgiachi 4ede6d4118 feat(web): a Duplicates section in the admin area
I can now see the songs that are in more than one file and delete the extra copies from Admin.

- A table of the copies of each song (album, format, bitrate, size, length) with the copy to keep already chosen and changeable.
- The check that reads the files, with a question first, progress, Stop, and the result of the last run; the groups are read again when it ends.
- Delete the others for one song and Clean all suggestions for all of them, each after a question that lists the files and the space it frees. It stops at the first refusal and says what was already deleted.
- With deleting off everything is visible and the delete buttons are disabled, with the reason.
- English and Italian.
2026-11-14 09:52:57 +01:00

50 lines
2 KiB
TypeScript

import { useTranslation } from 'react-i18next'
import { NavLink, Outlet } from 'react-router-dom'
import { useSession } from '@/auth/session'
import { EmptyMessage } from '@/components/Status'
import { cn } from '@/lib/utils'
import PageTitle from '@/components/PageTitle'
/** The sections of the admin area; each is a route under `/admin`. */
const SECTIONS = [
{ to: '/admin/libraries', key: 'admin.sectionLibraries' },
{ to: '/admin/users', key: 'admin.sectionUsers' },
{ to: '/admin/providers', key: 'admin.sectionProviders' },
{ to: '/admin/federation', key: 'admin.sectionFederation' },
{ to: '/admin/jobs', key: 'admin.sectionJobs' },
{ to: '/admin/duplicates', key: 'admin.sectionDuplicates' },
{ to: '/admin/costs', key: 'admin.sectionCosts' },
]
/**
* The frame of the admin area. Only an admin gets the sections: anyone else gets a notice, and since the
* section pages are never rendered for them, nothing is asked of the server (which would say 403 anyway).
*/
export default function AdminLayout() {
const { t } = useTranslation()
const { user } = useSession()
if (!user?.is_admin) return <EmptyMessage>{t('admin.adminOnly')}</EmptyMessage>
return (
<div className="flex flex-col gap-6">
<PageTitle>{t('admin.title')}</PageTitle>
<nav aria-label={t('admin.sections')} className="flex flex-wrap gap-1 border-b border-border">
{SECTIONS.map((section) => (
<NavLink
key={section.to}
to={section.to}
className={({ isActive }) =>
cn(
'-mb-px flex min-h-12 items-center border-b-[3px] px-4 font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring',
isActive ? 'border-primary text-foreground' : 'border-transparent text-muted-foreground hover:text-foreground',
)
}
>
{t(section.key)}
</NavLink>
))}
</nav>
<Outlet />
</div>
)
}