import PropTypes from 'prop-types'; import React, { Component } from 'react'; import IconButton from 'Components/Link/IconButton'; import { icons, kinds } from 'Helpers/Props'; import TableRow from 'Components/Table/TableRow'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRowCellButton from 'Components/Table/Cells/TableRowCellButton'; import MovieQuality from 'Movie/MovieQuality'; import MovieLanguage from 'Movie/MovieLanguage'; import ConfirmModal from 'Components/Modal/ConfirmModal'; import SelectQualityModal from 'MovieFile/Quality/SelectQualityModal'; import SelectLanguageModal from 'MovieFile/Language/SelectLanguageModal'; import * as mediaInfoTypes from 'MovieFile/mediaInfoTypes'; import MediaInfoConnector from 'MovieFile/MediaInfoConnector'; import MovieFileRowCellPlaceholder from './MovieFileRowCellPlaceholder'; import styles from './MovieFileEditorRow.css'; class MovieFileEditorRow extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isSelectQualityModalOpen: false, isSelectLanguageModalOpen: false, isConfirmDeleteModalOpen: false }; } // // Listeners onSelectQualityPress = () => { this.setState({ isSelectQualityModalOpen: true }); } onSelectLanguagePress = () => { this.setState({ isSelectLanguageModalOpen: true }); } onSelectQualityModalClose = () => { this.setState({ isSelectQualityModalOpen: false }); } onSelectLanguageModalClose = () => { this.setState({ isSelectLanguageModalOpen: false }); } onDeletePress = () => { this.setState({ isConfirmDeleteModalOpen: true }); } onConfirmDelete = () => { this.setState({ isConfirmDeleteModalOpen: false }); this.props.onDeletePress(this.props.id); } onConfirmDeleteModalClose = () => { this.setState({ isConfirmDeleteModalOpen: false }); } // // Render render() { const { id, relativePath, quality, languages } = this.props; const { isSelectQualityModalOpen, isSelectLanguageModalOpen, isConfirmDeleteModalOpen } = this.state; const showQualityPlaceholder = !quality; const showLanguagePlaceholder = !languages; return ( {relativePath} { showLanguagePlaceholder && } { !showLanguagePlaceholder && !!languages && } { showQualityPlaceholder && } { !showQualityPlaceholder && !!quality && } 1 : false} real={quality ? quality.revision.real > 0 : false} onModalClose={this.onSelectQualityModalClose} /> ); } } MovieFileEditorRow.propTypes = { id: PropTypes.number.isRequired, size: PropTypes.number.isRequired, relativePath: PropTypes.string.isRequired, quality: PropTypes.object.isRequired, languages: PropTypes.arrayOf(PropTypes.object).isRequired, mediaInfo: PropTypes.object.isRequired, onDeletePress: PropTypes.func.isRequired }; export default MovieFileEditorRow;