2018-11-23 07:04:42 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import Icon from 'Components/Icon';
|
|
|
|
import Label from 'Components/Label';
|
|
|
|
import Link from 'Components/Link/Link';
|
2022-06-26 22:23:07 +00:00
|
|
|
import TmdbRating from 'Components/TmdbRating';
|
2020-08-09 02:07:57 +00:00
|
|
|
import Tooltip from 'Components/Tooltip/Tooltip';
|
|
|
|
import { icons, kinds, sizes, tooltipPositions } from 'Helpers/Props';
|
|
|
|
import MovieDetailsLinks from 'Movie/Details/MovieDetailsLinks';
|
2020-10-05 18:50:03 +00:00
|
|
|
import MovieStatusLabel from 'Movie/Details/MovieStatusLabel';
|
|
|
|
import MovieIndexProgressBar from 'Movie/Index/ProgressBar/MovieIndexProgressBar';
|
2018-11-23 07:04:42 +00:00
|
|
|
import MoviePoster from 'Movie/MoviePoster';
|
2021-04-13 00:49:37 +00:00
|
|
|
import formatRuntime from 'Utilities/Date/formatRuntime';
|
2020-08-29 03:56:13 +00:00
|
|
|
import translate from 'Utilities/String/translate';
|
2018-11-23 07:04:42 +00:00
|
|
|
import AddNewMovieModal from './AddNewMovieModal';
|
|
|
|
import styles from './AddNewMovieSearchResult.css';
|
|
|
|
|
|
|
|
class AddNewMovieSearchResult extends Component {
|
|
|
|
|
|
|
|
//
|
|
|
|
// Lifecycle
|
|
|
|
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
isNewAddMovieModalOpen: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
if (!prevProps.isExistingMovie && this.props.isExistingMovie) {
|
2019-07-06 02:26:16 +00:00
|
|
|
this.onAddMovieModalClose();
|
2018-11-23 07:04:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Listeners
|
|
|
|
|
|
|
|
onPress = () => {
|
|
|
|
this.setState({ isNewAddMovieModalOpen: true });
|
2022-03-20 23:20:34 +00:00
|
|
|
};
|
2018-11-23 07:04:42 +00:00
|
|
|
|
2019-07-06 02:26:16 +00:00
|
|
|
onAddMovieModalClose = () => {
|
2018-11-23 07:04:42 +00:00
|
|
|
this.setState({ isNewAddMovieModalOpen: false });
|
2022-03-20 23:20:34 +00:00
|
|
|
};
|
2018-11-23 07:04:42 +00:00
|
|
|
|
2020-07-30 01:33:49 +00:00
|
|
|
onExternalLinkPress = (event) => {
|
2019-12-07 06:25:03 +00:00
|
|
|
event.stopPropagation();
|
2022-03-20 23:20:34 +00:00
|
|
|
};
|
2019-12-07 06:25:03 +00:00
|
|
|
|
2018-11-23 07:04:42 +00:00
|
|
|
//
|
|
|
|
// Render
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
tmdbId,
|
2020-07-30 01:33:49 +00:00
|
|
|
imdbId,
|
2020-08-09 02:07:57 +00:00
|
|
|
youTubeTrailerId,
|
2018-11-23 07:04:42 +00:00
|
|
|
title,
|
|
|
|
titleSlug,
|
|
|
|
year,
|
|
|
|
studio,
|
|
|
|
status,
|
|
|
|
overview,
|
|
|
|
ratings,
|
2019-09-29 20:27:30 +00:00
|
|
|
folder,
|
2018-11-23 07:04:42 +00:00
|
|
|
images,
|
|
|
|
isExistingMovie,
|
2019-07-06 02:26:16 +00:00
|
|
|
isExclusionMovie,
|
2020-10-05 18:50:03 +00:00
|
|
|
isSmallScreen,
|
|
|
|
colorImpairedMode,
|
|
|
|
id,
|
|
|
|
monitored,
|
|
|
|
hasFile,
|
|
|
|
isAvailable,
|
|
|
|
queueStatus,
|
2021-04-13 00:49:37 +00:00
|
|
|
queueState,
|
|
|
|
runtime,
|
|
|
|
movieRuntimeFormat,
|
|
|
|
certification
|
2018-11-23 07:04:42 +00:00
|
|
|
} = this.props;
|
2019-10-06 03:21:55 +00:00
|
|
|
|
2018-11-23 07:04:42 +00:00
|
|
|
const {
|
|
|
|
isNewAddMovieModalOpen
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
const linkProps = isExistingMovie ? { to: `/movie/${titleSlug}` } : { onPress: this.onPress };
|
2022-01-21 02:45:46 +00:00
|
|
|
const posterWidth = 167;
|
|
|
|
const posterHeight = 250;
|
|
|
|
|
|
|
|
const elementStyle = {
|
|
|
|
width: `${posterWidth}px`,
|
|
|
|
height: `${posterHeight}px`
|
|
|
|
};
|
2018-11-23 07:04:42 +00:00
|
|
|
|
|
|
|
return (
|
2019-12-31 02:48:43 +00:00
|
|
|
<div className={styles.searchResult}>
|
2018-11-23 07:04:42 +00:00
|
|
|
<Link
|
2019-12-31 02:48:43 +00:00
|
|
|
className={styles.underlay}
|
2018-11-23 07:04:42 +00:00
|
|
|
{...linkProps}
|
2019-12-31 02:48:43 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<div className={styles.overlay}>
|
2018-11-23 07:04:42 +00:00
|
|
|
{
|
|
|
|
isSmallScreen ?
|
|
|
|
null :
|
2020-10-05 18:50:03 +00:00
|
|
|
<div>
|
|
|
|
<div className={styles.posterContainer}>
|
|
|
|
<MoviePoster
|
|
|
|
className={styles.poster}
|
2022-01-21 02:45:46 +00:00
|
|
|
style={elementStyle}
|
2020-10-05 18:50:03 +00:00
|
|
|
images={images}
|
|
|
|
size={250}
|
|
|
|
overflow={true}
|
2023-04-14 03:09:55 +00:00
|
|
|
lazy={false}
|
2020-10-05 18:50:03 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{
|
|
|
|
isExistingMovie &&
|
|
|
|
<MovieIndexProgressBar
|
|
|
|
monitored={monitored}
|
|
|
|
hasFile={hasFile}
|
|
|
|
status={status}
|
2023-05-03 04:07:12 +00:00
|
|
|
width={posterWidth}
|
2020-10-05 18:50:03 +00:00
|
|
|
detailedProgressBar={true}
|
|
|
|
queueStatus={queueStatus}
|
|
|
|
queueState={queueState}
|
|
|
|
isAvailable={isAvailable}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</div>
|
2018-11-23 07:04:42 +00:00
|
|
|
}
|
|
|
|
|
2019-12-07 06:25:03 +00:00
|
|
|
<div className={styles.content}>
|
2020-09-06 04:34:10 +00:00
|
|
|
<div className={styles.titleRow}>
|
|
|
|
<div className={styles.titleContainer}>
|
|
|
|
<div className={styles.title}>
|
|
|
|
{title}
|
|
|
|
|
|
|
|
{
|
|
|
|
!title.contains(year) && !!year ?
|
|
|
|
<span className={styles.year}>
|
|
|
|
({year})
|
|
|
|
</span> :
|
|
|
|
null
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.icons}>
|
|
|
|
|
|
|
|
{
|
|
|
|
isExistingMovie &&
|
|
|
|
<Icon
|
|
|
|
className={styles.alreadyExistsIcon}
|
|
|
|
name={icons.CHECK_CIRCLE}
|
|
|
|
size={36}
|
|
|
|
title={translate('AlreadyInYourLibrary')}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
isExclusionMovie &&
|
|
|
|
<Icon
|
|
|
|
className={styles.exclusionIcon}
|
|
|
|
name={icons.DANGER}
|
|
|
|
size={36}
|
|
|
|
title={translate('MovieIsOnImportExclusionList')}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</div>
|
2018-11-23 07:04:42 +00:00
|
|
|
</div>
|
|
|
|
|
2021-04-13 00:49:37 +00:00
|
|
|
<div>
|
|
|
|
{
|
|
|
|
!!certification &&
|
|
|
|
<span className={styles.certification}>
|
|
|
|
{certification}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
!!runtime &&
|
2021-05-11 03:41:21 +00:00
|
|
|
<span className={styles.runtime}>
|
2021-04-13 00:49:37 +00:00
|
|
|
{formatRuntime(runtime, movieRuntimeFormat)}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
|
2018-11-23 07:04:42 +00:00
|
|
|
<div>
|
|
|
|
<Label size={sizes.LARGE}>
|
2022-06-26 22:23:07 +00:00
|
|
|
<TmdbRating
|
2020-10-13 04:14:15 +00:00
|
|
|
ratings={ratings}
|
2018-11-23 07:04:42 +00:00
|
|
|
iconSize={13}
|
|
|
|
/>
|
|
|
|
</Label>
|
|
|
|
|
|
|
|
{
|
|
|
|
!!studio &&
|
2019-12-07 02:38:58 +00:00
|
|
|
<Label size={sizes.LARGE}>
|
|
|
|
{studio}
|
|
|
|
</Label>
|
2018-11-23 07:04:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-09 02:07:57 +00:00
|
|
|
<Tooltip
|
|
|
|
anchor={
|
|
|
|
<Label
|
|
|
|
size={sizes.LARGE}
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
name={icons.EXTERNAL_LINK}
|
|
|
|
size={13}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<span className={styles.links}>
|
|
|
|
Links
|
|
|
|
</span>
|
|
|
|
</Label>
|
|
|
|
}
|
|
|
|
tooltip={
|
|
|
|
<MovieDetailsLinks
|
|
|
|
tmdbId={tmdbId}
|
|
|
|
youTubeTrailerId={youTubeTrailerId}
|
|
|
|
imdbId={imdbId}
|
|
|
|
/>
|
|
|
|
}
|
2020-10-05 03:34:27 +00:00
|
|
|
canFlip={true}
|
2020-08-09 02:07:57 +00:00
|
|
|
kind={kinds.INVERSE}
|
|
|
|
position={tooltipPositions.BOTTOM}
|
|
|
|
/>
|
|
|
|
|
2018-11-23 07:04:42 +00:00
|
|
|
{
|
2020-10-05 18:50:03 +00:00
|
|
|
isExistingMovie && isSmallScreen &&
|
|
|
|
<MovieStatusLabel
|
|
|
|
hasMovieFiles={hasFile}
|
|
|
|
monitored={monitored}
|
|
|
|
isAvailable={isAvailable}
|
|
|
|
id={id}
|
|
|
|
useLabel={true}
|
|
|
|
colorImpairedMode={colorImpairedMode}
|
|
|
|
/>
|
2018-11-23 07:04:42 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.overview}>
|
|
|
|
{overview}
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-12-31 02:48:43 +00:00
|
|
|
</div>
|
2018-11-23 07:04:42 +00:00
|
|
|
|
|
|
|
<AddNewMovieModal
|
|
|
|
isOpen={isNewAddMovieModalOpen && !isExistingMovie}
|
|
|
|
tmdbId={tmdbId}
|
|
|
|
title={title}
|
|
|
|
year={year}
|
|
|
|
overview={overview}
|
2019-09-29 20:27:30 +00:00
|
|
|
folder={folder}
|
2018-11-23 07:04:42 +00:00
|
|
|
images={images}
|
2019-07-06 02:26:16 +00:00
|
|
|
onModalClose={this.onAddMovieModalClose}
|
2018-11-23 07:04:42 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AddNewMovieSearchResult.propTypes = {
|
|
|
|
tmdbId: PropTypes.number.isRequired,
|
2020-07-30 01:33:49 +00:00
|
|
|
imdbId: PropTypes.string,
|
2020-08-09 02:07:57 +00:00
|
|
|
youTubeTrailerId: PropTypes.string,
|
2018-11-23 07:04:42 +00:00
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
titleSlug: PropTypes.string.isRequired,
|
|
|
|
year: PropTypes.number.isRequired,
|
|
|
|
studio: PropTypes.string,
|
|
|
|
status: PropTypes.string.isRequired,
|
|
|
|
overview: PropTypes.string,
|
|
|
|
ratings: PropTypes.object.isRequired,
|
2019-09-29 20:27:30 +00:00
|
|
|
folder: PropTypes.string.isRequired,
|
2018-11-23 07:04:42 +00:00
|
|
|
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
isExistingMovie: PropTypes.bool.isRequired,
|
2019-07-06 02:26:16 +00:00
|
|
|
isExclusionMovie: PropTypes.bool.isRequired,
|
2020-10-05 18:50:03 +00:00
|
|
|
isSmallScreen: PropTypes.bool.isRequired,
|
|
|
|
id: PropTypes.number,
|
|
|
|
queueItems: PropTypes.arrayOf(PropTypes.object),
|
|
|
|
monitored: PropTypes.bool.isRequired,
|
|
|
|
hasFile: PropTypes.bool.isRequired,
|
|
|
|
isAvailable: PropTypes.bool.isRequired,
|
|
|
|
colorImpairedMode: PropTypes.bool,
|
|
|
|
queueStatus: PropTypes.string,
|
2021-04-13 00:49:37 +00:00
|
|
|
queueState: PropTypes.string,
|
|
|
|
runtime: PropTypes.number.isRequired,
|
|
|
|
movieRuntimeFormat: PropTypes.string.isRequired,
|
|
|
|
certification: PropTypes.string
|
2018-11-23 07:04:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default AddNewMovieSearchResult;
|