import PropTypes from 'prop-types'; import React, { Component } from 'react'; import TextTruncate from 'react-text-truncate'; import { icons } from 'Helpers/Props'; import dimensions from 'Styles/Variables/dimensions'; import fonts from 'Styles/Variables/fonts'; import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import ArtistPoster from 'Artist/ArtistPoster'; import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; import ArtistIndexOverviewInfo from './ArtistIndexOverviewInfo'; import styles from './ArtistIndexOverview.css'; const columnPadding = parseInt(dimensions.artistIndexColumnPadding); const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); const defaultFontSize = parseInt(fonts.defaultFontSize); const lineHeight = parseFloat(fonts.lineHeight); // Hardcoded height beased on line-height of 32 + bottom margin of 10. // Less side-effecty than using react-measure. const titleRowHeight = 42; function getContentHeight(rowHeight, isSmallScreen) { const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; return rowHeight - padding; } class ArtistIndexOverview extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isEditArtistModalOpen: false, isDeleteArtistModalOpen: false }; } // // Listeners onEditArtistPress = () => { this.setState({ isEditArtistModalOpen: true }); } onEditArtistModalClose = () => { this.setState({ isEditArtistModalOpen: false }); } onDeleteArtistPress = () => { this.setState({ isEditArtistModalOpen: false, isDeleteArtistModalOpen: true }); } onDeleteArtistModalClose = () => { this.setState({ isDeleteArtistModalOpen: false }); } // // Render render() { const { id, artistName, overview, monitored, status, titleSlug, nextAiring, statistics, images, posterWidth, posterHeight, qualityProfile, overviewOptions, showSearchAction, showRelativeDates, shortDateFormat, longDateFormat, timeFormat, rowHeight, isSmallScreen, isRefreshingArtist, isSearchingArtist, onRefreshArtistPress, onSearchPress, ...otherProps } = this.props; const { albumCount, sizeOnDisk, trackCount, trackFileCount, totalTrackCount } = statistics; const { isEditArtistModalOpen, isDeleteArtistModalOpen } = this.state; const link = `/author/${titleSlug}`; const elementStyle = { width: `${posterWidth}px`, height: `${posterHeight}px` }; const contentHeight = getContentHeight(rowHeight, isSmallScreen); const overviewHeight = contentHeight - titleRowHeight; return (
{ status === 'ended' &&
}
{artistName}
{ showSearchAction && }
); } } ArtistIndexOverview.propTypes = { id: PropTypes.number.isRequired, artistName: PropTypes.string.isRequired, overview: PropTypes.string.isRequired, monitored: PropTypes.bool.isRequired, status: PropTypes.string.isRequired, titleSlug: PropTypes.string.isRequired, nextAiring: PropTypes.string, statistics: PropTypes.object.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, posterWidth: PropTypes.number.isRequired, posterHeight: PropTypes.number.isRequired, rowHeight: PropTypes.number.isRequired, qualityProfile: PropTypes.object.isRequired, overviewOptions: PropTypes.object.isRequired, showSearchAction: PropTypes.bool.isRequired, showRelativeDates: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, longDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, isSmallScreen: PropTypes.bool.isRequired, isRefreshingArtist: PropTypes.bool.isRequired, isSearchingArtist: PropTypes.bool.isRequired, onRefreshArtistPress: PropTypes.func.isRequired, onSearchPress: PropTypes.func.isRequired }; ArtistIndexOverview.defaultProps = { statistics: { albumCount: 0, trackCount: 0, trackFileCount: 0, totalTrackCount: 0 } }; export default ArtistIndexOverview;