mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
New: Add option to only monitor selected book when adding single book
This commit is contained in:
@@ -7,6 +7,7 @@ function MonitorBooksSelectInput(props) {
|
|||||||
const {
|
const {
|
||||||
includeNoChange,
|
includeNoChange,
|
||||||
includeMixed,
|
includeMixed,
|
||||||
|
includeSpecificBook,
|
||||||
...otherProps
|
...otherProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
@@ -28,6 +29,13 @@ function MonitorBooksSelectInput(props) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (includeSpecificBook) {
|
||||||
|
values.push({
|
||||||
|
key: 'specificBook',
|
||||||
|
value: 'Only This Book'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectInput
|
<SelectInput
|
||||||
values={values}
|
values={values}
|
||||||
@@ -39,12 +47,14 @@ function MonitorBooksSelectInput(props) {
|
|||||||
MonitorBooksSelectInput.propTypes = {
|
MonitorBooksSelectInput.propTypes = {
|
||||||
includeNoChange: PropTypes.bool.isRequired,
|
includeNoChange: PropTypes.bool.isRequired,
|
||||||
includeMixed: PropTypes.bool.isRequired,
|
includeMixed: PropTypes.bool.isRequired,
|
||||||
|
includeSpecificBook: PropTypes.bool.isRequired,
|
||||||
onChange: PropTypes.func.isRequired
|
onChange: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
MonitorBooksSelectInput.defaultProps = {
|
MonitorBooksSelectInput.defaultProps = {
|
||||||
includeNoChange: false,
|
includeNoChange: false,
|
||||||
includeMixed: false
|
includeMixed: false,
|
||||||
|
includeSpecificBook: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MonitorBooksSelectInput;
|
export default MonitorBooksSelectInput;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { addAuthor, setAddDefault } from 'Store/Actions/searchActions';
|
import { addAuthor, setAuthorAddDefault } from 'Store/Actions/searchActions';
|
||||||
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
|
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
|
||||||
import selectSettings from 'Store/Selectors/selectSettings';
|
import selectSettings from 'Store/Selectors/selectSettings';
|
||||||
import AddNewAuthorModalContent from './AddNewAuthorModalContent';
|
import AddNewAuthorModalContent from './AddNewAuthorModalContent';
|
||||||
@@ -16,14 +16,14 @@ function createMapStateToProps() {
|
|||||||
const {
|
const {
|
||||||
isAdding,
|
isAdding,
|
||||||
addError,
|
addError,
|
||||||
defaults
|
authorDefaults
|
||||||
} = searchState;
|
} = searchState;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
settings,
|
settings,
|
||||||
validationErrors,
|
validationErrors,
|
||||||
validationWarnings
|
validationWarnings
|
||||||
} = selectSettings(defaults, {}, addError);
|
} = selectSettings(authorDefaults, {}, addError);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAdding,
|
isAdding,
|
||||||
@@ -39,7 +39,7 @@ function createMapStateToProps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
setAddDefault,
|
setAuthorAddDefault,
|
||||||
addAuthor
|
addAuthor
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ class AddNewAuthorModalContentConnector extends Component {
|
|||||||
// Listeners
|
// Listeners
|
||||||
|
|
||||||
onInputChange = ({ name, value }) => {
|
onInputChange = ({ name, value }) => {
|
||||||
this.props.setAddDefault({ [name]: value });
|
this.props.setAuthorAddDefault({ [name]: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddAuthorPress = (searchForMissingBooks) => {
|
onAddAuthorPress = (searchForMissingBooks) => {
|
||||||
@@ -95,7 +95,7 @@ AddNewAuthorModalContentConnector.propTypes = {
|
|||||||
metadataProfileId: PropTypes.object,
|
metadataProfileId: PropTypes.object,
|
||||||
tags: PropTypes.object.isRequired,
|
tags: PropTypes.object.isRequired,
|
||||||
onModalClose: PropTypes.func.isRequired,
|
onModalClose: PropTypes.func.isRequired,
|
||||||
setAddDefault: PropTypes.func.isRequired,
|
setAuthorAddDefault: PropTypes.func.isRequired,
|
||||||
addAuthor: PropTypes.func.isRequired
|
addAuthor: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class AddNewBookModalContent extends Component {
|
|||||||
<AddAuthorOptionsForm
|
<AddAuthorOptionsForm
|
||||||
authorName={authorName}
|
authorName={authorName}
|
||||||
includeNoneMetadataProfile={true}
|
includeNoneMetadataProfile={true}
|
||||||
|
includeSpecificBookMonitor={true}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import PropTypes from 'prop-types';
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { metadataProfileNames } from 'Helpers/Props';
|
import { addBook, setBookAddDefault } from 'Store/Actions/searchActions';
|
||||||
import { addBook, setAddDefault } from 'Store/Actions/searchActions';
|
|
||||||
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
|
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
|
||||||
import selectSettings from 'Store/Selectors/selectSettings';
|
import selectSettings from 'Store/Selectors/selectSettings';
|
||||||
import AddNewBookModalContent from './AddNewBookModalContent';
|
import AddNewBookModalContent from './AddNewBookModalContent';
|
||||||
@@ -18,17 +17,14 @@ function createMapStateToProps() {
|
|||||||
const {
|
const {
|
||||||
isAdding,
|
isAdding,
|
||||||
addError,
|
addError,
|
||||||
defaults
|
bookDefaults
|
||||||
} = searchState;
|
} = searchState;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
settings,
|
settings,
|
||||||
validationErrors,
|
validationErrors,
|
||||||
validationWarnings
|
validationWarnings
|
||||||
} = selectSettings(defaults, {}, addError);
|
} = selectSettings(bookDefaults, {}, addError);
|
||||||
|
|
||||||
// For adding single books, default to None profile
|
|
||||||
const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAdding,
|
isAdding,
|
||||||
@@ -37,7 +33,6 @@ function createMapStateToProps() {
|
|||||||
isSmallScreen: dimensions.isSmallScreen,
|
isSmallScreen: dimensions.isSmallScreen,
|
||||||
validationErrors,
|
validationErrors,
|
||||||
validationWarnings,
|
validationWarnings,
|
||||||
noneMetadataProfileId: noneProfile.id,
|
|
||||||
...settings
|
...settings
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -45,39 +40,17 @@ function createMapStateToProps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
setAddDefault,
|
setBookAddDefault,
|
||||||
addBook
|
addBook
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddNewBookModalContentConnector extends Component {
|
class AddNewBookModalContentConnector extends Component {
|
||||||
|
|
||||||
//
|
|
||||||
// Lifecycle
|
|
||||||
|
|
||||||
constructor(props, context) {
|
|
||||||
super(props, context);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
metadataProfileIdDefault: props.metadataProfileId.value
|
|
||||||
};
|
|
||||||
|
|
||||||
// select none as default
|
|
||||||
this.onInputChange({
|
|
||||||
name: 'metadataProfileId',
|
|
||||||
value: props.noneMetadataProfileId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
// reinstate standard default
|
|
||||||
this.props.setAddDefault({ metadataProfileId: this.state.metadataProfileIdDefault });
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Listeners
|
// Listeners
|
||||||
|
|
||||||
onInputChange = ({ name, value }) => {
|
onInputChange = ({ name, value }) => {
|
||||||
this.props.setAddDefault({ [name]: value });
|
this.props.setBookAddDefault({ [name]: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddBookPress = (searchForNewBook) => {
|
onAddBookPress = (searchForNewBook) => {
|
||||||
@@ -122,10 +95,9 @@ AddNewBookModalContentConnector.propTypes = {
|
|||||||
monitor: PropTypes.object.isRequired,
|
monitor: PropTypes.object.isRequired,
|
||||||
qualityProfileId: PropTypes.object,
|
qualityProfileId: PropTypes.object,
|
||||||
metadataProfileId: PropTypes.object,
|
metadataProfileId: PropTypes.object,
|
||||||
noneMetadataProfileId: PropTypes.number.isRequired,
|
|
||||||
tags: PropTypes.object.isRequired,
|
tags: PropTypes.object.isRequired,
|
||||||
onModalClose: PropTypes.func.isRequired,
|
onModalClose: PropTypes.func.isRequired,
|
||||||
setAddDefault: PropTypes.func.isRequired,
|
setBookAddDefault: PropTypes.func.isRequired,
|
||||||
addBook: PropTypes.func.isRequired
|
addBook: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class AddAuthorOptionsForm extends Component {
|
|||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
metadataProfileId,
|
metadataProfileId,
|
||||||
includeNoneMetadataProfile,
|
includeNoneMetadataProfile,
|
||||||
|
includeSpecificBookMonitor,
|
||||||
showMetadataProfile,
|
showMetadataProfile,
|
||||||
tags,
|
tags,
|
||||||
onInputChange,
|
onInputChange,
|
||||||
@@ -77,6 +78,7 @@ class AddAuthorOptionsForm extends Component {
|
|||||||
type={inputTypes.MONITOR_BOOKS_SELECT}
|
type={inputTypes.MONITOR_BOOKS_SELECT}
|
||||||
name="monitor"
|
name="monitor"
|
||||||
onChange={onInputChange}
|
onChange={onInputChange}
|
||||||
|
includeSpecificBook={includeSpecificBookMonitor}
|
||||||
{...monitor}
|
{...monitor}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
@@ -147,6 +149,7 @@ AddAuthorOptionsForm.propTypes = {
|
|||||||
metadataProfileId: PropTypes.object,
|
metadataProfileId: PropTypes.object,
|
||||||
showMetadataProfile: PropTypes.bool.isRequired,
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
includeNoneMetadataProfile: PropTypes.bool.isRequired,
|
includeNoneMetadataProfile: PropTypes.bool.isRequired,
|
||||||
|
includeSpecificBookMonitor: PropTypes.bool.isRequired,
|
||||||
tags: PropTypes.object.isRequired,
|
tags: PropTypes.object.isRequired,
|
||||||
onInputChange: PropTypes.func.isRequired
|
onInputChange: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,15 @@ export const defaultState = {
|
|||||||
addError: null,
|
addError: null,
|
||||||
items: [],
|
items: [],
|
||||||
|
|
||||||
defaults: {
|
authorDefaults: {
|
||||||
|
rootFolderPath: '',
|
||||||
|
monitor: monitorOptions[0].key,
|
||||||
|
qualityProfileId: 0,
|
||||||
|
metadataProfileId: 0,
|
||||||
|
tags: []
|
||||||
|
},
|
||||||
|
|
||||||
|
bookDefaults: {
|
||||||
rootFolderPath: '',
|
rootFolderPath: '',
|
||||||
monitor: monitorOptions[0].key,
|
monitor: monitorOptions[0].key,
|
||||||
qualityProfileId: 0,
|
qualityProfileId: 0,
|
||||||
@@ -39,7 +47,8 @@ export const defaultState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const persistState = [
|
export const persistState = [
|
||||||
'search.defaults'
|
'search.bookDefaults',
|
||||||
|
'search.authorDefaults'
|
||||||
];
|
];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -49,7 +58,8 @@ export const GET_SEARCH_RESULTS = 'search/getSearchResults';
|
|||||||
export const ADD_AUTHOR = 'search/addAuthor';
|
export const ADD_AUTHOR = 'search/addAuthor';
|
||||||
export const ADD_BOOK = 'search/addBook';
|
export const ADD_BOOK = 'search/addBook';
|
||||||
export const CLEAR_SEARCH_RESULTS = 'search/clearSearchResults';
|
export const CLEAR_SEARCH_RESULTS = 'search/clearSearchResults';
|
||||||
export const SET_ADD_DEFAULT = 'search/setAddDefault';
|
export const SET_AUTHOR_ADD_DEFAULT = 'search/setAuthorAddDefault';
|
||||||
|
export const SET_BOOK_ADD_DEFAULT = 'search/setBookAddDefault';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action Creators
|
// Action Creators
|
||||||
@@ -58,7 +68,8 @@ export const getSearchResults = createThunk(GET_SEARCH_RESULTS);
|
|||||||
export const addAuthor = createThunk(ADD_AUTHOR);
|
export const addAuthor = createThunk(ADD_AUTHOR);
|
||||||
export const addBook = createThunk(ADD_BOOK);
|
export const addBook = createThunk(ADD_BOOK);
|
||||||
export const clearSearchResults = createAction(CLEAR_SEARCH_RESULTS);
|
export const clearSearchResults = createAction(CLEAR_SEARCH_RESULTS);
|
||||||
export const setAddDefault = createAction(SET_ADD_DEFAULT);
|
export const setAuthorAddDefault = createAction(SET_AUTHOR_ADD_DEFAULT);
|
||||||
|
export const setBookAddDefault = createAction(SET_BOOK_ADD_DEFAULT);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action Handlers
|
// Action Handlers
|
||||||
@@ -191,11 +202,22 @@ export const actionHandlers = handleThunks({
|
|||||||
|
|
||||||
export const reducers = createHandleActions({
|
export const reducers = createHandleActions({
|
||||||
|
|
||||||
[SET_ADD_DEFAULT]: function(state, { payload }) {
|
[SET_AUTHOR_ADD_DEFAULT]: function(state, { payload }) {
|
||||||
const newState = getSectionState(state, section);
|
const newState = getSectionState(state, section);
|
||||||
|
|
||||||
newState.defaults = {
|
newState.authorDefaults = {
|
||||||
...newState.defaults,
|
...newState.authorDefaults,
|
||||||
|
...payload
|
||||||
|
};
|
||||||
|
|
||||||
|
return updateSectionState(state, section, newState);
|
||||||
|
},
|
||||||
|
|
||||||
|
[SET_BOOK_ADD_DEFAULT]: function(state, { payload }) {
|
||||||
|
const newState = getSectionState(state, section);
|
||||||
|
|
||||||
|
newState.bookDefaults = {
|
||||||
|
...newState.bookDefaults,
|
||||||
...payload
|
...payload
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -204,7 +226,8 @@ export const reducers = createHandleActions({
|
|||||||
|
|
||||||
[CLEAR_SEARCH_RESULTS]: function(state) {
|
[CLEAR_SEARCH_RESULTS]: function(state) {
|
||||||
const {
|
const {
|
||||||
defaults,
|
authorDefaults,
|
||||||
|
bookDefaults,
|
||||||
...otherDefaultState
|
...otherDefaultState
|
||||||
} = defaultState;
|
} = defaultState;
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import createAllAuthorsSelector from './createAllAuthorsSelector';
|
|
||||||
|
|
||||||
function createImportAuthorItemSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state, { id }) => id,
|
|
||||||
(state) => state.addAuthor,
|
|
||||||
(state) => state.importAuthor,
|
|
||||||
createAllAuthorsSelector(),
|
|
||||||
(id, addAuthor, importAuthor, author) => {
|
|
||||||
const item = _.find(importAuthor.items, { id }) || {};
|
|
||||||
const selectedAuthor = item && item.selectedAuthor;
|
|
||||||
const isExistingAuthor = !!selectedAuthor && _.some(author, { titleSlug: selectedAuthor.titleSlug });
|
|
||||||
|
|
||||||
return {
|
|
||||||
defaultMonitor: addAuthor.defaults.monitor,
|
|
||||||
defaultQualityProfileId: addAuthor.defaults.qualityProfileId,
|
|
||||||
...item,
|
|
||||||
isExistingAuthor
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createImportAuthorItemSelector;
|
|
||||||
@@ -7,6 +7,11 @@ function getNewBook(book, payload) {
|
|||||||
|
|
||||||
if (!('id' in book.author) || book.author.id === 0) {
|
if (!('id' in book.author) || book.author.id === 0) {
|
||||||
getNewAuthor(book.author, payload);
|
getNewAuthor(book.author, payload);
|
||||||
|
|
||||||
|
if (payload.monitor === 'specificBook') {
|
||||||
|
delete book.author.addOptions.monitor;
|
||||||
|
book.author.addOptions.booksToMonitor = [book.foreignBookId];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
book.addOptions = {
|
book.addOptions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user