mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
New: Remember add import list exclusion when removing artists
(cherry picked from commit d8f6eaebdcf7e9b8170fe2baf1fe232fe02a1331) Closes #3260 Closes #326
This commit is contained in:
parent
f509ca0f72
commit
28ac640103
3 changed files with 58 additions and 52 deletions
|
@ -23,8 +23,7 @@ class DeleteArtistModalContent extends Component {
|
|||
super(props, context);
|
||||
|
||||
this.state = {
|
||||
deleteFiles: false,
|
||||
addImportListExclusion: false
|
||||
deleteFiles: false
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -35,16 +34,11 @@ class DeleteArtistModalContent extends Component {
|
|||
this.setState({ deleteFiles: value });
|
||||
};
|
||||
|
||||
onAddImportListExclusionChange = ({ value }) => {
|
||||
this.setState({ addImportListExclusion: value });
|
||||
};
|
||||
|
||||
onDeleteArtistConfirmed = () => {
|
||||
const deleteFiles = this.state.deleteFiles;
|
||||
const addImportListExclusion = this.state.addImportListExclusion;
|
||||
const addImportListExclusion = this.props.deleteOptions.addImportListExclusion;
|
||||
|
||||
this.setState({ deleteFiles: false });
|
||||
this.setState({ addImportListExclusion: false });
|
||||
this.props.onDeletePress(deleteFiles, addImportListExclusion);
|
||||
};
|
||||
|
||||
|
@ -56,7 +50,9 @@ class DeleteArtistModalContent extends Component {
|
|||
artistName,
|
||||
path,
|
||||
statistics,
|
||||
onModalClose
|
||||
deleteOptions,
|
||||
onModalClose,
|
||||
onDeleteOptionChange
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
|
@ -65,7 +61,7 @@ class DeleteArtistModalContent extends Component {
|
|||
} = statistics;
|
||||
|
||||
const deleteFiles = this.state.deleteFiles;
|
||||
const addImportListExclusion = this.state.addImportListExclusion;
|
||||
const addImportListExclusion = deleteOptions.addImportListExclusion;
|
||||
|
||||
let deleteFilesLabel = `Delete ${trackFileCount} Track Files`;
|
||||
let deleteFilesHelpText = translate('DeleteFilesHelpText');
|
||||
|
@ -117,7 +113,7 @@ class DeleteArtistModalContent extends Component {
|
|||
value={addImportListExclusion}
|
||||
helpText={translate('AddImportListExclusionArtistHelpText')}
|
||||
kind={kinds.DANGER}
|
||||
onChange={this.onAddImportListExclusionChange}
|
||||
onChange={onDeleteOptionChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
|
@ -158,6 +154,8 @@ DeleteArtistModalContent.propTypes = {
|
|||
artistName: PropTypes.string.isRequired,
|
||||
path: PropTypes.string.isRequired,
|
||||
statistics: PropTypes.object.isRequired,
|
||||
deleteOptions: PropTypes.object.isRequired,
|
||||
onDeleteOptionChange: PropTypes.func.isRequired,
|
||||
onDeletePress: PropTypes.func.isRequired,
|
||||
onModalClose: PropTypes.func.isRequired
|
||||
};
|
||||
|
|
|
@ -1,56 +1,44 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { deleteArtist } from 'Store/Actions/artistActions';
|
||||
import { deleteArtist, setDeleteOption } from 'Store/Actions/artistActions';
|
||||
import createArtistSelector from 'Store/Selectors/createArtistSelector';
|
||||
import DeleteArtistModalContent from './DeleteArtistModalContent';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.artist.deleteOptions,
|
||||
createArtistSelector(),
|
||||
(artist) => {
|
||||
return artist;
|
||||
(deleteOptions, artist) => {
|
||||
return {
|
||||
...artist,
|
||||
deleteOptions
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
deleteArtist
|
||||
};
|
||||
function createMapDispatchToProps(dispatch, props) {
|
||||
return {
|
||||
onDeleteOptionChange(option) {
|
||||
dispatch(
|
||||
setDeleteOption({
|
||||
[option.name]: option.value
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
class DeleteArtistModalContentConnector extends Component {
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onDeletePress = (deleteFiles, addImportListExclusion) => {
|
||||
this.props.deleteArtist({
|
||||
id: this.props.artistId,
|
||||
onDeletePress(deleteFiles, addImportListExclusion) {
|
||||
dispatch(
|
||||
deleteArtist({
|
||||
id: props.artistId,
|
||||
deleteFiles,
|
||||
addImportListExclusion
|
||||
});
|
||||
|
||||
this.props.onModalClose(true);
|
||||
};
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DeleteArtistModalContent
|
||||
{...this.props}
|
||||
onDeletePress={this.onDeletePress}
|
||||
/>
|
||||
})
|
||||
);
|
||||
|
||||
props.onModalClose(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
DeleteArtistModalContentConnector.propTypes = {
|
||||
artistId: PropTypes.number.isRequired,
|
||||
onModalClose: PropTypes.func.isRequired,
|
||||
deleteArtist: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(DeleteArtistModalContentConnector);
|
||||
export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteArtistModalContent);
|
||||
|
|
|
@ -157,9 +157,16 @@ export const defaultState = {
|
|||
items: [],
|
||||
sortKey: 'sortName',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
pendingChanges: {}
|
||||
pendingChanges: {},
|
||||
deleteOptions: {
|
||||
addImportListExclusion: false
|
||||
}
|
||||
};
|
||||
|
||||
export const persistState = [
|
||||
'artist.deleteOptions'
|
||||
];
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
|
@ -171,6 +178,8 @@ export const DELETE_ARTIST = 'artist/deleteArtist';
|
|||
export const TOGGLE_ARTIST_MONITORED = 'artist/toggleArtistMonitored';
|
||||
export const TOGGLE_ALBUM_MONITORED = 'artist/toggleAlbumMonitored';
|
||||
|
||||
export const SET_DELETE_OPTION = 'artist/setDeleteOption';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
|
@ -211,6 +220,8 @@ export const setArtistValue = createAction(SET_ARTIST_VALUE, (payload) => {
|
|||
};
|
||||
});
|
||||
|
||||
export const setDeleteOption = createAction(SET_DELETE_OPTION);
|
||||
|
||||
//
|
||||
// Helpers
|
||||
|
||||
|
@ -340,6 +351,15 @@ export const actionHandlers = handleThunks({
|
|||
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[SET_ARTIST_VALUE]: createSetSettingValueReducer(section)
|
||||
[SET_ARTIST_VALUE]: createSetSettingValueReducer(section),
|
||||
|
||||
[SET_DELETE_OPTION]: (state, { payload }) => {
|
||||
return {
|
||||
...state,
|
||||
deleteOptions: {
|
||||
...payload
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}, defaultState, section);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue