mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
New: Confirmation for searching movies
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo, useState } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { useSelect } from 'App/SelectContext';
|
import { useSelect } from 'App/SelectContext';
|
||||||
import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState';
|
import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState';
|
||||||
import MoviesAppState, { MovieIndexAppState } from 'App/State/MoviesAppState';
|
import MoviesAppState, { MovieIndexAppState } from 'App/State/MoviesAppState';
|
||||||
import { MOVIE_SEARCH } from 'Commands/commandNames';
|
import { MOVIE_SEARCH } from 'Commands/commandNames';
|
||||||
|
import ConfirmModal from 'Components/Modal/ConfirmModal';
|
||||||
import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
|
import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
|
||||||
import { icons } from 'Helpers/Props';
|
import { icons, kinds } from 'Helpers/Props';
|
||||||
import { executeCommand } from 'Store/Actions/commandActions';
|
import { executeCommand } from 'Store/Actions/commandActions';
|
||||||
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
||||||
import createMovieClientSideCollectionItemsSelector from 'Store/Selectors/createMovieClientSideCollectionItemsSelector';
|
import createMovieClientSideCollectionItemsSelector from 'Store/Selectors/createMovieClientSideCollectionItemsSelector';
|
||||||
@@ -25,6 +26,8 @@ function MovieIndexSearchButton(props: MovieIndexSearchButtonProps) {
|
|||||||
useSelector(createMovieClientSideCollectionItemsSelector('movieIndex'));
|
useSelector(createMovieClientSideCollectionItemsSelector('movieIndex'));
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const [isConfirmModalOpen, setIsConfirmModalOpen] = useState(false);
|
||||||
|
|
||||||
const { isSelectMode, selectedFilterKey } = props;
|
const { isSelectMode, selectedFilterKey } = props;
|
||||||
const [selectState] = useSelect();
|
const [selectState] = useSelect();
|
||||||
const { selectedState } = selectState;
|
const { selectedState } = selectState;
|
||||||
@@ -49,6 +52,8 @@ function MovieIndexSearchButton(props: MovieIndexSearchButtonProps) {
|
|||||||
: translate('SearchAll');
|
: translate('SearchAll');
|
||||||
|
|
||||||
const onPress = useCallback(() => {
|
const onPress = useCallback(() => {
|
||||||
|
setIsConfirmModalOpen(false);
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
executeCommand({
|
executeCommand({
|
||||||
name: MOVIE_SEARCH,
|
name: MOVIE_SEARCH,
|
||||||
@@ -57,14 +62,36 @@ function MovieIndexSearchButton(props: MovieIndexSearchButtonProps) {
|
|||||||
);
|
);
|
||||||
}, [dispatch, moviesToSearch]);
|
}, [dispatch, moviesToSearch]);
|
||||||
|
|
||||||
|
const onConfirmPress = useCallback(() => {
|
||||||
|
setIsConfirmModalOpen(true);
|
||||||
|
}, [setIsConfirmModalOpen]);
|
||||||
|
|
||||||
|
const onConfirmModalClose = useCallback(() => {
|
||||||
|
setIsConfirmModalOpen(false);
|
||||||
|
}, [setIsConfirmModalOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageToolbarButton
|
<>
|
||||||
label={isSelectMode ? searchSelectLabel : searchIndexLabel}
|
<PageToolbarButton
|
||||||
isSpinning={isSearching}
|
label={isSelectMode ? searchSelectLabel : searchIndexLabel}
|
||||||
isDisabled={!items.length}
|
isSpinning={isSearching}
|
||||||
iconName={icons.SEARCH}
|
isDisabled={!items.length}
|
||||||
onPress={onPress}
|
iconName={icons.SEARCH}
|
||||||
/>
|
onPress={moviesToSearch.length > 5 ? onConfirmPress : onPress}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ConfirmModal
|
||||||
|
isOpen={isConfirmModalOpen}
|
||||||
|
kind={kinds.DANGER}
|
||||||
|
title={isSelectMode ? searchSelectLabel : searchIndexLabel}
|
||||||
|
message={translate('SearchMoviesConfirmationMessageText', {
|
||||||
|
count: moviesToSearch.length,
|
||||||
|
})}
|
||||||
|
confirmLabel={isSelectMode ? searchSelectLabel : searchIndexLabel}
|
||||||
|
onConfirm={onPress}
|
||||||
|
onCancel={onConfirmModalClose}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1072,6 +1072,7 @@
|
|||||||
"SearchOnAddCollectionHelpText": "Search for movies on this collection when added to library",
|
"SearchOnAddCollectionHelpText": "Search for movies on this collection when added to library",
|
||||||
"SearchOnAddHelpText": "Search for movies on this list when added to library",
|
"SearchOnAddHelpText": "Search for movies on this list when added to library",
|
||||||
"SearchSelected": "Search Selected",
|
"SearchSelected": "Search Selected",
|
||||||
|
"SearchMoviesConfirmationMessageText": "Are you sure you want to run a search for {count} movie(s)?",
|
||||||
"Seconds": "Seconds",
|
"Seconds": "Seconds",
|
||||||
"Security": "Security",
|
"Security": "Security",
|
||||||
"Seeders": "Seeders",
|
"Seeders": "Seeders",
|
||||||
|
|||||||
Reference in New Issue
Block a user