Enhance movie import process and metadata handling
ci / build-backend (push) Successful in 1m33s
ci / build-frontend (push) Successful in 55s
ci / tests (push) Successful in 3m27s
ci / sonar (push) Successful in 6m55s

Refactored the movie import functionality to ensure that the title from the source is used for the show name, while the file name is retained as the original title. Improved the handling of metadata during the import process, allowing for better integration of original titles from various sources. Updated related classes and methods to streamline the import workflow and enhance user experience. Added tests to verify the correct assignment of titles and original names during the import process. Updated documentation to reflect these changes.
This commit is contained in:
Leonid Pershin
2026-07-28 03:14:19 +03:00
parent d859a9894c
commit d0bc0465e7
21 changed files with 926 additions and 698 deletions
@@ -0,0 +1,66 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/shared/ui/dialog'
import { ManualInboxPanel } from './ManualInboxPanel'
import { MovieImportPanel } from './MovieImportPanel'
import { UploadToShowPanel } from './UploadToShowPanel'
/** Способы пополнить библиотеку. «В шоу» появляется только когда файлы уже выбраны. */
type Tab = 'movies' | 'manual' | 'toShow'
/**
* Одно окно на все способы завести медиа: фильмы пачкой, серии из `manual/` в шоу и загрузка
* выбранных файлов в шоу. Раньше это были три кнопки и три окна — а выбор между ними делается
* один раз и по одному признаку: что за контент кладём.
*/
export function MediaImportDialog({
files,
onClose,
}: Readonly<{
/** Файлы, выбранные в проводнике до открытия окна: тогда сразу открывается вкладка «в шоу». */
files: File[] | null
onClose: () => void
}>) {
const { t } = useTranslation()
const [tab, setTab] = useState<Tab>(files ? 'toShow' : 'movies')
const tabs: Tab[] = files ? ['toShow', 'movies', 'manual'] : ['movies', 'manual']
return (
<Dialog open onOpenChange={(open) => !open && onClose()}>
<DialogContent className="max-w-[min(96vw,80rem)]">
<DialogHeader>
<DialogTitle>{t('admin.media.importTitle')}</DialogTitle>
<DialogDescription>{t('admin.media.importHint')}</DialogDescription>
</DialogHeader>
<div className="flex gap-1 border-b border-border">
{tabs.map((item) => (
<button
key={item}
type="button"
onClick={() => setTab(item)}
className={`-mb-px border-b-2 px-3 py-1.5 text-sm ${
tab === item
? 'border-primary text-foreground'
: 'border-transparent text-muted-foreground hover:text-foreground'
}`}
>
{t(`admin.media.importTabs.${item}`)}
</button>
))}
</div>
{tab === 'movies' && <MovieImportPanel onClose={onClose} />}
{tab === 'manual' && <ManualInboxPanel onClose={onClose} />}
{tab === 'toShow' && files && <UploadToShowPanel files={files} onClose={onClose} />}
</DialogContent>
</Dialog>
)
}