|
|
@ -16,9 +16,18 @@ function createMapStateToProps() {
|
|
|
|
(state) => state.rootFolders,
|
|
|
|
(state) => state.rootFolders,
|
|
|
|
(state) => state.addArtist,
|
|
|
|
(state) => state.addArtist,
|
|
|
|
(state) => state.importArtist,
|
|
|
|
(state) => state.importArtist,
|
|
|
|
|
|
|
|
(state) => state.settings.qualityProfiles,
|
|
|
|
(state) => state.settings.languageProfiles,
|
|
|
|
(state) => state.settings.languageProfiles,
|
|
|
|
(state) => state.settings.metadataProfiles,
|
|
|
|
(state) => state.settings.metadataProfiles,
|
|
|
|
(match, rootFolders, addArtist, importArtistState, languageProfiles, metadataProfiles) => {
|
|
|
|
(
|
|
|
|
|
|
|
|
match,
|
|
|
|
|
|
|
|
rootFolders,
|
|
|
|
|
|
|
|
addArtist,
|
|
|
|
|
|
|
|
importArtistState,
|
|
|
|
|
|
|
|
qualityProfiles,
|
|
|
|
|
|
|
|
languageProfiles,
|
|
|
|
|
|
|
|
metadataProfiles
|
|
|
|
|
|
|
|
) => {
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
isFetching: rootFoldersFetching,
|
|
|
|
isFetching: rootFoldersFetching,
|
|
|
|
isPopulated: rootFoldersPopulated,
|
|
|
|
isPopulated: rootFoldersPopulated,
|
|
|
@ -33,8 +42,14 @@ function createMapStateToProps() {
|
|
|
|
rootFoldersFetching,
|
|
|
|
rootFoldersFetching,
|
|
|
|
rootFoldersPopulated,
|
|
|
|
rootFoldersPopulated,
|
|
|
|
rootFoldersError,
|
|
|
|
rootFoldersError,
|
|
|
|
|
|
|
|
qualityProfiles: qualityProfiles.items,
|
|
|
|
|
|
|
|
languageProfiles: languageProfiles.items,
|
|
|
|
|
|
|
|
metadataProfiles: metadataProfiles.items,
|
|
|
|
showLanguageProfile: languageProfiles.items.length > 1,
|
|
|
|
showLanguageProfile: languageProfiles.items.length > 1,
|
|
|
|
showMetadataProfile: metadataProfiles.items.length > 1
|
|
|
|
showMetadataProfile: metadataProfiles.items.length > 1,
|
|
|
|
|
|
|
|
defaultQualityProfileId: addArtist.defaults.qualityProfileId,
|
|
|
|
|
|
|
|
defaultLanguageProfileId: addArtist.defaults.languageProfileId,
|
|
|
|
|
|
|
|
defaultMetadataProfileId: addArtist.defaults.metadataProfileId
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (items.length) {
|
|
|
|
if (items.length) {
|
|
|
@ -53,11 +68,11 @@ function createMapStateToProps() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
setImportArtistValue,
|
|
|
|
dispatchSetImportArtistValue: setImportArtistValue,
|
|
|
|
importArtist,
|
|
|
|
dispatchImportArtist: importArtist,
|
|
|
|
clearImportArtist,
|
|
|
|
dispatchClearImportArtist: clearImportArtist,
|
|
|
|
fetchRootFolders,
|
|
|
|
dispatchFetchRootFolders: fetchRootFolders,
|
|
|
|
setAddArtistDefault
|
|
|
|
dispatchSetAddArtistDefault: setAddArtistDefault
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ImportArtistConnector extends Component {
|
|
|
|
class ImportArtistConnector extends Component {
|
|
|
@ -66,23 +81,65 @@ class ImportArtistConnector extends Component {
|
|
|
|
// Lifecycle
|
|
|
|
// Lifecycle
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
qualityProfiles,
|
|
|
|
|
|
|
|
languageProfiles,
|
|
|
|
|
|
|
|
metadataProfiles,
|
|
|
|
|
|
|
|
defaultQualityProfileId,
|
|
|
|
|
|
|
|
defaultLanguageProfileId,
|
|
|
|
|
|
|
|
defaultMetadataProfileId,
|
|
|
|
|
|
|
|
dispatchFetchRootFolders,
|
|
|
|
|
|
|
|
dispatchSetAddArtistDefault
|
|
|
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.props.rootFoldersPopulated) {
|
|
|
|
if (!this.props.rootFoldersPopulated) {
|
|
|
|
this.props.fetchRootFolders();
|
|
|
|
dispatchFetchRootFolders();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let setDefaults = false;
|
|
|
|
|
|
|
|
const setDefaultPayload = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
!defaultQualityProfileId ||
|
|
|
|
|
|
|
|
!qualityProfiles.some((p) => p.id === defaultQualityProfileId)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
setDefaults = true;
|
|
|
|
|
|
|
|
setDefaultPayload.qualityProfileId = qualityProfiles[0].id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
!defaultLanguageProfileId ||
|
|
|
|
|
|
|
|
!languageProfiles.some((p) => p.id === defaultLanguageProfileId)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
setDefaults = true;
|
|
|
|
|
|
|
|
setDefaultPayload.languageProfileId = languageProfiles[0].id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
!defaultMetadataProfileId ||
|
|
|
|
|
|
|
|
!metadataProfiles.some((p) => p.id === defaultMetadataProfileId)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
setDefaults = true;
|
|
|
|
|
|
|
|
setDefaultPayload.metadataProfileId = metadataProfiles[0].id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (setDefaults) {
|
|
|
|
|
|
|
|
dispatchSetAddArtistDefault(setDefaultPayload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
componentWillUnmount() {
|
|
|
|
this.props.clearImportArtist();
|
|
|
|
this.props.dispatchClearImportArtist();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Listeners
|
|
|
|
// Listeners
|
|
|
|
|
|
|
|
|
|
|
|
onInputChange = (ids, name, value) => {
|
|
|
|
onInputChange = (ids, name, value) => {
|
|
|
|
this.props.setAddArtistDefault({ [name]: value });
|
|
|
|
this.props.dispatchSetAddArtistDefault({ [name]: value });
|
|
|
|
|
|
|
|
|
|
|
|
ids.forEach((id) => {
|
|
|
|
ids.forEach((id) => {
|
|
|
|
this.props.setImportArtistValue({
|
|
|
|
this.props.dispatchSetImportArtistValue({
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
[name]: value
|
|
|
|
[name]: value
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -90,7 +147,7 @@ class ImportArtistConnector extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onImportPress = (ids) => {
|
|
|
|
onImportPress = (ids) => {
|
|
|
|
this.props.importArtist({ ids });
|
|
|
|
this.props.dispatchImportArtist({ ids });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -114,11 +171,17 @@ const routeMatchShape = createRouteMatchShape({
|
|
|
|
ImportArtistConnector.propTypes = {
|
|
|
|
ImportArtistConnector.propTypes = {
|
|
|
|
match: routeMatchShape.isRequired,
|
|
|
|
match: routeMatchShape.isRequired,
|
|
|
|
rootFoldersPopulated: PropTypes.bool.isRequired,
|
|
|
|
rootFoldersPopulated: PropTypes.bool.isRequired,
|
|
|
|
setImportArtistValue: PropTypes.func.isRequired,
|
|
|
|
qualityProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
importArtist: PropTypes.func.isRequired,
|
|
|
|
languageProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
clearImportArtist: PropTypes.func.isRequired,
|
|
|
|
metadataProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
fetchRootFolders: PropTypes.func.isRequired,
|
|
|
|
defaultQualityProfileId: PropTypes.number.isRequired,
|
|
|
|
setAddArtistDefault: PropTypes.func.isRequired
|
|
|
|
defaultLanguageProfileId: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
defaultMetadataProfileId: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
dispatchSetImportArtistValue: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
dispatchImportArtist: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
dispatchClearImportArtist: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
dispatchFetchRootFolders: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
dispatchSetAddArtistDefault: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistConnector);
|
|
|
|
export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistConnector);
|
|
|
|