import PropTypes from 'prop-types'; import React, { Component } from 'react'; import classNames from 'classnames'; import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; import formatBytes from 'Utilities/Number/formatBytes'; import { icons } from 'Helpers/Props'; import HeartRating from 'Components/HeartRating'; import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import ProgressBar from 'Components/ProgressBar'; import TagListConnector from 'Components/TagListConnector'; import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; import ArtistNameLink from 'Artist/ArtistNameLink'; import AlbumTitleLink from 'Album/AlbumTitleLink'; import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; import ArtistBanner from 'Artist/ArtistBanner'; import hasGrowableColumns from './hasGrowableColumns'; import ArtistStatusCell from './ArtistStatusCell'; import styles from './ArtistIndexRow.css'; class ArtistIndexRow extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { hasBannerError: false, isEditArtistModalOpen: false, isDeleteArtistModalOpen: false }; } onEditArtistPress = () => { this.setState({ isEditArtistModalOpen: true }); } onEditArtistModalClose = () => { this.setState({ isEditArtistModalOpen: false }); } onDeleteArtistPress = () => { this.setState({ isEditArtistModalOpen: false, isDeleteArtistModalOpen: true }); } onDeleteArtistModalClose = () => { this.setState({ isDeleteArtistModalOpen: false }); } onUseSceneNumberingChange = () => { // Mock handler to satisfy `onChange` being required for `CheckInput`. // } onBannerLoad = () => { if (this.state.hasBannerError) { this.setState({ hasBannerError: false }); } } onBannerLoadError = () => { if (!this.state.hasBannerError) { this.setState({ hasBannerError: true }); } } // // Render render() { const { id, monitored, status, artistName, titleSlug, artistType, qualityProfile, metadataProfile, nextAlbum, lastAlbum, added, statistics, genres, ratings, path, tags, images, showBanners, showSearchAction, columns, isRefreshingArtist, isSearchingArtist, onRefreshArtistPress, onSearchPress } = this.props; const { albumCount, trackCount, trackFileCount, totalTrackCount, sizeOnDisk } = statistics; const { hasBannerError, isEditArtistModalOpen, isDeleteArtistModalOpen } = this.state; return ( <> { columns.map((column) => { const { name, isVisible } = column; if (!isVisible) { return null; } if (name === 'status') { return ( ); } if (name === 'sortName') { return ( { showBanners ? { hasBannerError &&
{artistName}
} : }
); } if (name === 'artistType') { return ( {artistType} ); } if (name === 'qualityProfileId') { return ( {qualityProfile.name} ); } if (name === 'metadataProfileId') { return ( {metadataProfile.name} ); } if (name === 'nextAlbum') { if (nextAlbum) { return ( ); } return ( None ); } if (name === 'lastAlbum') { if (lastAlbum) { return ( ); } return ( None ); } if (name === 'added') { return ( ); } if (name === 'albumCount') { return ( {albumCount} ); } if (name === 'trackProgress') { const progress = trackCount ? trackFileCount / trackCount * 100 : 100; return ( ); } if (name === 'trackCount') { return ( {totalTrackCount} ); } if (name === 'path') { return ( {path} ); } if (name === 'sizeOnDisk') { return ( {formatBytes(sizeOnDisk)} ); } if (name === 'genres') { const joinedGenres = genres.join(', '); return ( {joinedGenres} ); } if (name === 'ratings') { return ( ); } if (name === 'tags') { return ( ); } if (name === 'actions') { return ( { showSearchAction && } ); } return null; }) } ); } } ArtistIndexRow.propTypes = { id: PropTypes.number.isRequired, monitored: PropTypes.bool.isRequired, status: PropTypes.string.isRequired, artistName: PropTypes.string.isRequired, titleSlug: PropTypes.string.isRequired, artistType: PropTypes.string, qualityProfile: PropTypes.object.isRequired, metadataProfile: PropTypes.object.isRequired, nextAlbum: PropTypes.object, lastAlbum: PropTypes.object, added: PropTypes.string, statistics: PropTypes.object.isRequired, latestAlbum: PropTypes.object, path: PropTypes.string.isRequired, genres: PropTypes.arrayOf(PropTypes.string).isRequired, ratings: PropTypes.object.isRequired, tags: PropTypes.arrayOf(PropTypes.number).isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, showBanners: PropTypes.bool.isRequired, showSearchAction: PropTypes.bool.isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, isRefreshingArtist: PropTypes.bool.isRequired, isSearchingArtist: PropTypes.bool.isRequired, onRefreshArtistPress: PropTypes.func.isRequired, onSearchPress: PropTypes.func.isRequired }; ArtistIndexRow.defaultProps = { statistics: { albumCount: 0, trackCount: 0, trackFileCount: 0, totalTrackCount: 0 }, genres: [], tags: [] }; export default ArtistIndexRow;