import PropTypes from 'prop-types'; import React, { Component } from 'react'; import TextTruncate from 'react-text-truncate'; import Label from 'Components/Label'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import { icons, kinds } from 'Helpers/Props'; import CategoryLabel from 'Search/Table/CategoryLabel'; import Peers from 'Search/Table/Peers'; import ProtocolLabel from 'Search/Table/ProtocolLabel'; import dimensions from 'Styles/Variables/dimensions'; import formatAge from 'Utilities/Number/formatAge'; import formatBytes from 'Utilities/Number/formatBytes'; import translate from 'Utilities/String/translate'; import styles from './SearchIndexOverview.css'; const columnPadding = parseInt(dimensions.movieIndexColumnPadding); const columnPaddingSmallScreen = parseInt(dimensions.movieIndexColumnPaddingSmallScreen); function getContentHeight(rowHeight, isSmallScreen) { const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; return rowHeight - padding; } function getDownloadIcon(isGrabbing, isGrabbed, grabError) { if (isGrabbing) { return icons.SPINNER; } else if (isGrabbed) { return icons.DOWNLOADING; } else if (grabError) { return icons.DOWNLOADING; } return icons.DOWNLOAD; } function getDownloadTooltip(isGrabbing, isGrabbed, grabError) { if (isGrabbing) { return ''; } else if (isGrabbed) { return translate('AddedToDownloadClient'); } else if (grabError) { return grabError; } return translate('AddToDownloadClient'); } class SearchIndexOverview extends Component { // // Listeners onGrabPress = () => { const { guid, indexerId, onGrabPress } = this.props; onGrabPress({ guid, indexerId }); }; // // Render render() { const { title, protocol, downloadUrl, categories, seeders, leechers, size, age, ageHours, ageMinutes, indexer, rowHeight, isSmallScreen, isGrabbed, isGrabbing, grabError } = this.props; const contentHeight = getContentHeight(rowHeight, isSmallScreen); return (