import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { icons } from 'Helpers/Props'; import IconButton from 'Components/Link/IconButton'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; import TableRow from 'Components/Table/TableRow'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import AlbumTitleLink from 'Album/AlbumTitleLink'; import EpisodeLanguage from 'Album/EpisodeLanguage'; import EpisodeQuality from 'Album/EpisodeQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; import HistoryEventTypeCell from './HistoryEventTypeCell'; import HistoryDetailsModal from './Details/HistoryDetailsModal'; import styles from './HistoryRow.css'; class HistoryRow extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isDetailsModalOpen: false }; } componentDidUpdate(prevProps) { if ( prevProps.isMarkingAsFailed && !this.props.isMarkingAsFailed && !this.props.markAsFailedError ) { this.setState({ isDetailsModalOpen: false }); } } // // Listeners onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); } // // Render render() { const { artist, album, track, language, languageCutoffNotMet, quality, qualityCutoffNotMet, eventType, sourceTitle, date, data, isMarkingAsFailed, columns, shortDateFormat, timeFormat, onMarkAsFailedPress } = this.props; if (!album) { return null; } return ( { columns.map((column) => { const { name, isVisible } = column; if (!isVisible) { return null; } if (name === 'eventType') { return ( ); } if (name === 'artist.sortName') { return ( ); } if (name === 'albumTitle') { return ( ); } if (name === 'trackTitle') { return ( {track.title} ); } if (name === 'language') { return ( ); } if (name === 'quality') { return ( ); } if (name === 'date') { return ( ); } if (name === 'downloadClient') { return ( {data.downloadClient} ); } if (name === 'indexer') { return ( {data.indexer} ); } if (name === 'releaseGroup') { return ( {data.releaseGroup} ); } if (name === 'details') { return ( ); } return null; }) } ); } } HistoryRow.propTypes = { albumId: PropTypes.number, artist: PropTypes.object.isRequired, album: PropTypes.object, track: PropTypes.object, language: PropTypes.object.isRequired, languageCutoffNotMet: PropTypes.bool.isRequired, quality: PropTypes.object.isRequired, qualityCutoffNotMet: PropTypes.bool.isRequired, eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, date: PropTypes.string.isRequired, data: PropTypes.object.isRequired, isMarkingAsFailed: PropTypes.bool, markAsFailedError: PropTypes.object, columns: PropTypes.arrayOf(PropTypes.object).isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, onMarkAsFailedPress: PropTypes.func.isRequired }; HistoryRow.defaultProps = { track: { title: '' } }; export default HistoryRow;