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 AlbumSearchCellConnector from 'Album/AlbumSearchCellConnector'; import AlbumTitleDetailLink from 'Album/AlbumTitleDetailLink'; import styles from './AlbumRow.css'; function getTrackCountKind(monitored, trackFileCount, trackCount) { if (trackFileCount === trackCount && trackCount > 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, isEditAlbumModalOpen: false }; } // // Listeners onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); } onEditAlbumPress = () => { this.setState({ isEditAlbumModalOpen: true }); } onEditAlbumModalClose = () => { this.setState({ isEditAlbumModalOpen: false }); } onMonitorAlbumPress = (monitored, options) => { this.props.onMonitorAlbumPress(this.props.id, monitored, options); } // // Render render() { const { id, artistId, monitored, statistics, duration, releaseDate, mediumCount, secondaryTypes, title, isSaving, artistMonitored, foreignAlbumId, 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 === 'mediumCount') { return ( { mediumCount } ); } if (name === 'secondaryTypes') { return ( { secondaryTypes } ); } if (name === 'trackCount') { return ( { statistics.totalTrackCount } ); } 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, mediumCount: PropTypes.number.isRequired, duration: PropTypes.number.isRequired, title: PropTypes.string.isRequired, secondaryTypes: PropTypes.arrayOf(PropTypes.string).isRequired, foreignAlbumId: PropTypes.string.isRequired, isSaving: PropTypes.bool, unverifiedSceneNumbering: PropTypes.bool, artistMonitored: PropTypes.bool.isRequired, statistics: PropTypes.object.isRequired, mediaInfo: PropTypes.object, columns: PropTypes.arrayOf(PropTypes.object).isRequired, onMonitorAlbumPress: PropTypes.func.isRequired }; AlbumRow.defaultProps = { statistics: { trackCount: 0, trackFileCount: 0 } }; export default AlbumRow;