2018-01-13 02:01:27 +00:00
import PropTypes from 'prop-types' ;
import React from 'react' ;
2022-05-20 04:15:43 +00:00
import Form from 'Components/Form/Form' ;
import FormGroup from 'Components/Form/FormGroup' ;
import FormInputGroup from 'Components/Form/FormInputGroup' ;
import FormLabel from 'Components/Form/FormLabel' ;
import ProviderFieldFormGroup from 'Components/Form/ProviderFieldFormGroup' ;
2018-01-13 02:01:27 +00:00
import Button from 'Components/Link/Button' ;
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton' ;
import LoadingIndicator from 'Components/Loading/LoadingIndicator' ;
import ModalBody from 'Components/Modal/ModalBody' ;
2022-05-20 04:15:43 +00:00
import ModalContent from 'Components/Modal/ModalContent' ;
2018-01-13 02:01:27 +00:00
import ModalFooter from 'Components/Modal/ModalFooter' ;
2022-05-20 04:15:43 +00:00
import ModalHeader from 'Components/Modal/ModalHeader' ;
import { inputTypes , kinds } from 'Helpers/Props' ;
2018-01-13 02:01:27 +00:00
import styles from './EditIndexerModalContent.css' ;
function EditIndexerModalContent ( props ) {
const {
advancedSettings ,
isFetching ,
error ,
isSaving ,
isTesting ,
saveError ,
item ,
onInputChange ,
onFieldChange ,
onModalClose ,
onSavePress ,
onTestPress ,
onDeleteIndexerPress ,
... otherProps
} = props ;
const {
id ,
implementationName ,
name ,
enableRss ,
enableAutomaticSearch ,
enableInteractiveSearch ,
supportsRss ,
supportsSearch ,
2021-03-22 00:00:06 +00:00
tags ,
2020-09-10 22:04:53 +00:00
fields ,
2022-01-23 20:58:23 +00:00
priority ,
2022-08-07 18:43:18 +00:00
seasonSearchMaximumSingleEpisodeAge ,
2022-01-23 20:58:23 +00:00
protocol ,
downloadClientId
2018-01-13 02:01:27 +00:00
} = item ;
return (
< ModalContent onModalClose = { onModalClose } >
< ModalHeader >
{ ` ${ id ? 'Edit' : 'Add' } Indexer - ${ implementationName } ` }
< / M o d a l H e a d e r >
< ModalBody >
{
isFetching &&
< LoadingIndicator / >
}
{
! isFetching && ! ! error &&
< div > Unable to add a new indexer , please try again . < / d i v >
}
{
! isFetching && ! error &&
2019-01-02 00:13:49 +00:00
< Form { ... otherProps } >
2018-01-13 02:01:27 +00:00
< FormGroup >
< FormLabel > Name < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . TEXT }
name = "name"
{ ... name }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
< FormGroup >
< FormLabel > Enable RSS < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . CHECK }
name = "enableRss"
helpTextWarning = { supportsRss . value ? undefined : 'RSS is not supported with this indexer' }
isDisabled = { ! supportsRss . value }
{ ... enableRss }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
< FormGroup >
< FormLabel > Enable Automatic Search < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . CHECK }
name = "enableAutomaticSearch"
helpText = { supportsSearch . value ? 'Will be used when automatic searches are performed via the UI or by Sonarr' : undefined }
helpTextWarning = { supportsSearch . value ? undefined : 'Search is not supported with this indexer' }
isDisabled = { ! supportsSearch . value }
{ ... enableAutomaticSearch }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
< FormGroup >
< FormLabel > Enable Interactive Search < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . CHECK }
name = "enableInteractiveSearch"
helpText = { supportsSearch . value ? 'Will be used when interactive search is used' : undefined }
helpTextWarning = { supportsSearch . value ? undefined : 'Search is not supported with this indexer' }
isDisabled = { ! supportsSearch . value }
{ ... enableInteractiveSearch }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
{
fields . map ( ( field ) => {
return (
< ProviderFieldFormGroup
key = { field . name }
advancedSettings = { advancedSettings }
provider = "indexer"
providerData = { item }
{ ... field }
onChange = { onFieldChange }
/ >
) ;
} )
}
2021-03-22 00:00:06 +00:00
2020-09-11 03:02:22 +00:00
< FormGroup
advancedSettings = { advancedSettings }
isAdvanced = { true }
>
2020-09-10 22:04:53 +00:00
< FormLabel > Indexer Priority < / F o r m L a b e l >
2018-01-13 02:01:27 +00:00
2020-09-10 22:04:53 +00:00
< FormInputGroup
type = { inputTypes . NUMBER }
name = "priority"
2022-01-08 17:29:24 +00:00
helpText = "Indexer Priority from 1 (Highest) to 50 (Lowest). Default: 25. Used when grabbing releases as a tiebreaker for otherwise equal releases, Sonarr will still use all enabled indexers for RSS Sync and Searching."
2020-09-10 22:04:53 +00:00
min = { 1 }
max = { 50 }
{ ... priority }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
2021-03-22 00:00:06 +00:00
2022-08-07 18:43:18 +00:00
< FormGroup
advancedSettings = { advancedSettings }
isAdvanced = { true }
>
< FormLabel > Maximum Single Episode Age < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . NUMBER }
name = "seasonSearchMaximumSingleEpisodeAge"
helpText = "During a full season search only season packs will be allowed when the season's last episode is older than this setting. Standard series only. Use 0 to disable."
min = { 0 }
unit = "days"
{ ... seasonSearchMaximumSingleEpisodeAge }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
2022-01-23 20:58:23 +00:00
< FormGroup
advancedSettings = { advancedSettings }
isAdvanced = { true }
>
< FormLabel > DownloadClient < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . DOWNLOAD _CLIENT _SELECT }
name = "downloadClientId"
helpText = { 'Specify which download client is used for grabs from this indexer' }
{ ... downloadClientId }
includeAny = { true }
protocol = { protocol . value }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
2021-03-22 00:00:06 +00:00
< FormGroup >
< FormLabel > Tags < / F o r m L a b e l >
< FormInputGroup
type = { inputTypes . TAG }
name = "tags"
helpText = "Only use this indexer for series with at least one matching tag. Leave blank to use with all series."
{ ... tags }
onChange = { onInputChange }
/ >
< / F o r m G r o u p >
2018-01-13 02:01:27 +00:00
< / F o r m >
}
< / M o d a l B o d y >
< ModalFooter >
{
id &&
< Button
className = { styles . deleteButton }
kind = { kinds . DANGER }
onPress = { onDeleteIndexerPress }
>
Delete
< / B u t t o n >
}
< SpinnerErrorButton
isSpinning = { isTesting }
error = { saveError }
onPress = { onTestPress }
>
Test
< / S p i n n e r E r r o r B u t t o n >
< Button
onPress = { onModalClose }
>
Cancel
< / B u t t o n >
< SpinnerErrorButton
isSpinning = { isSaving }
error = { saveError }
onPress = { onSavePress }
>
Save
< / S p i n n e r E r r o r B u t t o n >
< / M o d a l F o o t e r >
< / M o d a l C o n t e n t >
) ;
}
EditIndexerModalContent . propTypes = {
advancedSettings : PropTypes . bool . isRequired ,
isFetching : PropTypes . bool . isRequired ,
error : PropTypes . object ,
isSaving : PropTypes . bool . isRequired ,
isTesting : PropTypes . bool . isRequired ,
saveError : PropTypes . object ,
item : PropTypes . object . isRequired ,
onInputChange : PropTypes . func . isRequired ,
onFieldChange : PropTypes . func . isRequired ,
onModalClose : PropTypes . func . isRequired ,
onSavePress : PropTypes . func . isRequired ,
onTestPress : PropTypes . func . isRequired ,
onDeleteIndexerPress : PropTypes . func
} ;
export default EditIndexerModalContent ;