import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { icons } from 'Helpers/Props'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; import DescriptionListItemTitle from 'Components/DescriptionList/DescriptionListItemTitle'; import DescriptionListItemDescription from 'Components/DescriptionList/DescriptionListItemDescription'; import styles from './FileDetails.css'; class FileDetails extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isExpanded: props.isExpanded }; } // // Listeners onExpandPress = () => { const { isExpanded } = this.state; this.setState({ isExpanded: !isExpanded }); } // // Render renderRejections() { const { rejections } = this.props; return ( Rejections { _.map(rejections, (item, key) => { return ( {item.reason} ); }) } ); } render() { const { filename, audioTags, rejections } = this.props; const { isExpanded } = this.state; return (
{filename}
{ isExpanded &&
{ audioTags.title !== undefined && } { audioTags.trackNumbers[0] > 0 && } { audioTags.discNumber > 0 && } { audioTags.discCount > 0 && } { audioTags.albumTitle !== undefined && } { audioTags.artistTitle !== undefined && } { audioTags.country !== undefined && } { audioTags.year > 0 && } { audioTags.label !== undefined && } { audioTags.catalogNumber !== undefined && } { audioTags.disambiguation !== undefined && } { audioTags.duration !== undefined && } { audioTags.artistMBId !== undefined && } { audioTags.albumMBId !== undefined && } { audioTags.releaseMBId !== undefined && } { audioTags.recordingMBId !== undefined && } { audioTags.trackMBId !== undefined && } { rejections.length > 0 && this.renderRejections() }
}
); } } FileDetails.propTypes = { audioTags: PropTypes.object.isRequired, filename: PropTypes.string.isRequired, rejections: PropTypes.arrayOf(PropTypes.object).isRequired, isExpanded: PropTypes.bool }; export default FileDetails;