mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 22:07:32 -04:00
* History Added * History Cleanup * History Mark Failed Fix * History Lint Fix * Search Tab Initial * Interactive Search Cleanup * Files Tab + Small Backend change to MovieFile api * Reverse Movie History Items * Grabbed files are not grabbable again. * Partial movie title outline + Search not updating fix * Lint Fix + InteractiveSearch refactor * Rename movieLanguage.js to MovieLanguage.js * Fixes for qstick's comments * Rename language selector to allow for const languages * Qstick comment changes. * Activity Tabs - Language Column fixed * Movie Details - MoveStatusLabel fixed * Spaces + Lower Case added * fixed DownloadAllowed * Added padding to history and file tables * Fix class => className * Updated search to not refresh unless switching movie * lint fix * File Tab Converted to Inline Editting * FIles tab fix + Alt Titles tab implemented * lint fix * Cleanup via qstick request
294 lines
7.4 KiB
JavaScript
294 lines
7.4 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import formatBytes from 'Utilities/Number/formatBytes';
|
|
import { icons, kinds, tooltipPositions } from 'Helpers/Props';
|
|
import Icon from 'Components/Icon';
|
|
import TableRow from 'Components/Table/TableRow';
|
|
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
|
import TableRowCellButton from 'Components/Table/Cells/TableRowCellButton';
|
|
import TableSelectCell from 'Components/Table/Cells/TableSelectCell';
|
|
import Popover from 'Components/Tooltip/Popover';
|
|
import MovieQuality from 'Movie/MovieQuality';
|
|
import MovieLanguage from 'Movie/MovieLanguage';
|
|
import SelectMovieModal from 'InteractiveImport/Movie/SelectMovieModal';
|
|
import SelectQualityModal from 'InteractiveImport/Quality/SelectQualityModal';
|
|
import SelectLanguageModal from 'InteractiveImport/Language/SelectLanguageModal';
|
|
import InteractiveImportRowCellPlaceholder from './InteractiveImportRowCellPlaceholder';
|
|
import styles from './InteractiveImportRow.css';
|
|
|
|
class InteractiveImportRow extends Component {
|
|
|
|
//
|
|
// Lifecycle
|
|
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
|
|
this.state = {
|
|
isSelectMovieModalOpen: false,
|
|
isSelectQualityModalOpen: false,
|
|
isSelectLanguageModalOpen: false
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
const {
|
|
id,
|
|
movie,
|
|
quality,
|
|
language
|
|
} = this.props;
|
|
|
|
if (
|
|
movie &&
|
|
quality &&
|
|
language
|
|
) {
|
|
this.props.onSelectedChange({ id, value: true });
|
|
}
|
|
}
|
|
|
|
componentDidUpdate(prevProps) {
|
|
const {
|
|
id,
|
|
movie,
|
|
quality,
|
|
language,
|
|
isSelected,
|
|
onValidRowChange
|
|
} = this.props;
|
|
|
|
if (
|
|
prevProps.movie === movie &&
|
|
prevProps.quality === quality &&
|
|
prevProps.language === language &&
|
|
prevProps.isSelected === isSelected
|
|
) {
|
|
return;
|
|
}
|
|
|
|
const isValid = !!(
|
|
movie &&
|
|
quality &&
|
|
language
|
|
);
|
|
|
|
if (isSelected && !isValid) {
|
|
onValidRowChange(id, false);
|
|
} else {
|
|
onValidRowChange(id, true);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Control
|
|
|
|
selectRowAfterChange = (value) => {
|
|
const {
|
|
id,
|
|
isSelected
|
|
} = this.props;
|
|
|
|
if (!isSelected && value === true) {
|
|
this.props.onSelectedChange({ id, value });
|
|
}
|
|
}
|
|
|
|
//
|
|
// Listeners
|
|
|
|
onSelectMoviePress = () => {
|
|
this.setState({ isSelectMovieModalOpen: true });
|
|
}
|
|
|
|
onSelectQualityPress = () => {
|
|
this.setState({ isSelectQualityModalOpen: true });
|
|
}
|
|
|
|
onSelectLanguagePress = () => {
|
|
this.setState({ isSelectLanguageModalOpen: true });
|
|
}
|
|
|
|
onSelectMovieModalClose = (changed) => {
|
|
this.setState({ isSelectMovieModalOpen: false });
|
|
this.selectRowAfterChange(changed);
|
|
}
|
|
|
|
onSelectQualityModalClose = (changed) => {
|
|
this.setState({ isSelectQualityModalOpen: false });
|
|
this.selectRowAfterChange(changed);
|
|
}
|
|
|
|
onSelectLanguageModalClose = (changed) => {
|
|
this.setState({ isSelectLanguageModalOpen: false });
|
|
this.selectRowAfterChange(changed);
|
|
}
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
const {
|
|
id,
|
|
allowMovieChange,
|
|
relativePath,
|
|
movie,
|
|
quality,
|
|
language,
|
|
size,
|
|
rejections,
|
|
isSelected,
|
|
onSelectedChange
|
|
} = this.props;
|
|
|
|
const {
|
|
isSelectMovieModalOpen,
|
|
isSelectQualityModalOpen,
|
|
isSelectLanguageModalOpen
|
|
} = this.state;
|
|
|
|
const movieTitle = movie ? movie.title : '';
|
|
|
|
const showMoviePlaceholder = isSelected && !movie;
|
|
const showQualityPlaceholder = isSelected && !quality;
|
|
const showLanguagePlaceholder = isSelected && !language;
|
|
// TODO - Placeholder till we implement selection of multiple languages
|
|
const languages = [language];
|
|
return (
|
|
<TableRow>
|
|
<TableSelectCell
|
|
id={id}
|
|
isSelected={isSelected}
|
|
onSelectedChange={onSelectedChange}
|
|
/>
|
|
|
|
<TableRowCell
|
|
className={styles.relativePath}
|
|
title={relativePath}
|
|
>
|
|
{relativePath}
|
|
</TableRowCell>
|
|
|
|
<TableRowCellButton
|
|
isDisabled={!allowMovieChange}
|
|
title={allowMovieChange ? 'Click to change movie' : undefined}
|
|
onPress={this.onSelectMoviePress}
|
|
>
|
|
{
|
|
showMoviePlaceholder ? <InteractiveImportRowCellPlaceholder /> : movieTitle
|
|
}
|
|
</TableRowCellButton>
|
|
|
|
<TableRowCellButton
|
|
className={styles.quality}
|
|
title="Click to change quality"
|
|
onPress={this.onSelectQualityPress}
|
|
>
|
|
{
|
|
showQualityPlaceholder &&
|
|
<InteractiveImportRowCellPlaceholder />
|
|
}
|
|
|
|
{
|
|
!showQualityPlaceholder && !!quality &&
|
|
<MovieQuality
|
|
className={styles.label}
|
|
quality={quality}
|
|
/>
|
|
}
|
|
</TableRowCellButton>
|
|
|
|
<TableRowCellButton
|
|
className={styles.language}
|
|
title="Click to change language"
|
|
onPress={this.onSelectLanguagePress}
|
|
>
|
|
{
|
|
showLanguagePlaceholder &&
|
|
<InteractiveImportRowCellPlaceholder />
|
|
}
|
|
|
|
{
|
|
!showLanguagePlaceholder && !!language &&
|
|
<MovieLanguage
|
|
className={styles.label}
|
|
languages={languages}
|
|
/>
|
|
}
|
|
</TableRowCellButton>
|
|
|
|
<TableRowCell>
|
|
{formatBytes(size)}
|
|
</TableRowCell>
|
|
|
|
<TableRowCell>
|
|
{
|
|
!!rejections.length &&
|
|
<Popover
|
|
anchor={
|
|
<Icon
|
|
name={icons.DANGER}
|
|
kind={kinds.DANGER}
|
|
/>
|
|
}
|
|
title="Release Rejected"
|
|
body={
|
|
<ul>
|
|
{
|
|
rejections.map((rejection, index) => {
|
|
return (
|
|
<li key={index}>
|
|
{rejection.reason}
|
|
</li>
|
|
);
|
|
})
|
|
}
|
|
</ul>
|
|
}
|
|
position={tooltipPositions.LEFT}
|
|
/>
|
|
}
|
|
</TableRowCell>
|
|
|
|
<SelectMovieModal
|
|
isOpen={isSelectMovieModalOpen}
|
|
ids={[id]}
|
|
onModalClose={this.onSelectMovieModalClose}
|
|
/>
|
|
|
|
<SelectQualityModal
|
|
isOpen={isSelectQualityModalOpen}
|
|
ids={[id]}
|
|
qualityId={quality ? quality.quality.id : 0}
|
|
proper={quality ? quality.revision.version > 1 : false}
|
|
real={quality ? quality.revision.real > 0 : false}
|
|
onModalClose={this.onSelectQualityModalClose}
|
|
/>
|
|
|
|
<SelectLanguageModal
|
|
isOpen={isSelectLanguageModalOpen}
|
|
ids={[id]}
|
|
languageId={language ? language.id : 0}
|
|
onModalClose={this.onSelectLanguageModalClose}
|
|
/>
|
|
</TableRow>
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
InteractiveImportRow.propTypes = {
|
|
id: PropTypes.number.isRequired,
|
|
allowMovieChange: PropTypes.bool.isRequired,
|
|
relativePath: PropTypes.string.isRequired,
|
|
movie: PropTypes.object,
|
|
quality: PropTypes.object,
|
|
language: PropTypes.object,
|
|
size: PropTypes.number.isRequired,
|
|
rejections: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
isSelected: PropTypes.bool,
|
|
onSelectedChange: PropTypes.func.isRequired,
|
|
onValidRowChange: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default InteractiveImportRow;
|