/* 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, showMonitored, showQualityProfile, showAdded, showAlbumCount, showPath, showSizeOnDisk, monitored, nextAiring, qualityProfile, added, statistics, path, sortKey, showRelativeDates, shortDateFormat, timeFormat } = props; const { albumCount, sizeOnDisk } = statistics; let albums = '1 album'; if (albumCount === 0) { albums = 'No albums'; } else if (albumCount > 1) { albums = `${albumCount} albums`; } const maxRows = Math.floor(height / (infoRowHeight + 4)); const monitoredText = monitored ? 'Monitored' : 'Unmonitored'; return (
{ !!nextAiring &&
{ getRelativeDate( nextAiring, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true } ) }
} { isVisible('monitored', showMonitored, monitored, sortKey) && maxRows > 1 &&
{monitoredText}
} { isVisible('qualityProfileId', showQualityProfile, qualityProfile, sortKey) && maxRows > 2 &&
{qualityProfile.name}
} { isVisible('added', showAdded, added, sortKey) && maxRows > 3 &&
{ getRelativeDate( added, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true } ) }
} { isVisible('albumCount', showAlbumCount, albumCount, sortKey) && maxRows > 4 &&
{albums}
} { isVisible('path', showPath, path, sortKey) && maxRows > 5 &&
{path}
} { isVisible('sizeOnDisk', showSizeOnDisk, sizeOnDisk, sortKey) && maxRows > 6 &&
{formatBytes(sizeOnDisk)}
}
); } ArtistIndexOverviewInfo.propTypes = { height: PropTypes.number.isRequired, showNetwork: PropTypes.bool.isRequired, showMonitored: PropTypes.bool.isRequired, showQualityProfile: PropTypes.bool.isRequired, showAdded: PropTypes.bool.isRequired, showAlbumCount: PropTypes.bool.isRequired, showPath: PropTypes.bool.isRequired, showSizeOnDisk: PropTypes.bool.isRequired, monitored: PropTypes.bool.isRequired, nextAiring: PropTypes.string, qualityProfile: PropTypes.object.isRequired, previousAiring: PropTypes.string, added: PropTypes.string, statistics: PropTypes.object.isRequired, path: PropTypes.string.isRequired, sortKey: PropTypes.string.isRequired, showRelativeDates: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired }; export default ArtistIndexOverviewInfo;