mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed delete from mass editor
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createAllMoviesSelector from 'Store/Selectors/createAllMoviesSelector';
|
import createAllIndexersSelector from 'Store/Selectors/createAllIndexersSelector';
|
||||||
import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector';
|
import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector';
|
||||||
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
||||||
import MovieSearchInput from './MovieSearchInput';
|
import MovieSearchInput from './MovieSearchInput';
|
||||||
|
|
||||||
function createCleanMovieSelector() {
|
function createCleanMovieSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
createAllMoviesSelector(),
|
createAllIndexersSelector(),
|
||||||
createTagsSelector(),
|
createTagsSelector(),
|
||||||
(allMovies, allTags) => {
|
(allMovies, allTags) => {
|
||||||
return allMovies.map((movie) => {
|
return allMovies.map((movie) => {
|
||||||
const {
|
const {
|
||||||
title,
|
name,
|
||||||
titleSlug,
|
titleSlug,
|
||||||
sortTitle,
|
sortTitle,
|
||||||
year,
|
year,
|
||||||
@@ -23,13 +23,13 @@ function createCleanMovieSelector() {
|
|||||||
} = movie;
|
} = movie;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
name,
|
||||||
titleSlug,
|
titleSlug,
|
||||||
sortTitle,
|
sortTitle,
|
||||||
year,
|
year,
|
||||||
images,
|
images,
|
||||||
alternateTitles,
|
alternateTitles,
|
||||||
firstCharacter: title.charAt(0).toLowerCase(),
|
firstCharacter: name.charAt(0).toLowerCase(),
|
||||||
tags: tags.reduce((acc, id) => {
|
tags: tags.reduce((acc, id) => {
|
||||||
const matchingTag = allTags.find((tag) => tag.id === id);
|
const matchingTag = allTags.find((tag) => tag.id === id);
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Modal from 'Components/Modal/Modal';
|
import Modal from 'Components/Modal/Modal';
|
||||||
import DeleteMovieModalContentConnector from './DeleteMovieModalContentConnector';
|
import DeleteIndexerModalContentConnector from './DeleteIndexerModalContentConnector';
|
||||||
|
|
||||||
function DeleteMovieModal(props) {
|
function DeleteIndexerModal(props) {
|
||||||
const {
|
const {
|
||||||
isOpen,
|
isOpen,
|
||||||
onModalClose,
|
onModalClose,
|
||||||
@@ -15,7 +15,7 @@ function DeleteMovieModal(props) {
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onModalClose={onModalClose}
|
onModalClose={onModalClose}
|
||||||
>
|
>
|
||||||
<DeleteMovieModalContentConnector
|
<DeleteIndexerModalContentConnector
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
onModalClose={onModalClose}
|
onModalClose={onModalClose}
|
||||||
/>
|
/>
|
||||||
@@ -23,9 +23,9 @@ function DeleteMovieModal(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteMovieModal.propTypes = {
|
DeleteIndexerModal.propTypes = {
|
||||||
isOpen: PropTypes.bool.isRequired,
|
isOpen: PropTypes.bool.isRequired,
|
||||||
onModalClose: PropTypes.func.isRequired
|
onModalClose: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DeleteMovieModal;
|
export default DeleteIndexerModal;
|
@@ -0,0 +1,74 @@
|
|||||||
|
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';
|
||||||
|
import styles from './DeleteIndexerModalContent.css';
|
||||||
|
|
||||||
|
class DeleteIndexerModalContent extends Component {
|
||||||
|
onDeleteMovieConfirmed = () => {
|
||||||
|
this.props.onDeleteSelectedPress();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
indexers,
|
||||||
|
onModalClose
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalContent onModalClose={onModalClose}>
|
||||||
|
<ModalHeader>
|
||||||
|
Delete Selected Indexers(s)
|
||||||
|
</ModalHeader>
|
||||||
|
|
||||||
|
<ModalBody>
|
||||||
|
|
||||||
|
<div className={styles.message}>
|
||||||
|
{`Are you sure you want to delete ${indexers.length} selected indexers(s)`}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{
|
||||||
|
indexers.map((s) => {
|
||||||
|
return (
|
||||||
|
<li key={s.name}>
|
||||||
|
<span>{s.name}</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</ModalBody>
|
||||||
|
|
||||||
|
<ModalFooter>
|
||||||
|
<Button onPress={onModalClose}>
|
||||||
|
{translate('Cancel')}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
kind={kinds.DANGER}
|
||||||
|
onPress={this.onDeleteMovieConfirmed}
|
||||||
|
>
|
||||||
|
{translate('Delete')}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</ModalContent>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteIndexerModalContent.propTypes = {
|
||||||
|
indexers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
onModalClose: PropTypes.func.isRequired,
|
||||||
|
onDeleteSelectedPress: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DeleteIndexerModalContent;
|
@@ -0,0 +1,43 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import { bulkDeleteIndexers } from 'Store/Actions/indexerIndexActions';
|
||||||
|
import createAllIndexersSelector from 'Store/Selectors/createAllIndexersSelector';
|
||||||
|
import DeleteIndexerModalContent from './DeleteIndexerModalContent';
|
||||||
|
|
||||||
|
function createMapStateToProps() {
|
||||||
|
return createSelector(
|
||||||
|
(state, { indexerIds }) => indexerIds,
|
||||||
|
createAllIndexersSelector(),
|
||||||
|
(indexerIds, allIndexers) => {
|
||||||
|
const selectedMovie = _.intersectionWith(allIndexers, indexerIds, (s, id) => {
|
||||||
|
return s.id === id;
|
||||||
|
});
|
||||||
|
|
||||||
|
const sortedMovies = _.orderBy(selectedMovie, 'name');
|
||||||
|
const indexers = _.map(sortedMovies, (s) => {
|
||||||
|
return {
|
||||||
|
name: s.name
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
indexers
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMapDispatchToProps(dispatch, props) {
|
||||||
|
return {
|
||||||
|
onDeleteSelectedPress() {
|
||||||
|
dispatch(bulkDeleteIndexers({
|
||||||
|
indexerIds: props.indexerIds
|
||||||
|
}));
|
||||||
|
|
||||||
|
props.onModalClose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteIndexerModalContent);
|
@@ -1,145 +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 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 { inputTypes, kinds } from 'Helpers/Props';
|
|
||||||
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.onDeleteSelectedPress(deleteFiles, addImportExclusion);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Render
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
movies,
|
|
||||||
onModalClose
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const deleteFiles = this.state.deleteFiles;
|
|
||||||
const addImportExclusion = this.state.addImportExclusion;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ModalContent onModalClose={onModalClose}>
|
|
||||||
<ModalHeader>
|
|
||||||
Delete Selected Movie(s)
|
|
||||||
</ModalHeader>
|
|
||||||
|
|
||||||
<ModalBody>
|
|
||||||
<div>
|
|
||||||
<FormGroup>
|
|
||||||
<FormLabel>{`Delete Movie Folder${movies.length > 1 ? 's' : ''}`}</FormLabel>
|
|
||||||
|
|
||||||
<FormInputGroup
|
|
||||||
type={inputTypes.CHECK}
|
|
||||||
name="deleteFiles"
|
|
||||||
value={deleteFiles}
|
|
||||||
helpText={`Delete Movie Folder${movies.length > 1 ? 's' : ''} and all contents`}
|
|
||||||
kind={kinds.DANGER}
|
|
||||||
onChange={this.onDeleteFilesChange}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
|
|
||||||
<FormGroup>
|
|
||||||
<FormLabel>{translate('AddListExclusion')}</FormLabel>
|
|
||||||
|
|
||||||
<FormInputGroup
|
|
||||||
type={inputTypes.CHECK}
|
|
||||||
name="addImportExclusion"
|
|
||||||
value={addImportExclusion}
|
|
||||||
helpText={translate('AddImportExclusionHelpText')}
|
|
||||||
kind={kinds.DANGER}
|
|
||||||
onChange={this.onAddImportExclusionChange}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={styles.message}>
|
|
||||||
{`Are you sure you want to delete ${movies.length} selected movie(s)${deleteFiles ? ' and all contents' : ''}?`}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
{
|
|
||||||
movies.map((s) => {
|
|
||||||
return (
|
|
||||||
<li key={s.title}>
|
|
||||||
<span>{s.title}</span>
|
|
||||||
|
|
||||||
{
|
|
||||||
deleteFiles &&
|
|
||||||
<span className={styles.pathContainer}>
|
|
||||||
-
|
|
||||||
<span className={styles.path}>
|
|
||||||
{s.path}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</ModalBody>
|
|
||||||
|
|
||||||
<ModalFooter>
|
|
||||||
<Button onPress={onModalClose}>
|
|
||||||
{translate('Cancel')}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
kind={kinds.DANGER}
|
|
||||||
onPress={this.onDeleteMovieConfirmed}
|
|
||||||
>
|
|
||||||
{translate('Delete')}
|
|
||||||
</Button>
|
|
||||||
</ModalFooter>
|
|
||||||
</ModalContent>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteMovieModalContent.propTypes = {
|
|
||||||
movies: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
||||||
onModalClose: PropTypes.func.isRequired,
|
|
||||||
onDeleteSelectedPress: PropTypes.func.isRequired
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DeleteMovieModalContent;
|
|
@@ -1,46 +0,0 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import { bulkDeleteMovie } from 'Store/Actions/indexerIndexActions';
|
|
||||||
import createAllMoviesSelector from 'Store/Selectors/createAllMoviesSelector';
|
|
||||||
import DeleteMovieModalContent from './DeleteMovieModalContent';
|
|
||||||
|
|
||||||
function createMapStateToProps() {
|
|
||||||
return createSelector(
|
|
||||||
(state, { movieIds }) => movieIds,
|
|
||||||
createAllMoviesSelector(),
|
|
||||||
(movieIds, allMovies) => {
|
|
||||||
const selectedMovie = _.intersectionWith(allMovies, movieIds, (s, id) => {
|
|
||||||
return s.id === id;
|
|
||||||
});
|
|
||||||
|
|
||||||
const sortedMovies = _.orderBy(selectedMovie, 'sortTitle');
|
|
||||||
const movies = _.map(sortedMovies, (s) => {
|
|
||||||
return {
|
|
||||||
title: s.title,
|
|
||||||
path: s.path
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
movies
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createMapDispatchToProps(dispatch, props) {
|
|
||||||
return {
|
|
||||||
onDeleteSelectedPress(deleteFiles, addImportExclusion) {
|
|
||||||
dispatch(bulkDeleteMovie({
|
|
||||||
movieIds: props.movieIds,
|
|
||||||
deleteFiles,
|
|
||||||
addImportExclusion
|
|
||||||
}));
|
|
||||||
|
|
||||||
props.onModalClose();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteMovieModalContent);
|
|
@@ -4,14 +4,14 @@ import SpinnerButton from 'Components/Link/SpinnerButton';
|
|||||||
import PageContentFooter from 'Components/Page/PageContentFooter';
|
import PageContentFooter from 'Components/Page/PageContentFooter';
|
||||||
import { kinds } from 'Helpers/Props';
|
import { kinds } from 'Helpers/Props';
|
||||||
import translate from 'Utilities/String/translate';
|
import translate from 'Utilities/String/translate';
|
||||||
import DeleteMovieModal from './Delete/DeleteMovieModal';
|
import DeleteIndexerModal from './Delete/DeleteIndexerModal';
|
||||||
import MovieEditorFooterLabel from './MovieEditorFooterLabel';
|
import IndexerEditorFooterLabel from './IndexerEditorFooterLabel';
|
||||||
import TagsModal from './Tags/TagsModal';
|
import TagsModal from './Tags/TagsModal';
|
||||||
import styles from './MovieEditorFooter.css';
|
import styles from './IndexerEditorFooter.css';
|
||||||
|
|
||||||
const NO_CHANGE = 'noChange';
|
const NO_CHANGE = 'noChange';
|
||||||
|
|
||||||
class MovieEditorFooter extends Component {
|
class IndexerEditorFooter extends Component {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
@@ -88,7 +88,7 @@ class MovieEditorFooter extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
movieIds,
|
indexerIds,
|
||||||
selectedCount,
|
selectedCount,
|
||||||
isSaving,
|
isSaving,
|
||||||
isDeleting
|
isDeleting
|
||||||
@@ -104,7 +104,7 @@ class MovieEditorFooter extends Component {
|
|||||||
<PageContentFooter>
|
<PageContentFooter>
|
||||||
<div className={styles.buttonContainer}>
|
<div className={styles.buttonContainer}>
|
||||||
<div className={styles.buttonContainerContent}>
|
<div className={styles.buttonContainerContent}>
|
||||||
<MovieEditorFooterLabel
|
<IndexerEditorFooterLabel
|
||||||
label={translate('IndexersSelectedInterp', [selectedCount])}
|
label={translate('IndexersSelectedInterp', [selectedCount])}
|
||||||
isSaving={false}
|
isSaving={false}
|
||||||
/>
|
/>
|
||||||
@@ -136,14 +136,14 @@ class MovieEditorFooter extends Component {
|
|||||||
|
|
||||||
<TagsModal
|
<TagsModal
|
||||||
isOpen={isTagsModalOpen}
|
isOpen={isTagsModalOpen}
|
||||||
movieIds={movieIds}
|
indexerIds={indexerIds}
|
||||||
onApplyTagsPress={this.onApplyTagsPress}
|
onApplyTagsPress={this.onApplyTagsPress}
|
||||||
onModalClose={this.onTagsModalClose}
|
onModalClose={this.onTagsModalClose}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DeleteMovieModal
|
<DeleteIndexerModal
|
||||||
isOpen={isDeleteMovieModalOpen}
|
isOpen={isDeleteMovieModalOpen}
|
||||||
movieIds={movieIds}
|
indexerIds={indexerIds}
|
||||||
onModalClose={this.onDeleteMovieModalClose}
|
onModalClose={this.onDeleteMovieModalClose}
|
||||||
/>
|
/>
|
||||||
</PageContentFooter>
|
</PageContentFooter>
|
||||||
@@ -151,8 +151,8 @@ class MovieEditorFooter extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MovieEditorFooter.propTypes = {
|
IndexerEditorFooter.propTypes = {
|
||||||
movieIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
indexerIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||||
selectedCount: PropTypes.number.isRequired,
|
selectedCount: PropTypes.number.isRequired,
|
||||||
isSaving: PropTypes.bool.isRequired,
|
isSaving: PropTypes.bool.isRequired,
|
||||||
saveError: PropTypes.object,
|
saveError: PropTypes.object,
|
||||||
@@ -161,4 +161,4 @@ MovieEditorFooter.propTypes = {
|
|||||||
onSaveSelected: PropTypes.func.isRequired
|
onSaveSelected: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MovieEditorFooter;
|
export default IndexerEditorFooter;
|
@@ -2,9 +2,9 @@ import PropTypes from 'prop-types';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import SpinnerIcon from 'Components/SpinnerIcon';
|
import SpinnerIcon from 'Components/SpinnerIcon';
|
||||||
import { icons } from 'Helpers/Props';
|
import { icons } from 'Helpers/Props';
|
||||||
import styles from './MovieEditorFooterLabel.css';
|
import styles from './IndexerEditorFooterLabel.css';
|
||||||
|
|
||||||
function MovieEditorFooterLabel(props) {
|
function IndexerEditorFooterLabel(props) {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
label,
|
label,
|
||||||
@@ -27,14 +27,14 @@ function MovieEditorFooterLabel(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MovieEditorFooterLabel.propTypes = {
|
IndexerEditorFooterLabel.propTypes = {
|
||||||
className: PropTypes.string.isRequired,
|
className: PropTypes.string.isRequired,
|
||||||
label: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
isSaving: PropTypes.bool.isRequired
|
isSaving: PropTypes.bool.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
MovieEditorFooterLabel.defaultProps = {
|
IndexerEditorFooterLabel.defaultProps = {
|
||||||
className: styles.label
|
className: styles.label
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MovieEditorFooterLabel;
|
export default IndexerEditorFooterLabel;
|
@@ -1,17 +1,17 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createAllMoviesSelector from 'Store/Selectors/createAllMoviesSelector';
|
import createAllIndexersSelector from 'Store/Selectors/createAllIndexersSelector';
|
||||||
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
||||||
import TagsModalContent from './TagsModalContent';
|
import TagsModalContent from './TagsModalContent';
|
||||||
|
|
||||||
function createMapStateToProps() {
|
function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { movieIds }) => movieIds,
|
(state, { indexerIds }) => indexerIds,
|
||||||
createAllMoviesSelector(),
|
createAllIndexersSelector(),
|
||||||
createTagsSelector(),
|
createTagsSelector(),
|
||||||
(movieIds, allMovies, tagList) => {
|
(indexerIds, allMovies, tagList) => {
|
||||||
const movies = _.intersectionWith(allMovies, movieIds, (s, id) => {
|
const movies = _.intersectionWith(allMovies, indexerIds, (s, id) => {
|
||||||
return s.id === id;
|
return s.id === id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection';
|
|||||||
import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator';
|
import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator';
|
||||||
import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper';
|
import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper';
|
||||||
import { align, icons, sortDirections } from 'Helpers/Props';
|
import { align, icons, sortDirections } from 'Helpers/Props';
|
||||||
import MovieEditorFooter from 'Indexer/Editor/MovieEditorFooter.js';
|
import IndexerEditorFooter from 'Indexer/Editor/IndexerEditorFooter.js';
|
||||||
import NoIndexer from 'Indexer/NoIndexer';
|
import NoIndexer from 'Indexer/NoIndexer';
|
||||||
import AddIndexerModal from 'Settings/Indexers/Indexers/AddIndexerModal';
|
import AddIndexerModal from 'Settings/Indexers/Indexers/AddIndexerModal';
|
||||||
import EditIndexerModalConnector from 'Settings/Indexers/Indexers/EditIndexerModalConnector';
|
import EditIndexerModalConnector from 'Settings/Indexers/Indexers/EditIndexerModalConnector';
|
||||||
@@ -444,8 +444,8 @@ class IndexerIndex extends Component {
|
|||||||
|
|
||||||
{
|
{
|
||||||
isLoaded && isMovieEditorActive &&
|
isLoaded && isMovieEditorActive &&
|
||||||
<MovieEditorFooter
|
<IndexerEditorFooter
|
||||||
movieIds={selectedMovieIds}
|
indexerIds={selectedMovieIds}
|
||||||
selectedCount={selectedMovieIds.length}
|
selectedCount={selectedMovieIds.length}
|
||||||
isSaving={isSaving}
|
isSaving={isSaving}
|
||||||
saveError={saveError}
|
saveError={saveError}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createAllMoviesSelector from 'Store/Selectors/createAllMoviesSelector';
|
import createAllIndexersSelector from 'Store/Selectors/createAllIndexersSelector';
|
||||||
import TagDetailsModalContent from './TagDetailsModalContent';
|
import TagDetailsModalContent from './TagDetailsModalContent';
|
||||||
|
|
||||||
function findMatchingItems(ids, items) {
|
function findMatchingItems(ids, items) {
|
||||||
@@ -11,8 +11,8 @@ function findMatchingItems(ids, items) {
|
|||||||
|
|
||||||
function createUnorderedMatchingMoviesSelector() {
|
function createUnorderedMatchingMoviesSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { movieIds }) => movieIds,
|
(state, { indexerIds }) => indexerIds,
|
||||||
createAllMoviesSelector(),
|
createAllIndexersSelector(),
|
||||||
findMatchingItems
|
findMatchingItems
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -37,14 +37,6 @@ function createMatchingMoviesSelector() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMatchingDelayProfilesSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state, { delayProfileIds }) => delayProfileIds,
|
|
||||||
(state) => state.settings.delayProfiles.items,
|
|
||||||
findMatchingItems
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createMatchingNotificationsSelector() {
|
function createMatchingNotificationsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { notificationIds }) => notificationIds,
|
(state, { notificationIds }) => notificationIds,
|
||||||
@@ -53,26 +45,14 @@ function createMatchingNotificationsSelector() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMatchingRestrictionsSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state, { restrictionIds }) => restrictionIds,
|
|
||||||
(state) => state.settings.restrictions.items,
|
|
||||||
findMatchingItems
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createMapStateToProps() {
|
function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
createMatchingMoviesSelector(),
|
createMatchingMoviesSelector(),
|
||||||
createMatchingDelayProfilesSelector(),
|
|
||||||
createMatchingNotificationsSelector(),
|
createMatchingNotificationsSelector(),
|
||||||
createMatchingRestrictionsSelector(),
|
(movies, notifications) => {
|
||||||
(movies, delayProfiles, notifications, restrictions) => {
|
|
||||||
return {
|
return {
|
||||||
movies,
|
movies,
|
||||||
delayProfiles,
|
notifications
|
||||||
notifications,
|
|
||||||
restrictions
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -4,7 +4,7 @@ import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Hel
|
|||||||
import { createThunk, handleThunks } from 'Store/thunks';
|
import { createThunk, handleThunks } from 'Store/thunks';
|
||||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||||
import translate from 'Utilities/String/translate';
|
import translate from 'Utilities/String/translate';
|
||||||
import { set, updateItem } from './baseActions';
|
import { removeItem, set, updateItem } from './baseActions';
|
||||||
import createHandleActions from './Creators/createHandleActions';
|
import createHandleActions from './Creators/createHandleActions';
|
||||||
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
|
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
|
||||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||||
@@ -24,9 +24,9 @@ export const defaultState = {
|
|||||||
saveError: null,
|
saveError: null,
|
||||||
isDeleting: false,
|
isDeleting: false,
|
||||||
deleteError: null,
|
deleteError: null,
|
||||||
sortKey: 'sortTitle',
|
sortKey: 'name',
|
||||||
sortDirection: sortDirections.ASCENDING,
|
sortDirection: sortDirections.ASCENDING,
|
||||||
secondarySortKey: 'sortTitle',
|
secondarySortKey: 'name',
|
||||||
secondarySortDirection: sortDirections.ASCENDING,
|
secondarySortDirection: sortDirections.ASCENDING,
|
||||||
|
|
||||||
tableOptions: {
|
tableOptions: {
|
||||||
@@ -105,7 +105,7 @@ export const defaultState = {
|
|||||||
|
|
||||||
filterBuilderProps: [
|
filterBuilderProps: [
|
||||||
{
|
{
|
||||||
name: 'title',
|
name: 'name',
|
||||||
label: 'Indexer Name',
|
label: 'Indexer Name',
|
||||||
type: filterBuilderTypes.STRING
|
type: filterBuilderTypes.STRING
|
||||||
},
|
},
|
||||||
@@ -142,7 +142,7 @@ export const SET_MOVIE_FILTER = 'indexerIndex/setMovieFilter';
|
|||||||
export const SET_MOVIE_VIEW = 'indexerIndex/setMovieView';
|
export const SET_MOVIE_VIEW = 'indexerIndex/setMovieView';
|
||||||
export const SET_MOVIE_TABLE_OPTION = 'indexerIndex/setMovieTableOption';
|
export const SET_MOVIE_TABLE_OPTION = 'indexerIndex/setMovieTableOption';
|
||||||
export const SAVE_MOVIE_EDITOR = 'indexerIndex/saveMovieEditor';
|
export const SAVE_MOVIE_EDITOR = 'indexerIndex/saveMovieEditor';
|
||||||
export const BULK_DELETE_MOVIE = 'indexerIndex/bulkDeleteMovie';
|
export const BULK_DELETE_INDEXERS = 'indexerIndex/bulkDeleteIndexers';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action Creators
|
// Action Creators
|
||||||
@@ -152,7 +152,7 @@ export const setMovieFilter = createAction(SET_MOVIE_FILTER);
|
|||||||
export const setMovieView = createAction(SET_MOVIE_VIEW);
|
export const setMovieView = createAction(SET_MOVIE_VIEW);
|
||||||
export const setMovieTableOption = createAction(SET_MOVIE_TABLE_OPTION);
|
export const setMovieTableOption = createAction(SET_MOVIE_TABLE_OPTION);
|
||||||
export const saveMovieEditor = createThunk(SAVE_MOVIE_EDITOR);
|
export const saveMovieEditor = createThunk(SAVE_MOVIE_EDITOR);
|
||||||
export const bulkDeleteMovie = createThunk(BULK_DELETE_MOVIE);
|
export const bulkDeleteIndexers = createThunk(BULK_DELETE_INDEXERS);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action Handlers
|
// Action Handlers
|
||||||
@@ -198,27 +198,31 @@ export const actionHandlers = handleThunks({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[BULK_DELETE_MOVIE]: function(getState, payload, dispatch) {
|
[BULK_DELETE_INDEXERS]: function(getState, payload, dispatch) {
|
||||||
dispatch(set({
|
dispatch(set({
|
||||||
section,
|
section,
|
||||||
isDeleting: true
|
isDeleting: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const promise = createAjaxRequest({
|
const promise = createAjaxRequest({
|
||||||
url: '/movie/editor',
|
url: '/indexer/editor',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
data: JSON.stringify(payload),
|
data: JSON.stringify(payload),
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).request;
|
}).request;
|
||||||
|
|
||||||
promise.done(() => {
|
promise.done(() => {
|
||||||
// SignaR will take care of removing the movie from the collection
|
dispatch(batchActions([
|
||||||
|
...payload.indexerIds.map((id) => {
|
||||||
|
return removeItem({ section: 'indexers', id });
|
||||||
|
}),
|
||||||
|
|
||||||
dispatch(set({
|
set({
|
||||||
section,
|
section,
|
||||||
isDeleting: false,
|
isDeleting: false,
|
||||||
deleteError: null
|
deleteError: null
|
||||||
}));
|
})
|
||||||
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
promise.fail((xhr) => {
|
promise.fail((xhr) => {
|
||||||
|
12
frontend/src/Store/Selectors/createAllIndexersSelector.js
Normal file
12
frontend/src/Store/Selectors/createAllIndexersSelector.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
|
function createAllIndexersSelector() {
|
||||||
|
return createSelector(
|
||||||
|
(state) => state.indexers,
|
||||||
|
(indexers) => {
|
||||||
|
return indexers.items;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createAllIndexersSelector;
|
@@ -1,12 +0,0 @@
|
|||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
function createAllMoviesSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state) => state.movies,
|
|
||||||
(movies) => {
|
|
||||||
return movies.items;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createAllMoviesSelector;
|
|
@@ -14,6 +14,7 @@ namespace NzbDrone.Core.Indexers
|
|||||||
List<IIndexer> RssEnabled(bool filterBlockedIndexers = true);
|
List<IIndexer> RssEnabled(bool filterBlockedIndexers = true);
|
||||||
List<IIndexer> AutomaticSearchEnabled(bool filterBlockedIndexers = true);
|
List<IIndexer> AutomaticSearchEnabled(bool filterBlockedIndexers = true);
|
||||||
List<IIndexer> InteractiveSearchEnabled(bool filterBlockedIndexers = true);
|
List<IIndexer> InteractiveSearchEnabled(bool filterBlockedIndexers = true);
|
||||||
|
void DeleteIndexers(List<int> indexerIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, IIndexerFactory
|
public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, IIndexerFactory
|
||||||
@@ -102,6 +103,18 @@ namespace NzbDrone.Core.Indexers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteIndexers(List<int> indexerIds)
|
||||||
|
{
|
||||||
|
var indexersToDelete = _providerRepository.Get(indexerIds).ToList();
|
||||||
|
|
||||||
|
_providerRepository.DeleteMany(indexerIds);
|
||||||
|
|
||||||
|
foreach (var indexer in indexersToDelete)
|
||||||
|
{
|
||||||
|
_logger.Info("Deleted indexer {0}", indexer.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ValidationResult Test(IndexerDefinition definition)
|
public override ValidationResult Test(IndexerDefinition definition)
|
||||||
{
|
{
|
||||||
var result = base.Test(definition);
|
var result = base.Test(definition);
|
||||||
|
@@ -14,7 +14,7 @@ namespace NzbDrone.Core.ThingiProvider
|
|||||||
where TProviderDefinition : ProviderDefinition, new()
|
where TProviderDefinition : ProviderDefinition, new()
|
||||||
where TProvider : IProvider
|
where TProvider : IProvider
|
||||||
{
|
{
|
||||||
private readonly IProviderRepository<TProviderDefinition> _providerRepository;
|
protected readonly IProviderRepository<TProviderDefinition> _providerRepository;
|
||||||
private readonly IContainer _container;
|
private readonly IContainer _container;
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
@@ -8,7 +8,7 @@ using Prowlarr.Http.Extensions;
|
|||||||
|
|
||||||
namespace Prowlarr.Api.V1.FileSystem
|
namespace Prowlarr.Api.V1.FileSystem
|
||||||
{
|
{
|
||||||
public class FileSystemModule : ProwlarrV3Module
|
public class FileSystemModule : ProwlarrV1Module
|
||||||
{
|
{
|
||||||
private readonly IFileSystemLookupService _fileSystemLookupService;
|
private readonly IFileSystemLookupService _fileSystemLookupService;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
30
src/Prowlarr.Api.V1/Indexers/IndexerEditorModule.cs
Normal file
30
src/Prowlarr.Api.V1/Indexers/IndexerEditorModule.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Nancy;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
|
using Prowlarr.Http.Extensions;
|
||||||
|
|
||||||
|
namespace Prowlarr.Api.V1.Indexers
|
||||||
|
{
|
||||||
|
public class IndexerEditorModule : ProwlarrV1Module
|
||||||
|
{
|
||||||
|
private readonly IIndexerFactory _movieService;
|
||||||
|
private readonly IManageCommandQueue _commandQueueManager;
|
||||||
|
|
||||||
|
public IndexerEditorModule(IIndexerFactory movieService, IManageCommandQueue commandQueueManager)
|
||||||
|
: base("/indexer/editor")
|
||||||
|
{
|
||||||
|
_movieService = movieService;
|
||||||
|
_commandQueueManager = commandQueueManager;
|
||||||
|
Delete("/", movie => DeleteIndexers());
|
||||||
|
}
|
||||||
|
|
||||||
|
private object DeleteIndexers()
|
||||||
|
{
|
||||||
|
var resource = Request.Body.FromJson<IndexerEditorResource>();
|
||||||
|
|
||||||
|
_movieService.DeleteIndexers(resource.IndexerIds);
|
||||||
|
|
||||||
|
return new object();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/Prowlarr.Api.V1/Indexers/IndexerEditorResource.cs
Normal file
9
src/Prowlarr.Api.V1/Indexers/IndexerEditorResource.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Prowlarr.Api.V1.Indexers
|
||||||
|
{
|
||||||
|
public class IndexerEditorResource
|
||||||
|
{
|
||||||
|
public List<int> IndexerIds { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -2,9 +2,9 @@ using Prowlarr.Http;
|
|||||||
|
|
||||||
namespace Prowlarr.Api.V1
|
namespace Prowlarr.Api.V1
|
||||||
{
|
{
|
||||||
public abstract class ProwlarrV3Module : ProwlarrModule
|
public abstract class ProwlarrV1Module : ProwlarrModule
|
||||||
{
|
{
|
||||||
protected ProwlarrV3Module(string resource)
|
protected ProwlarrV1Module(string resource)
|
||||||
: base("/api/v1/" + resource.Trim('/'))
|
: base("/api/v1/" + resource.Trim('/'))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ using NzbDrone.Core.Lifecycle;
|
|||||||
|
|
||||||
namespace Prowlarr.Api.V1.System
|
namespace Prowlarr.Api.V1.System
|
||||||
{
|
{
|
||||||
public class SystemModule : ProwlarrV3Module
|
public class SystemModule : ProwlarrV1Module
|
||||||
{
|
{
|
||||||
private readonly IAppFolderInfo _appFolderInfo;
|
private readonly IAppFolderInfo _appFolderInfo;
|
||||||
private readonly IRuntimeInfo _runtimeInfo;
|
private readonly IRuntimeInfo _runtimeInfo;
|
||||||
|
Reference in New Issue
Block a user