import PropTypes from 'prop-types'; import React from 'react'; import Alert from 'Components/Alert'; 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 Button from 'Components/Link/Button'; import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { inputTypes, kinds } from 'Helpers/Props'; import { boolSettingShape, numberSettingShape, tagSettingShape } from 'Helpers/Props/Shapes/settingShape'; import translate from 'Utilities/String/translate'; import styles from './EditDelayProfileModalContent.css'; const protocolOptions = [ { key: 'preferUsenet', value: translate('PreferUsenet') }, { key: 'preferTorrent', value: translate('PreferTorrent') }, { key: 'onlyUsenet', value: translate('OnlyUsenet') }, { key: 'onlyTorrent', value: translate('OnlyTorrent') } ]; function EditDelayProfileModalContent(props) { const { id, isFetching, error, isSaving, saveError, item, protocol, onInputChange, onProtocolChange, onSavePress, onModalClose, onDeleteDelayProfilePress, ...otherProps } = props; const { enableUsenet, enableTorrent, usenetDelay, torrentDelay, tags } = item; return ( {id ? translate('EditDelayProfile') : translate('AddDelayProfile')} { isFetching ? : null } { !isFetching && !!error ?
{translate('UnableToAddANewQualityProfilePleaseTryAgain')}
: null } { !isFetching && !error ?
{translate('PreferredProtocol')} { enableUsenet.value && {translate('UsenetDelay')} } { enableTorrent.value && {translate('TorrentDelay')} } { id === 1 ? {translate('DefaultDelayProfileHelpText')} : {translate('Tags')} }
: null }
{ id && id > 1 ? : null } {translate('Save')}
); } const delayProfileShape = { enableUsenet: PropTypes.shape(boolSettingShape).isRequired, enableTorrent: PropTypes.shape(boolSettingShape).isRequired, usenetDelay: PropTypes.shape(numberSettingShape).isRequired, torrentDelay: PropTypes.shape(numberSettingShape).isRequired, order: PropTypes.shape(numberSettingShape), tags: PropTypes.shape(tagSettingShape).isRequired }; EditDelayProfileModalContent.propTypes = { id: PropTypes.number, isFetching: PropTypes.bool.isRequired, error: PropTypes.object, isSaving: PropTypes.bool.isRequired, saveError: PropTypes.object, item: PropTypes.shape(delayProfileShape).isRequired, protocol: PropTypes.string.isRequired, onInputChange: PropTypes.func.isRequired, onProtocolChange: PropTypes.func.isRequired, onSavePress: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired, onDeleteDelayProfilePress: PropTypes.func }; export default EditDelayProfileModalContent;