import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { icons, kinds } from 'Helpers/Props'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import ProgressBar from 'Components/ProgressBar'; import TableRow from 'Components/Table/TableRow'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; import ProtocolLabel from 'Activity/Queue/ProtocolLabel'; import EpisodeTitleLink from 'Episode/EpisodeTitleLink'; import EpisodeQuality from 'Episode/EpisodeQuality'; import SeasonEpisodeNumber from 'Episode/SeasonEpisodeNumber'; import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal'; import ArtistNameLink from 'Artist/ArtistNameLink'; import QueueStatusCell from './QueueStatusCell'; import TimeleftCell from './TimeleftCell'; import RemoveQueueItemModal from './RemoveQueueItemModal'; import styles from './QueueRow.css'; class QueueRow extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isRemoveQueueItemModalOpen: false, isInteractiveImportModalOpen: false }; } // // Listeners onRemoveQueueItemPress = () => { this.setState({ isRemoveQueueItemModalOpen: true }); } onRemoveQueueItemModalConfirmed = (blacklist) => { this.props.onRemoveQueueItemPress(blacklist); this.setState({ isRemoveQueueItemModalOpen: false }); } onRemoveQueueItemModalClose = () => { this.setState({ isRemoveQueueItemModalOpen: false }); } onInteractiveImportPress = () => { this.setState({ isInteractiveImportModalOpen: true }); } onInteractiveImportModalClose = () => { this.setState({ isInteractiveImportModalOpen: false }); } // // Render render() { const { id, downloadId, title, status, trackedDownloadStatus, statusMessages, errorMessage, series, episode, quality, protocol, indexer, downloadClient, estimatedCompletionTime, timeleft, size, sizeleft, showRelativeDates, shortDateFormat, timeFormat, isGrabbing, grabError, isRemoving, isSelected, columns, onSelectedChange, onGrabPress } = this.props; const { isRemoveQueueItemModalOpen, isInteractiveImportModalOpen } = this.state; const progress = 100 - (sizeleft / size * 100); const showInteractiveImport = status === 'Completed' && trackedDownloadStatus === 'Warning'; const isPending = status === 'Delay' || status === 'DownloadClientUnavailable'; return ( { columns.map((column) => { const { name, isVisible } = column; if (!isVisible) { return null; } if (name === 'status') { return ( ); } if (name === 'series.sortName') { return ( ); } if (name === 'series') { return ( ); } if (name === 'episodeTitle') { return ( ); } if (name === 'quality') { return ( ); } if (name === 'protocol') { return ( ); } if (name === 'indexer') { return ( {indexer} ); } if (name === 'downloadClient') { return ( {downloadClient} ); } if (name === 'estimatedCompletionTime') { return ( ); } if (name === 'progress') { return ( { !!progress && } ); } if (name === 'actions') { return ( { showInteractiveImport && } { isPending && } ); } return null; }) } ); } } QueueRow.propTypes = { id: PropTypes.number.isRequired, downloadId: PropTypes.string, title: PropTypes.string.isRequired, status: PropTypes.string.isRequired, trackedDownloadStatus: PropTypes.string, statusMessages: PropTypes.arrayOf(PropTypes.object), errorMessage: PropTypes.string, series: PropTypes.object.isRequired, episode: PropTypes.object.isRequired, quality: PropTypes.object.isRequired, protocol: PropTypes.string.isRequired, indexer: PropTypes.string, downloadClient: PropTypes.string, estimatedCompletionTime: PropTypes.string, timeleft: PropTypes.string, size: PropTypes.number, sizeleft: PropTypes.number, showRelativeDates: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, isGrabbing: PropTypes.bool.isRequired, grabError: PropTypes.object, isRemoving: PropTypes.bool.isRequired, isSelected: PropTypes.bool, columns: PropTypes.arrayOf(PropTypes.object).isRequired, onSelectedChange: PropTypes.func.isRequired, onGrabPress: PropTypes.func.isRequired, onRemoveQueueItemPress: PropTypes.func.isRequired }; QueueRow.defaultProps = { isGrabbing: false, isRemoving: false }; export default QueueRow;