diff --git a/frontend/src/Indexer/Delete/DeleteMovieModal.js b/frontend/src/Indexer/Delete/DeleteIndexerModal.js similarity index 56% rename from frontend/src/Indexer/Delete/DeleteMovieModal.js rename to frontend/src/Indexer/Delete/DeleteIndexerModal.js index dc4e1de04..5c1e130a5 100644 --- a/frontend/src/Indexer/Delete/DeleteMovieModal.js +++ b/frontend/src/Indexer/Delete/DeleteIndexerModal.js @@ -2,13 +2,12 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; import { sizes } from 'Helpers/Props'; -import DeleteMovieModalContentConnector from './DeleteMovieModalContentConnector'; +import DeleteIndexerModalContentConnector from './DeleteIndexerModalContentConnector'; -function DeleteMovieModal(props) { +function DeleteIndexerModal(props) { const { isOpen, onModalClose, - previousMovie, ...otherProps } = props; @@ -18,19 +17,17 @@ function DeleteMovieModal(props) { size={sizes.MEDIUM} onModalClose={onModalClose} > - ); } -DeleteMovieModal.propTypes = { +DeleteIndexerModal.propTypes = { isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired, - previousMovie: PropTypes.string + onModalClose: PropTypes.func.isRequired }; -export default DeleteMovieModal; +export default DeleteIndexerModal; diff --git a/frontend/src/Indexer/Delete/DeleteIndexerModalContent.js b/frontend/src/Indexer/Delete/DeleteIndexerModalContent.js new file mode 100644 index 000000000..5b4efe2b1 --- /dev/null +++ b/frontend/src/Indexer/Delete/DeleteIndexerModalContent.js @@ -0,0 +1,88 @@ +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/DeleteIndexerModalContentConnector.js b/frontend/src/Indexer/Delete/DeleteIndexerModalContentConnector.js new file mode 100644 index 000000000..be9d2b0a1 --- /dev/null +++ b/frontend/src/Indexer/Delete/DeleteIndexerModalContentConnector.js @@ -0,0 +1,57 @@ +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/frontend/src/Indexer/Delete/DeleteMovieModalContent.css b/frontend/src/Indexer/Delete/DeleteMovieModalContent.css deleted file mode 100644 index dbfef0871..000000000 --- a/frontend/src/Indexer/Delete/DeleteMovieModalContent.css +++ /dev/null @@ -1,12 +0,0 @@ -.pathContainer { - margin-bottom: 20px; -} - -.pathIcon { - margin-right: 8px; -} - -.deleteFilesMessage { - margin-top: 20px; - color: $dangerColor; -} diff --git a/frontend/src/Indexer/Delete/DeleteMovieModalContent.js b/frontend/src/Indexer/Delete/DeleteMovieModalContent.js deleted file mode 100644 index 7153e6d4e..000000000 --- a/frontend/src/Indexer/Delete/DeleteMovieModalContent.js +++ /dev/null @@ -1,166 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Icon from 'Components/Icon'; -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 { icons, inputTypes, kinds } from 'Helpers/Props'; -import formatBytes from 'Utilities/Number/formatBytes'; -import translate from 'Utilities/String/translate'; -import styles from './DeleteMovieModalContent.css'; - -class DeleteMovieModalContent 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 { - title, - path, - statistics, - onModalClose - } = this.props; - - const { - movieFileCount, - sizeOnDisk - } = statistics; - - const deleteFiles = this.state.deleteFiles; - const addImportExclusion = this.state.addImportExclusion; - - let deleteFilesLabel = `Delete ${movieFileCount} Movie Files`; - let deleteFilesHelpText = 'Delete the movie files and movie folder'; - - if (movieFileCount === 0) { - deleteFilesLabel = 'Delete Movie Folder'; - deleteFilesHelpText = 'Delete the movie folder and it\'s contents'; - } - - return ( - - - Delete - {title} - - - -
- - - {path} -
- - - {deleteFilesLabel} - - - - - { - deleteFiles && -
-
The movie folder {path} and all it's content will be deleted.
- - { - !!movieFileCount && -
{movieFileCount} movie files totaling {formatBytes(sizeOnDisk)}
- } -
- } - - - Add List Exclusion - - - - -
- - - - - - -
- ); - } -} - -DeleteMovieModalContent.propTypes = { - title: PropTypes.string.isRequired, - path: PropTypes.string.isRequired, - statistics: PropTypes.object.isRequired, - onDeletePress: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -DeleteMovieModalContent.defaultProps = { - statistics: { - movieFileCount: 0 - } -}; - -export default DeleteMovieModalContent; diff --git a/frontend/src/Indexer/Delete/DeleteMovieModalContentConnector.js b/frontend/src/Indexer/Delete/DeleteMovieModalContentConnector.js deleted file mode 100644 index 1bfb3c961..000000000 --- a/frontend/src/Indexer/Delete/DeleteMovieModalContentConnector.js +++ /dev/null @@ -1,64 +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 { deleteMovie } from 'Store/Actions/movieActions'; -import createIndexerSelector from 'Store/Selectors/createIndexerSelector'; -import DeleteMovieModalContent from './DeleteMovieModalContent'; - -function createMapStateToProps() { - return createSelector( - createIndexerSelector(), - (movie) => { - return movie; - } - ); -} - -const mapDispatchToProps = { - deleteMovie, - push -}; - -class DeleteMovieModalContentConnector extends Component { - - // - // Listeners - - onDeletePress = (deleteFiles, addImportExclusion) => { - this.props.deleteMovie({ - id: this.props.movieId, - deleteFiles, - addImportExclusion - }); - - this.props.onModalClose(true); - - if (this.props.nextMovieRelativePath) { - this.props.push(window.Prowlarr.urlBase + this.props.nextMovieRelativePath); - } - } - - // - // Render - - render() { - return ( - - ); - } -} - -DeleteMovieModalContentConnector.propTypes = { - movieId: PropTypes.number.isRequired, - onModalClose: PropTypes.func.isRequired, - deleteMovie: PropTypes.func.isRequired, - push: PropTypes.func.isRequired, - nextMovieRelativePath: PropTypes.string -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(DeleteMovieModalContentConnector); diff --git a/frontend/src/Indexer/Edit/EditMovieModalContent.js b/frontend/src/Indexer/Edit/EditMovieModalContent.js index a76d40bad..a2d3234ea 100644 --- a/frontend/src/Indexer/Edit/EditMovieModalContent.js +++ b/frontend/src/Indexer/Edit/EditMovieModalContent.js @@ -165,7 +165,7 @@ class EditMovieModalContent extends Component { } EditMovieModalContent.propTypes = { - movieId: PropTypes.number.isRequired, + indexerId: PropTypes.number.isRequired, title: PropTypes.string.isRequired, item: PropTypes.object.isRequired, isSaving: PropTypes.bool.isRequired, diff --git a/frontend/src/Indexer/Edit/EditMovieModalContentConnector.js b/frontend/src/Indexer/Edit/EditMovieModalContentConnector.js index ef5e4cc74..e4d369ef5 100644 --- a/frontend/src/Indexer/Edit/EditMovieModalContentConnector.js +++ b/frontend/src/Indexer/Edit/EditMovieModalContentConnector.js @@ -83,7 +83,7 @@ class EditMovieModalContentConnector extends Component { onSavePress = (moveFiles) => { this.props.dispatchSaveMovie({ - id: this.props.movieId, + id: this.props.indexerId, moveFiles }); } @@ -104,7 +104,7 @@ class EditMovieModalContentConnector extends Component { } EditMovieModalContentConnector.propTypes = { - movieId: PropTypes.number, + indexerId: PropTypes.number, isSaving: PropTypes.bool.isRequired, saveError: PropTypes.object, dispatchSetMovieValue: PropTypes.func.isRequired, diff --git a/frontend/src/Indexer/Index/Table/MovieIndexActionsCell.js b/frontend/src/Indexer/Index/Table/MovieIndexActionsCell.js index 554ec54d3..7b5296f29 100644 --- a/frontend/src/Indexer/Index/Table/MovieIndexActionsCell.js +++ b/frontend/src/Indexer/Index/Table/MovieIndexActionsCell.js @@ -79,14 +79,14 @@ class MovieIndexActionsCell extends Component { diff --git a/frontend/src/Indexer/Index/Table/MovieIndexRow.js b/frontend/src/Indexer/Index/Table/MovieIndexRow.js index 65e6e6db0..c68cb9e18 100644 --- a/frontend/src/Indexer/Index/Table/MovieIndexRow.js +++ b/frontend/src/Indexer/Index/Table/MovieIndexRow.js @@ -6,7 +6,7 @@ import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellCo import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell'; import { icons, kinds } from 'Helpers/Props'; -import DeleteMovieModal from 'Indexer/Delete/DeleteMovieModal'; +import DeleteIndexerModal from 'Indexer/Delete/DeleteIndexerModal'; import EditIndexerModalConnector from 'Settings/Indexers/Indexers/EditIndexerModalConnector'; import translate from 'Utilities/String/translate'; import CapabilitiesLabel from './CapabilitiesLabel'; @@ -217,11 +217,12 @@ class MovieIndexRow extends Component { id={id} isOpen={isEditIndexerModalOpen} onModalClose={this.onEditIndexerModalClose} + onDeleteIndexerPress={this.onDeleteMoviePress} /> - diff --git a/frontend/src/Indexer/Index/Table/MovieIndexTable.js b/frontend/src/Indexer/Index/Table/MovieIndexTable.js index 6ff53ff6f..3ae72b982 100644 --- a/frontend/src/Indexer/Index/Table/MovieIndexTable.js +++ b/frontend/src/Indexer/Index/Table/MovieIndexTable.js @@ -64,7 +64,7 @@ class MovieIndexTable extends Component { key={movie.id} component={MovieIndexRow} columns={columns} - movieId={movie.id} + indexerId={movie.id} isSelected={selectedState[movie.id]} onSelectedChange={onSelectedChange} isMovieEditorActive={isMovieEditorActive} diff --git a/frontend/src/Search/SearchIndex.js b/frontend/src/Search/SearchIndex.js index 27723906f..238775259 100644 --- a/frontend/src/Search/SearchIndex.js +++ b/frontend/src/Search/SearchIndex.js @@ -292,7 +292,7 @@ SearchIndex.propTypes = { onFilterSelect: PropTypes.func.isRequired, onSearchPress: PropTypes.func.isRequired, onScroll: PropTypes.func.isRequired, - hasIndexers: PropTypes.func.isRequired + hasIndexers: PropTypes.bool.isRequired }; export default SearchIndex; diff --git a/frontend/src/Store/Selectors/createIndexerSelector.js b/frontend/src/Store/Selectors/createIndexerSelector.js index 48a410959..5a6b7bfd7 100644 --- a/frontend/src/Store/Selectors/createIndexerSelector.js +++ b/frontend/src/Store/Selectors/createIndexerSelector.js @@ -2,12 +2,12 @@ import { createSelector } from 'reselect'; function createIndexerSelector() { return createSelector( - (state, { movieId }) => movieId, + (state, { indexerId }) => indexerId, (state) => state.indexers.itemMap, (state) => state.indexers.items, - (movieId, itemMap, allMovies) => { - if (allMovies && itemMap && movieId in itemMap) { - return allMovies[itemMap[movieId]]; + (indexerId, itemMap, allMovies) => { + if (allMovies && itemMap && indexerId in itemMap) { + return allMovies[itemMap[indexerId]]; } return undefined; }