Enhance movie import process and metadata handling
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:
@@ -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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user