import PropTypes from 'prop-types'; import React, { Component } from 'react'; import MonitorToggleButton from 'Components/MonitorToggleButton'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; import { kinds, sizes } from 'Helpers/Props'; import TableRow from 'Components/Table/TableRow'; import Label from 'Components/Label'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; import EpisodeSearchCellConnector from 'Episode/EpisodeSearchCellConnector'; import EpisodeTitleLink from 'Episode/EpisodeTitleLink'; import styles from './AlbumRow.css'; function getEpisodeCountKind(monitored, trackFileCount, episodeCount) { if (trackFileCount === episodeCount && episodeCount > 0) { return kinds.SUCCESS; } if (!monitored) { return kinds.WARNING; } return kinds.DANGER; } class AlbumRow extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isDetailsModalOpen: false }; } // // Listeners onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); } onMonitorAlbumPress = (monitored, options) => { this.props.onMonitorAlbumPress(this.props.id, monitored, options); } // // Render render() { const { id, artistId, monitored, statistics, duration, releaseDate, title, isSaving, artistMonitored, path, columns } = this.props; const { trackCount, trackFileCount, totalTrackCount } = statistics; return ( { columns.map((column) => { const { name, isVisible } = column; if (!isVisible) { return null; } if (name === 'monitored') { return ( ); } if (name === 'title') { return ( ); } if (name === 'path') { return ( { path } ); } if (name === 'trackCount') { return ( { statistics.trackCount } ); } if (name === 'duration') { return ( { formatTimeSpan(duration) } ); } if (name === 'releaseDate') { return ( ); } if (name === 'status') { return ( ); } if (name === 'actions') { return ( ); } return null; }) } ); } } AlbumRow.propTypes = { id: PropTypes.number.isRequired, artistId: PropTypes.number.isRequired, monitored: PropTypes.bool.isRequired, releaseDate: PropTypes.string.isRequired, duration: PropTypes.number.isRequired, title: PropTypes.string.isRequired, isSaving: PropTypes.bool, unverifiedSceneNumbering: PropTypes.bool, artistMonitored: PropTypes.bool.isRequired, statistics: PropTypes.object.isRequired, path: PropTypes.string, mediaInfo: PropTypes.object, alternateTitles: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, onMonitorAlbumPress: PropTypes.func.isRequired }; AlbumRow.defaultProps = { statistics: { trackCount: 0, trackFileCount: 0 } }; export default AlbumRow;