/* eslint max-params: 0 */ import PropTypes from 'prop-types'; import React from 'react'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; import { icons } from 'Helpers/Props'; import dimensions from 'Styles/Variables/dimensions'; import Icon from 'Components/Icon'; import styles from './ArtistIndexOverviewInfo.css'; const infoRowHeight = parseInt(dimensions.artistIndexOverviewInfoRowHeight); function isVisible(name, show, value, sortKey, index) { if (value == null) { return false; } return show || sortKey === name; } function ArtistIndexOverviewInfo(props) { const { height, showQualityProfile, showAdded, showAlbumCount, showPath, showSizeOnDisk, nextAiring, qualityProfile, added, albumCount, path, sizeOnDisk, sortKey, showRelativeDates, shortDateFormat, timeFormat } = props; let albums = '1 album'; if (albumCount === 0) { albums = 'No albums'; } else if (albumCount > 1) { albums = `${albumCount} albums`; } const maxRows = Math.floor(height / (infoRowHeight + 4)); return (
{ !!nextAiring &&
{ getRelativeDate( nextAiring, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true } ) }
} { isVisible('qualityProfileId', showQualityProfile, qualityProfile, sortKey) && maxRows > 1 &&
{qualityProfile.name}
} { isVisible('added', showAdded, added, sortKey) && maxRows > 2 &&
{ getRelativeDate( added, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true } ) }
} { isVisible('albumCount', showAlbumCount, albumCount, sortKey) && maxRows > 3 &&
{albums}
} { isVisible('path', showPath, path, sortKey) && maxRows > 4 &&
{path}
} { isVisible('sizeOnDisk', showSizeOnDisk, sizeOnDisk, sortKey) && maxRows > 5 &&
{formatBytes(sizeOnDisk)}
}
); } ArtistIndexOverviewInfo.propTypes = { height: PropTypes.number.isRequired, showNetwork: PropTypes.bool.isRequired, showQualityProfile: PropTypes.bool.isRequired, showAdded: PropTypes.bool.isRequired, showAlbumCount: PropTypes.bool.isRequired, showPath: PropTypes.bool.isRequired, showSizeOnDisk: PropTypes.bool.isRequired, nextAiring: PropTypes.string, qualityProfile: PropTypes.object.isRequired, previousAiring: PropTypes.string, added: PropTypes.string, albumCount: PropTypes.number.isRequired, path: PropTypes.string.isRequired, sizeOnDisk: PropTypes.number, sortKey: PropTypes.string.isRequired, showRelativeDates: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired }; export default ArtistIndexOverviewInfo;