Fixed: Prevent selecting season or episode in Manual Import if series or episode is not selected

Closes #6354
This commit is contained in:
Mark McDowall 2024-01-14 09:56:39 -08:00 committed by Mark McDowall
parent ee0048c768
commit 0685896ed8
1 changed files with 58 additions and 38 deletions

View File

@ -269,33 +269,6 @@ function InteractiveImportModalContent(
const [interactiveImportErrorMessage, setInteractiveImportErrorMessage] = const [interactiveImportErrorMessage, setInteractiveImportErrorMessage] =
useState<string | null>(null); useState<string | null>(null);
const [selectState, setSelectState] = useSelectState(); const [selectState, setSelectState] = useSelectState();
const [bulkSelectOptions, setBulkSelectOptions] = useState([
{
key: 'select',
value: translate('SelectDropdown'),
disabled: true,
},
{
key: 'season',
value: translate('SelectSeason'),
},
{
key: 'episode',
value: translate('SelectEpisodes'),
},
{
key: 'quality',
value: translate('SelectQuality'),
},
{
key: 'releaseGroup',
value: translate('SelectReleaseGroup'),
},
{
key: 'language',
value: translate('SelectLanguage'),
},
]);
const { allSelected, allUnselected, selectedState } = selectState; const { allSelected, allUnselected, selectedState } = selectState;
const previousIsDeleting = usePrevious(isDeleting); const previousIsDeleting = usePrevious(isDeleting);
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -318,19 +291,66 @@ function InteractiveImportModalContent(
return getSelectedIds(selectedState); return getSelectedIds(selectedState);
}, [selectedState]); }, [selectedState]);
useEffect( const bulkSelectOptions = useMemo(() => {
() => { const { seasonSelectDisabled, episodeSelectDisabled } = items.reduce(
if (allowSeriesChange) { (acc, item) => {
const newBulkSelectOptions = [...bulkSelectOptions]; if (!selectedIds.includes(item.id)) {
return acc;
}
newBulkSelectOptions.splice(1, 0, { acc.seasonSelectDisabled ||= !item.series;
acc.episodeSelectDisabled ||= !item.seasonNumber;
return acc;
},
{
seasonSelectDisabled: false,
episodeSelectDisabled: false,
}
);
const options = [
{
key: 'select',
value: translate('SelectDropdown'),
disabled: true,
},
{
key: 'season',
value: translate('SelectSeason'),
disabled: seasonSelectDisabled,
},
{
key: 'episode',
value: translate('SelectEpisodes'),
disabled: episodeSelectDisabled,
},
{
key: 'quality',
value: translate('SelectQuality'),
},
{
key: 'releaseGroup',
value: translate('SelectReleaseGroup'),
},
{
key: 'language',
value: translate('SelectLanguage'),
},
];
if (allowSeriesChange) {
options.splice(1, 0, {
key: 'series', key: 'series',
value: translate('SelectSeries'), value: translate('SelectSeries'),
}); });
setBulkSelectOptions(newBulkSelectOptions);
} }
return options;
}, [allowSeriesChange, items, selectedIds]);
useEffect(
() => {
if (initialSortKey) { if (initialSortKey) {
const sortProps: { sortKey: string; sortDirection?: string } = { const sortProps: { sortKey: string; sortDirection?: string } = {
sortKey: initialSortKey, sortKey: initialSortKey,