New: Manually Edit/Override Album Release (#181)

* New: Manually Edit/Override Album Release

* !fixup for comments, loading all albums instead of only artist albums
* fixup! UI Cleanup lint issues
* fixup! Remove AddAlbum service for now, fix refresh override selected release
* fixup! Last one... to fix updating albums with custom release set

Closes #109 
Closes #129 
Closes #128
This commit is contained in:
Qstick 2018-01-17 21:28:47 -05:00 committed by GitHub
parent 74f433d4f0
commit 26ef43f302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 2928 additions and 408 deletions

View file

@ -0,0 +1,65 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import titleCase from 'Utilities/String/titleCase';
import SelectInput from './SelectInput';
function createMapStateToProps() {
return createSelector(
(state, { albumReleases }) => albumReleases,
(state, { selectedRelease }) => selectedRelease,
(albumReleases, selectedRelease) => {
const values = _.map(albumReleases.value, (albumRelease) => {
return {
key: albumRelease.id,
value: `${albumRelease.mediaCount} med, ${albumRelease.trackCount} tracks` +
`${albumRelease.country.length > 0 ? ', ' : ''}${albumRelease.country}` +
`${albumRelease.disambiguation ? ', ' : ''}${titleCase(albumRelease.disambiguation)}` +
`${albumRelease.format ? ', [' : ''}${albumRelease.format}${albumRelease.format ? ']' : ''}`
};
});
const value = selectedRelease.value.id;
return {
values,
value
};
}
);
}
class AlbumReleaseSelectInputConnector extends Component {
//
// Listeners
onChange = ({ name, value }) => {
const {
albumReleases
} = this.props;
this.props.onChange({ name, value: _.find(albumReleases.value, { id: value }) });
}
render() {
return (
<SelectInput
{...this.props}
onChange={this.onChange}
/>
);
}
}
AlbumReleaseSelectInputConnector.propTypes = {
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
albumReleases: PropTypes.object
};
export default connect(createMapStateToProps)(AlbumReleaseSelectInputConnector);

View file

@ -12,6 +12,7 @@ import PathInputConnector from './PathInputConnector';
import QualityProfileSelectInputConnector from './QualityProfileSelectInputConnector';
import LanguageProfileSelectInputConnector from './LanguageProfileSelectInputConnector';
import MetadataProfileSelectInputConnector from './MetadataProfileSelectInputConnector';
import AlbumReleaseSelectInputConnector from './AlbumReleaseSelectInputConnector';
import RootFolderSelectInputConnector from './RootFolderSelectInputConnector';
import SeriesTypeSelectInput from './SeriesTypeSelectInput';
import SelectInput from './SelectInput';
@ -53,6 +54,9 @@ function getComponent(type) {
case inputTypes.METADATA_PROFILE_SELECT:
return MetadataProfileSelectInputConnector;
case inputTypes.ALBUM_RELEASE_SELECT:
return AlbumReleaseSelectInputConnector;
case inputTypes.ROOT_FOLDER_SELECT:
return RootFolderSelectInputConnector;

View file

@ -218,12 +218,16 @@ class SignalRConnector extends Component {
}
handleTrack = (body) => {
if (body.action === 'updated') {
const action = body.action;
const section = 'tracks';
if (action === 'updated') {
this.props.updateItem({
section: 'tracks',
updateOnly: true,
section,
...body.resource
});
} else if (action === 'deleted') {
this.props.removeItem({ section, id: body.resource.id });
}
}