@ -8,11 +8,13 @@ import Column from 'Components/Table/Column';
import TableRow from 'Components/Table/TableRow' ;
import Popover from 'Components/Tooltip/Popover' ;
import { icons , kinds , tooltipPositions } from 'Helpers/Props' ;
import SelectIndexerFlagsModal from 'InteractiveImport/IndexerFlags/SelectIndexerFlagsModal' ;
import SelectLanguageModal from 'InteractiveImport/Language/SelectLanguageModal' ;
import SelectMovieModal from 'InteractiveImport/Movie/SelectMovieModal' ;
import SelectQualityModal from 'InteractiveImport/Quality/SelectQualityModal' ;
import SelectReleaseGroupModal from 'InteractiveImport/ReleaseGroup/SelectReleaseGroupModal' ;
import Language from 'Language/Language' ;
import IndexerFlags from 'Movie/IndexerFlags' ;
import Movie from 'Movie/Movie' ;
import MovieFormats from 'Movie/MovieFormats' ;
import MovieLanguage from 'Movie/MovieLanguage' ;
@ -30,7 +32,12 @@ import translate from 'Utilities/String/translate';
import InteractiveImportRowCellPlaceholder from './InteractiveImportRowCellPlaceholder' ;
import styles from './InteractiveImportRow.css' ;
type SelectType = 'movie' | 'releaseGroup' | 'quality' | 'language' ;
type SelectType =
| 'movie'
| 'releaseGroup'
| 'quality'
| 'language'
| 'indexerFlags' ;
type SelectedChangeProps = SelectStateInputProps & {
hasMovieFileId : boolean ;
@ -47,6 +54,7 @@ interface InteractiveImportRowProps {
size : number ;
customFormats? : object [ ] ;
customFormatScore? : number ;
indexerFlags : number ;
rejections : Rejection [ ] ;
columns : Column [ ] ;
movieFileId? : number ;
@ -69,6 +77,7 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
size ,
customFormats ,
customFormatScore ,
indexerFlags ,
rejections ,
isSelected ,
modalTitle ,
@ -84,6 +93,10 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
( ) = > columns . find ( ( c ) = > c . name === 'movie' ) ? . isVisible ? ? false ,
[ columns ]
) ;
const isIndexerFlagsColumnVisible = useMemo (
( ) = > columns . find ( ( c ) = > c . name === 'indexerFlags' ) ? . isVisible ? ? false ,
[ columns ]
) ;
const [ selectModalOpen , setSelectModalOpen ] = useState < SelectType | null > (
null
@ -223,12 +236,34 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
[ id , dispatch , setSelectModalOpen , selectRowAfterChange ]
) ;
const onSelectIndexerFlagsPress = useCallback ( ( ) = > {
setSelectModalOpen ( 'indexerFlags' ) ;
} , [ setSelectModalOpen ] ) ;
const onIndexerFlagsSelect = useCallback (
( indexerFlags : number ) = > {
dispatch (
updateInteractiveImportItem ( {
id ,
indexerFlags ,
} )
) ;
dispatch ( reprocessInteractiveImportItems ( { ids : [ id ] } ) ) ;
setSelectModalOpen ( null ) ;
selectRowAfterChange ( ) ;
} ,
[ id , dispatch , setSelectModalOpen , selectRowAfterChange ]
) ;
const movieTitle = movie ? movie . title : '' ;
const showMoviePlaceholder = isSelected && ! movie ;
const showReleaseGroupPlaceholder = isSelected && ! releaseGroup ;
const showQualityPlaceholder = isSelected && ! quality ;
const showLanguagePlaceholder = isSelected && ! languages ;
const showIndexerFlagsPlaceholder = isSelected && ! indexerFlags ;
return (
< TableRow >
@ -311,6 +346,28 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
) : null }
< / TableRowCell >
{ isIndexerFlagsColumnVisible ? (
< TableRowCellButton
title = { translate ( 'ClickToChangeIndexerFlags' ) }
onPress = { onSelectIndexerFlagsPress }
>
{ showIndexerFlagsPlaceholder ? (
< InteractiveImportRowCellPlaceholder isOptional = { true } / >
) : (
< >
{ indexerFlags ? (
< Popover
anchor = { < Icon name = { icons . FLAG } kind = { kinds . PRIMARY } / > }
title = { translate ( 'IndexerFlags' ) }
body = { < IndexerFlags indexerFlags = { indexerFlags } / > }
position = { tooltipPositions . LEFT }
/ >
) : null }
< / >
) }
< / TableRowCellButton >
) : null }
< TableRowCell >
{ rejections . length ? (
< Popover
@ -361,6 +418,14 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
onLanguagesSelect = { onLanguagesSelect }
onModalClose = { onSelectModalClose }
/ >
< SelectIndexerFlagsModal
isOpen = { selectModalOpen === 'indexerFlags' }
indexerFlags = { indexerFlags ? ? 0 }
modalTitle = { modalTitle }
onIndexerFlagsSelect = { onIndexerFlagsSelect }
onModalClose = { onSelectModalClose }
/ >
< / TableRow >
) ;
}