import PropTypes from 'prop-types'; import React, { Component } from 'react'; import AlbumFormats from 'Album/AlbumFormats'; import EpisodeStatusConnector from 'Album/EpisodeStatusConnector'; import IndexerFlags from 'Album/IndexerFlags'; import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; import Tooltip from 'Components/Tooltip/Tooltip'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import MediaInfoConnector from 'TrackFile/MediaInfoConnector'; import * as mediaInfoTypes from 'TrackFile/mediaInfoTypes'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; import formatBytes from 'Utilities/Number/formatBytes'; import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; import translate from 'Utilities/String/translate'; import TrackActionsCell from './TrackActionsCell'; import styles from './TrackRow.css'; class TrackRow extends Component { // // Render render() { const { id, albumId, mediumNumber, trackFileId, absoluteTrackNumber, title, duration, trackFilePath, trackFileSize, customFormats, customFormatScore, indexerFlags, columns, deleteTrackFile } = this.props; return ( { columns.map((column) => { const { name, isVisible } = column; if (!isVisible) { return null; } if (name === 'medium') { return ( {mediumNumber} ); } if (name === 'absoluteTrackNumber') { return ( {absoluteTrackNumber} ); } if (name === 'title') { return ( {title} ); } if (name === 'path') { return ( { trackFilePath } ); } if (name === 'duration') { return ( { formatTimeSpan(duration) } ); } if (name === 'audioInfo') { return ( ); } if (name === 'customFormats') { return ( ); } if (name === 'customFormatScore') { return ( } position={tooltipPositions.LEFT} /> ); } if (name === 'indexerFlags') { return ( {indexerFlags ? ( } title={translate('IndexerFlags')} body={} position={tooltipPositions.LEFT} /> ) : null} ); } if (name === 'size') { return ( {!!trackFileSize && formatBytes(trackFileSize)} ); } if (name === 'status') { return ( ); } if (name === 'actions') { return ( ); } return null; }) } ); } } TrackRow.propTypes = { deleteTrackFile: PropTypes.func.isRequired, id: PropTypes.number.isRequired, albumId: PropTypes.number.isRequired, trackFileId: PropTypes.number, mediumNumber: PropTypes.number.isRequired, trackNumber: PropTypes.string.isRequired, absoluteTrackNumber: PropTypes.number, title: PropTypes.string.isRequired, duration: PropTypes.number.isRequired, isSaving: PropTypes.bool, trackFilePath: PropTypes.string, trackFileSize: PropTypes.number, customFormats: PropTypes.arrayOf(PropTypes.object), customFormatScore: PropTypes.number.isRequired, indexerFlags: PropTypes.number.isRequired, mediaInfo: PropTypes.object, columns: PropTypes.arrayOf(PropTypes.object).isRequired }; TrackRow.defaultProps = { customFormats: [], indexerFlags: 0 }; export default TrackRow;