|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { icons } from 'Helpers/Props';
|
|
|
|
import IconButton from 'Components/Link/IconButton';
|
|
|
|
import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector';
|
|
|
|
import TableRow from 'Components/Table/TableRow';
|
|
|
|
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
|
|
|
import EpisodeLanguage from 'Album/EpisodeLanguage';
|
|
|
|
import EpisodeQuality from 'Album/EpisodeQuality';
|
|
|
|
import ArtistNameLink from 'Artist/ArtistNameLink';
|
|
|
|
import BlacklistDetailsModal from './BlacklistDetailsModal';
|
|
|
|
import styles from './BlacklistRow.css';
|
|
|
|
|
|
|
|
class BlacklistRow extends Component {
|
|
|
|
|
|
|
|
//
|
|
|
|
// Lifecycle
|
|
|
|
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
isDetailsModalOpen: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Listeners
|
|
|
|
|
|
|
|
onDetailsPress = () => {
|
|
|
|
this.setState({ isDetailsModalOpen: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
onDetailsModalClose = () => {
|
|
|
|
this.setState({ isDetailsModalOpen: false });
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Render
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
artist,
|
|
|
|
sourceTitle,
|
|
|
|
language,
|
|
|
|
quality,
|
|
|
|
date,
|
|
|
|
protocol,
|
|
|
|
indexer,
|
|
|
|
message,
|
|
|
|
columns
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TableRow>
|
|
|
|
{
|
|
|
|
columns.map((column) => {
|
|
|
|
const {
|
|
|
|
name,
|
|
|
|
isVisible
|
|
|
|
} = column;
|
|
|
|
|
|
|
|
if (!isVisible) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'artist.sortName') {
|
|
|
|
return (
|
|
|
|
<TableRowCell key={name}>
|
|
|
|
<ArtistNameLink
|
|
|
|
foreignArtistId={artist.foreignArtistId}
|
|
|
|
artistName={artist.artistName}
|
|
|
|
/>
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'sourceTitle') {
|
|
|
|
return (
|
|
|
|
<TableRowCell key={name}>
|
|
|
|
{sourceTitle}
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'language') {
|
|
|
|
return (
|
|
|
|
<TableRowCell
|
|
|
|
key={name}
|
|
|
|
className={styles.language}
|
|
|
|
>
|
|
|
|
<EpisodeLanguage
|
|
|
|
language={language}
|
|
|
|
/>
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'quality') {
|
|
|
|
return (
|
|
|
|
<TableRowCell
|
|
|
|
key={name}
|
|
|
|
className={styles.quality}
|
|
|
|
>
|
|
|
|
<EpisodeQuality
|
|
|
|
quality={quality}
|
|
|
|
/>
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'date') {
|
|
|
|
return (
|
|
|
|
<RelativeDateCellConnector
|
|
|
|
key={name}
|
|
|
|
date={date}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'indexer') {
|
|
|
|
return (
|
|
|
|
<TableRowCell
|
|
|
|
key={name}
|
|
|
|
className={styles.indexer}
|
|
|
|
>
|
|
|
|
{indexer}
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name === 'details') {
|
|
|
|
return (
|
|
|
|
<TableRowCell
|
|
|
|
key={name}
|
|
|
|
className={styles.details}
|
|
|
|
>
|
|
|
|
<IconButton
|
|
|
|
name={icons.INFO}
|
|
|
|
onPress={this.onDetailsPress}
|
|
|
|
/>
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
<BlacklistDetailsModal
|
|
|
|
isOpen={this.state.isDetailsModalOpen}
|
|
|
|
sourceTitle={sourceTitle}
|
|
|
|
protocol={protocol}
|
|
|
|
indexer={indexer}
|
|
|
|
message={message}
|
|
|
|
onModalClose={this.onDetailsModalClose}
|
|
|
|
/>
|
|
|
|
</TableRow>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BlacklistRow.propTypes = {
|
|
|
|
id: PropTypes.number.isRequired,
|
|
|
|
artist: PropTypes.object.isRequired,
|
|
|
|
sourceTitle: PropTypes.string.isRequired,
|
|
|
|
language: PropTypes.object.isRequired,
|
|
|
|
quality: PropTypes.object.isRequired,
|
|
|
|
date: PropTypes.string.isRequired,
|
|
|
|
protocol: PropTypes.string.isRequired,
|
|
|
|
indexer: PropTypes.string,
|
|
|
|
message: PropTypes.string,
|
|
|
|
columns: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BlacklistRow;
|