mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
New: Readarr 0.1
This commit is contained in:
@@ -23,7 +23,6 @@ import TableBody from 'Components/Table/TableBody';
|
||||
import SelectQualityModal from 'InteractiveImport/Quality/SelectQualityModal';
|
||||
import SelectArtistModal from 'InteractiveImport/Artist/SelectArtistModal';
|
||||
import SelectAlbumModal from 'InteractiveImport/Album/SelectAlbumModal';
|
||||
import SelectAlbumReleaseModal from 'InteractiveImport/AlbumRelease/SelectAlbumReleaseModal';
|
||||
import ConfirmImportModal from 'InteractiveImport/Confirmation/ConfirmImportModal';
|
||||
import InteractiveImportRow from './InteractiveImportRow';
|
||||
import styles from './InteractiveImportModalContent.css';
|
||||
@@ -43,12 +42,7 @@ const columns = [
|
||||
},
|
||||
{
|
||||
name: 'album',
|
||||
label: 'Album',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'tracks',
|
||||
label: 'Track(s)',
|
||||
label: 'Book',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
@@ -85,7 +79,6 @@ const importModeOptions = [
|
||||
const SELECT = 'select';
|
||||
const ARTIST = 'artist';
|
||||
const ALBUM = 'album';
|
||||
const ALBUM_RELEASE = 'albumRelease';
|
||||
const QUALITY = 'quality';
|
||||
|
||||
const replaceExistingFilesOptions = {
|
||||
@@ -110,7 +103,6 @@ class InteractiveImportModalContent extends Component {
|
||||
selectModalOpen: null,
|
||||
albumsImported: [],
|
||||
isConfirmImportModalOpen: false,
|
||||
showClearTracks: false,
|
||||
inconsistentAlbumReleases: false
|
||||
};
|
||||
}
|
||||
@@ -118,15 +110,10 @@ class InteractiveImportModalContent extends Component {
|
||||
componentDidUpdate(prevProps) {
|
||||
const selectedIds = this.getSelectedIds();
|
||||
const selectedItems = _.filter(this.props.items, (x) => _.includes(selectedIds, x.id));
|
||||
const selectionHasTracks = _.some(selectedItems, (x) => x.tracks.length);
|
||||
|
||||
if (this.state.showClearTracks !== selectionHasTracks) {
|
||||
this.setState({ showClearTracks: selectionHasTracks });
|
||||
}
|
||||
|
||||
const inconsistent = _(selectedItems)
|
||||
.map((x) => ({ albumId: x.album ? x.album.id : 0, releaseId: x.albumReleaseId }))
|
||||
.groupBy('albumId')
|
||||
.map((x) => ({ bookId: x.album ? x.album.id : 0, releaseId: x.albumReleaseId }))
|
||||
.groupBy('bookId')
|
||||
.mapValues((album) => _(album).groupBy((x) => x.releaseId).values().value().length)
|
||||
.values()
|
||||
.some((x) => x !== undefined && x > 1);
|
||||
@@ -224,7 +211,6 @@ class InteractiveImportModalContent extends Component {
|
||||
selectedIds.forEach((id) => {
|
||||
this.props.updateInteractiveImportItem({
|
||||
id,
|
||||
tracks: [],
|
||||
rejections: []
|
||||
});
|
||||
});
|
||||
@@ -277,7 +263,6 @@ class InteractiveImportModalContent extends Component {
|
||||
selectModalOpen,
|
||||
albumsImported,
|
||||
isConfirmImportModalOpen,
|
||||
showClearTracks,
|
||||
inconsistentAlbumReleases
|
||||
} = this.state;
|
||||
|
||||
@@ -288,7 +273,6 @@ class InteractiveImportModalContent extends Component {
|
||||
const bulkSelectOptions = [
|
||||
{ key: SELECT, value: 'Select...', disabled: true },
|
||||
{ key: ALBUM, value: 'Select Album' },
|
||||
{ key: ALBUM_RELEASE, value: 'Select Album Release' },
|
||||
{ key: QUALITY, value: 'Select Quality' }
|
||||
];
|
||||
|
||||
@@ -450,24 +434,6 @@ class InteractiveImportModalContent extends Component {
|
||||
isDisabled={!selectedIds.length}
|
||||
onChange={this.onSelectModalSelect}
|
||||
/>
|
||||
|
||||
{
|
||||
showClearTracks ? (
|
||||
<Button
|
||||
onPress={this.onClearTrackMappingPress}
|
||||
isDisabled={!selectedIds.length}
|
||||
>
|
||||
Clear Tracks
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
onPress={this.onGetTrackMappingPress}
|
||||
isDisabled={!selectedIds.length}
|
||||
>
|
||||
Map Tracks
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
|
||||
<div className={styles.rightButtons}>
|
||||
@@ -499,14 +465,7 @@ class InteractiveImportModalContent extends Component {
|
||||
<SelectAlbumModal
|
||||
isOpen={selectModalOpen === ALBUM}
|
||||
ids={selectedIds}
|
||||
artistId={selectedItem && selectedItem.artist && selectedItem.artist.id}
|
||||
onModalClose={this.onSelectModalClose}
|
||||
/>
|
||||
|
||||
<SelectAlbumReleaseModal
|
||||
isOpen={selectModalOpen === ALBUM_RELEASE}
|
||||
importIdsByAlbum={_.chain(items).filter((x) => x.album).groupBy((x) => x.album.id).mapValues((x) => x.map((y) => y.id)).value()}
|
||||
albums={_.chain(items).filter((x) => x.album).keyBy((x) => x.album.id).mapValues((x) => ({ matchedReleaseId: x.albumReleaseId, album: x.album })).values().value()}
|
||||
authorId={selectedItem && selectedItem.artist && selectedItem.artist.id}
|
||||
onModalClose={this.onSelectModalClose}
|
||||
/>
|
||||
|
||||
|
||||
+2
-11
@@ -124,8 +124,6 @@ class InteractiveImportModalContentConnector extends Component {
|
||||
const {
|
||||
artist,
|
||||
album,
|
||||
albumReleaseId,
|
||||
tracks,
|
||||
quality,
|
||||
disableReleaseSwitching
|
||||
} = item;
|
||||
@@ -140,11 +138,6 @@ class InteractiveImportModalContentConnector extends Component {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tracks || !tracks.length) {
|
||||
this.setState({ interactiveImportErrorMessage: 'One or more tracks must be chosen for each selected file' });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!quality) {
|
||||
this.setState({ interactiveImportErrorMessage: 'Quality must be chosen for each selected file' });
|
||||
return false;
|
||||
@@ -152,10 +145,8 @@ class InteractiveImportModalContentConnector extends Component {
|
||||
|
||||
files.push({
|
||||
path: item.path,
|
||||
artistId: artist.id,
|
||||
albumId: album.id,
|
||||
albumReleaseId,
|
||||
trackIds: _.map(tracks, 'id'),
|
||||
authorId: artist.id,
|
||||
bookId: album.id,
|
||||
quality,
|
||||
downloadId: this.props.downloadId,
|
||||
disableReleaseSwitching
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import formatBytes from 'Utilities/Number/formatBytes';
|
||||
import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
|
||||
import { icons, kinds, tooltipPositions, sortDirections } from 'Helpers/Props';
|
||||
import { icons, kinds, tooltipPositions } from 'Helpers/Props';
|
||||
import Icon from 'Components/Icon';
|
||||
import TableRow from 'Components/Table/TableRow';
|
||||
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
||||
@@ -13,10 +12,8 @@ import Tooltip from 'Components/Tooltip/Tooltip';
|
||||
import TrackQuality from 'Album/TrackQuality';
|
||||
import SelectArtistModal from 'InteractiveImport/Artist/SelectArtistModal';
|
||||
import SelectAlbumModal from 'InteractiveImport/Album/SelectAlbumModal';
|
||||
import SelectTrackModal from 'InteractiveImport/Track/SelectTrackModal';
|
||||
import SelectQualityModal from 'InteractiveImport/Quality/SelectQualityModal';
|
||||
import InteractiveImportRowCellPlaceholder from './InteractiveImportRowCellPlaceholder';
|
||||
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||||
import styles from './InteractiveImportRow.css';
|
||||
|
||||
class InteractiveImportRow extends Component {
|
||||
@@ -30,7 +27,6 @@ class InteractiveImportRow extends Component {
|
||||
this.state = {
|
||||
isSelectArtistModalOpen: false,
|
||||
isSelectAlbumModalOpen: false,
|
||||
isSelectTrackModalOpen: false,
|
||||
isSelectQualityModalOpen: false
|
||||
};
|
||||
}
|
||||
@@ -40,14 +36,12 @@ class InteractiveImportRow extends Component {
|
||||
id,
|
||||
artist,
|
||||
album,
|
||||
tracks,
|
||||
quality
|
||||
} = this.props;
|
||||
|
||||
if (
|
||||
artist &&
|
||||
album != null &&
|
||||
tracks.length &&
|
||||
quality
|
||||
) {
|
||||
this.props.onSelectedChange({ id, value: true });
|
||||
@@ -59,7 +53,6 @@ class InteractiveImportRow extends Component {
|
||||
id,
|
||||
artist,
|
||||
album,
|
||||
tracks,
|
||||
quality,
|
||||
isSelected,
|
||||
onValidRowChange
|
||||
@@ -68,7 +61,6 @@ class InteractiveImportRow extends Component {
|
||||
if (
|
||||
prevProps.artist === artist &&
|
||||
prevProps.album === album &&
|
||||
!hasDifferentItems(prevProps.tracks, tracks) &&
|
||||
prevProps.quality === quality &&
|
||||
prevProps.isSelected === isSelected
|
||||
) {
|
||||
@@ -78,7 +70,6 @@ class InteractiveImportRow extends Component {
|
||||
const isValid = !!(
|
||||
artist &&
|
||||
album &&
|
||||
tracks.length &&
|
||||
quality
|
||||
);
|
||||
|
||||
@@ -114,10 +105,6 @@ class InteractiveImportRow extends Component {
|
||||
this.setState({ isSelectAlbumModalOpen: true });
|
||||
}
|
||||
|
||||
onSelectTrackPress = () => {
|
||||
this.setState({ isSelectTrackModalOpen: true });
|
||||
}
|
||||
|
||||
onSelectQualityPress = () => {
|
||||
this.setState({ isSelectQualityModalOpen: true });
|
||||
}
|
||||
@@ -132,11 +119,6 @@ class InteractiveImportRow extends Component {
|
||||
this.selectRowAfterChange(changed);
|
||||
}
|
||||
|
||||
onSelectTrackModalClose = (changed) => {
|
||||
this.setState({ isSelectTrackModalOpen: false });
|
||||
this.selectRowAfterChange(changed);
|
||||
}
|
||||
|
||||
onSelectQualityModalClose = (changed) => {
|
||||
this.setState({ isSelectQualityModalOpen: false });
|
||||
this.selectRowAfterChange(changed);
|
||||
@@ -152,22 +134,17 @@ class InteractiveImportRow extends Component {
|
||||
path,
|
||||
artist,
|
||||
album,
|
||||
albumReleaseId,
|
||||
tracks,
|
||||
quality,
|
||||
size,
|
||||
rejections,
|
||||
audioTags,
|
||||
additionalFile,
|
||||
isSelected,
|
||||
isSaving,
|
||||
onSelectedChange
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
isSelectArtistModalOpen,
|
||||
isSelectAlbumModalOpen,
|
||||
isSelectTrackModalOpen,
|
||||
isSelectQualityModalOpen
|
||||
} = this.state;
|
||||
|
||||
@@ -177,15 +154,8 @@ class InteractiveImportRow extends Component {
|
||||
albumTitle = album.disambiguation ? `${album.title} (${album.disambiguation})` : album.title;
|
||||
}
|
||||
|
||||
const sortedTracks = tracks.sort((a, b) => parseInt(a.absoluteTrackNumber) - parseInt(b.absoluteTrackNumber));
|
||||
|
||||
const trackNumbers = sortedTracks.map((track) => `${track.mediumNumber}x${track.trackNumber}`)
|
||||
.join(', ');
|
||||
|
||||
const showArtistPlaceholder = isSelected && !artist;
|
||||
const showAlbumNumberPlaceholder = isSelected && !!artist && !album;
|
||||
const showTrackNumbersPlaceholder = !isSaving && isSelected && !!album && !tracks.length;
|
||||
const showTrackNumbersLoading = isSaving && !tracks.length;
|
||||
const showQualityPlaceholder = isSelected && !quality;
|
||||
|
||||
const pathCellContents = (
|
||||
@@ -239,19 +209,6 @@ class InteractiveImportRow extends Component {
|
||||
}
|
||||
</TableRowCellButton>
|
||||
|
||||
<TableRowCellButton
|
||||
isDisabled={!artist || !album}
|
||||
title={artist && album ? 'Click to change track' : undefined}
|
||||
onPress={this.onSelectTrackPress}
|
||||
>
|
||||
{
|
||||
showTrackNumbersLoading && <LoadingIndicator size={20} className={styles.loading} />
|
||||
}
|
||||
{
|
||||
showTrackNumbersPlaceholder ? <InteractiveImportRowCellPlaceholder /> : trackNumbers
|
||||
}
|
||||
</TableRowCellButton>
|
||||
|
||||
<TableRowCellButton
|
||||
className={styles.quality}
|
||||
title="Click to change quality"
|
||||
@@ -314,24 +271,10 @@ class InteractiveImportRow extends Component {
|
||||
<SelectAlbumModal
|
||||
isOpen={isSelectAlbumModalOpen}
|
||||
ids={[id]}
|
||||
artistId={artist && artist.id}
|
||||
authorId={artist && artist.id}
|
||||
onModalClose={this.onSelectAlbumModalClose}
|
||||
/>
|
||||
|
||||
<SelectTrackModal
|
||||
isOpen={isSelectTrackModalOpen}
|
||||
id={id}
|
||||
artistId={artist && artist.id}
|
||||
albumId={album && album.id}
|
||||
albumReleaseId={albumReleaseId}
|
||||
rejections={rejections}
|
||||
audioTags={audioTags}
|
||||
sortKey='mediumNumber'
|
||||
sortDirection={sortDirections.ASCENDING}
|
||||
filename={path}
|
||||
onModalClose={this.onSelectTrackModalClose}
|
||||
/>
|
||||
|
||||
<SelectQualityModal
|
||||
isOpen={isSelectQualityModalOpen}
|
||||
ids={[id]}
|
||||
@@ -352,8 +295,6 @@ InteractiveImportRow.propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
artist: PropTypes.object,
|
||||
album: PropTypes.object,
|
||||
albumReleaseId: PropTypes.number,
|
||||
tracks: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
quality: PropTypes.object,
|
||||
size: PropTypes.number.isRequired,
|
||||
rejections: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
@@ -365,8 +306,4 @@ InteractiveImportRow.propTypes = {
|
||||
onValidRowChange: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
InteractiveImportRow.defaultProps = {
|
||||
tracks: []
|
||||
};
|
||||
|
||||
export default InteractiveImportRow;
|
||||
|
||||
Reference in New Issue
Block a user