diff --git a/frontend/src/Indexer/Delete/DeleteIndexerModal.js b/frontend/src/Indexer/Delete/DeleteIndexerModal.js deleted file mode 100644 index aed954829..000000000 --- a/frontend/src/Indexer/Delete/DeleteIndexerModal.js +++ /dev/null @@ -1,34 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import { sizes } from 'Helpers/Props'; -import DeleteIndexerModalContentConnector from './DeleteIndexerModalContentConnector'; - -function DeleteIndexerModal(props) { - const { - isOpen, - onModalClose, - ...otherProps - } = props; - - return ( - - - - ); -} - -DeleteIndexerModal.propTypes = { - ...DeleteIndexerModalContentConnector.propTypes, - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default DeleteIndexerModal; diff --git a/frontend/src/Indexer/Delete/DeleteIndexerModal.tsx b/frontend/src/Indexer/Delete/DeleteIndexerModal.tsx new file mode 100644 index 000000000..13850aa77 --- /dev/null +++ b/frontend/src/Indexer/Delete/DeleteIndexerModal.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; +import DeleteIndexerModalContent from './DeleteIndexerModalContent'; + +interface DeleteIndexerModalProps { + isOpen: boolean; + indexerId: number; + onModalClose(): void; +} + +function DeleteIndexerModal(props: DeleteIndexerModalProps) { + const { isOpen, indexerId, onModalClose } = props; + + return ( + + + + ); +} + +export default DeleteIndexerModal; diff --git a/frontend/src/Indexer/Delete/DeleteIndexerModalContent.js b/frontend/src/Indexer/Delete/DeleteIndexerModalContent.js deleted file mode 100644 index e3d46e108..000000000 --- a/frontend/src/Indexer/Delete/DeleteIndexerModalContent.js +++ /dev/null @@ -1,88 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Button from 'Components/Link/Button'; -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 { kinds } from 'Helpers/Props'; -import translate from 'Utilities/String/translate'; - -class DeleteIndexerModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - deleteFiles: false, - addImportExclusion: false - }; - } - - // - // Listeners - - onDeleteFilesChange = ({ value }) => { - this.setState({ deleteFiles: value }); - }; - - onAddImportExclusionChange = ({ value }) => { - this.setState({ addImportExclusion: value }); - }; - - onDeleteMovieConfirmed = () => { - const deleteFiles = this.state.deleteFiles; - const addImportExclusion = this.state.addImportExclusion; - - this.setState({ deleteFiles: false, addImportExclusion: false }); - this.props.onDeletePress(deleteFiles, addImportExclusion); - }; - - // - // Render - - render() { - const { - name, - onModalClose - } = this.props; - - return ( - - - Delete - {name} - - - - {`Are you sure you want to delete ${name} from Prowlarr`} - - - - - - - - - ); - } -} - -DeleteIndexerModalContent.propTypes = { - name: PropTypes.string.isRequired, - onDeletePress: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default DeleteIndexerModalContent; diff --git a/frontend/src/Indexer/Delete/DeleteIndexerModalContent.tsx b/frontend/src/Indexer/Delete/DeleteIndexerModalContent.tsx new file mode 100644 index 000000000..7373ba885 --- /dev/null +++ b/frontend/src/Indexer/Delete/DeleteIndexerModalContent.tsx @@ -0,0 +1,51 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Button from 'Components/Link/Button'; +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 { kinds } from 'Helpers/Props'; +import { deleteIndexer } from 'Store/Actions/indexerActions'; +import { createIndexerSelectorForHook } from 'Store/Selectors/createIndexerSelector'; +import translate from 'Utilities/String/translate'; + +interface DeleteIndexerModalContentProps { + indexerId: number; + onModalClose(): void; +} + +function DeleteIndexerModalContent(props: DeleteIndexerModalContentProps) { + const { indexerId, onModalClose } = props; + + const { name } = useSelector(createIndexerSelectorForHook(indexerId)); + const dispatch = useDispatch(); + + const onConfirmDelete = useCallback(() => { + dispatch(deleteIndexer({ id: indexerId })); + + onModalClose(); + }, [indexerId, dispatch, onModalClose]); + + return ( + + + {translate('Delete')} - {name} + + + + {translate('AreYouSureYouWantToDeleteIndexer', [name])} + + + + + + + + + ); +} + +export default DeleteIndexerModalContent; diff --git a/frontend/src/Indexer/Delete/DeleteIndexerModalContentConnector.js b/frontend/src/Indexer/Delete/DeleteIndexerModalContentConnector.js deleted file mode 100644 index 1e92eb845..000000000 --- a/frontend/src/Indexer/Delete/DeleteIndexerModalContentConnector.js +++ /dev/null @@ -1,57 +0,0 @@ -import { push } from 'connected-react-router'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { deleteIndexer } from 'Store/Actions/indexerActions'; -import createIndexerSelector from 'Store/Selectors/createIndexerSelector'; -import DeleteIndexerModalContent from './DeleteIndexerModalContent'; - -function createMapStateToProps() { - return createSelector( - createIndexerSelector(), - (indexer) => { - return indexer; - } - ); -} - -const mapDispatchToProps = { - deleteIndexer, - push -}; - -class DeleteIndexerModalContentConnector extends Component { - - // - // Listeners - - onDeletePress = () => { - this.props.deleteIndexer({ - id: this.props.indexerId - }); - - this.props.onModalClose(true); - }; - - // - // Render - - render() { - return ( - - ); - } -} - -DeleteIndexerModalContentConnector.propTypes = { - indexerId: PropTypes.number.isRequired, - onModalClose: PropTypes.func.isRequired, - deleteIndexer: PropTypes.func.isRequired, - push: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(DeleteIndexerModalContentConnector); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index f10617902..a2a78cc46 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -52,6 +52,7 @@ "AppsMinimumSeeders": "Apps Minimum Seeders", "AppsMinimumSeedersHelpText": "Minimum seeders required by the Applications for the indexer to grab, empty is Sync profile's default", "AreYouSureYouWantToDeleteCategory": "Are you sure you want to delete mapped category?", + "AreYouSureYouWantToDeleteIndexer": "Are you sure you want to delete '{0}' from Prowlarr?", "AreYouSureYouWantToResetYourAPIKey": "Are you sure you want to reset your API Key?", "Artist": "Artist", "AudioSearch": "Audio Search",