You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
231 lines
6.0 KiB
231 lines
6.0 KiB
7 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
|
import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
||
|
import { icons } from 'Helpers/Props';
|
||
|
import IconButton from 'Components/Link/IconButton';
|
||
|
import SpinnerIconButton from 'Components/Link/SpinnerIconButton';
|
||
|
import Label from 'Components/Label';
|
||
|
import Link from 'Components/Link/Link';
|
||
|
import ArtistPoster from 'Artist/ArtistPoster';
|
||
|
import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector';
|
||
|
import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal';
|
||
|
import ArtistIndexPosterProgressBar from './ArtistIndexPosterProgressBar';
|
||
|
import ArtistIndexPosterInfo from './ArtistIndexPosterInfo';
|
||
|
import styles from './ArtistIndexPoster.css';
|
||
|
|
||
|
class ArtistIndexPoster extends Component {
|
||
|
|
||
|
//
|
||
|
// Lifecycle
|
||
|
|
||
|
constructor(props, context) {
|
||
|
super(props, context);
|
||
|
|
||
|
this.state = {
|
||
|
isEditArtistModalOpen: false,
|
||
|
isDeleteArtistModalOpen: false
|
||
|
};
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// Listeners
|
||
|
|
||
|
onEditSeriesPress = () => {
|
||
|
this.setState({ isEditArtistModalOpen: true });
|
||
|
}
|
||
|
|
||
|
onEditSeriesModalClose = () => {
|
||
|
this.setState({ isEditArtistModalOpen: false });
|
||
|
}
|
||
|
|
||
|
onDeleteSeriesPress = () => {
|
||
|
this.setState({
|
||
|
isEditArtistModalOpen: false,
|
||
|
isDeleteArtistModalOpen: true
|
||
|
});
|
||
|
}
|
||
|
|
||
|
onDeleteSeriesModalClose = () => {
|
||
|
this.setState({ isDeleteArtistModalOpen: false });
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// Render
|
||
|
|
||
|
render() {
|
||
|
const {
|
||
|
style,
|
||
|
id,
|
||
|
artistName,
|
||
|
monitored,
|
||
|
status,
|
||
|
nameSlug,
|
||
|
nextAiring,
|
||
|
trackCount,
|
||
|
trackFileCount,
|
||
|
images,
|
||
|
posterWidth,
|
||
|
posterHeight,
|
||
|
detailedProgressBar,
|
||
|
showTitle,
|
||
|
showQualityProfile,
|
||
|
qualityProfile,
|
||
|
showRelativeDates,
|
||
|
shortDateFormat,
|
||
|
timeFormat,
|
||
|
isRefreshingSeries,
|
||
|
onRefreshSeriesPress,
|
||
|
...otherProps
|
||
|
} = this.props;
|
||
|
|
||
|
const {
|
||
|
isEditArtistModalOpen,
|
||
|
isDeleteArtistModalOpen
|
||
|
} = this.state;
|
||
|
|
||
|
const link = `/series/${nameSlug}`;
|
||
|
|
||
|
const elementStyle = {
|
||
|
width: `${posterWidth}px`,
|
||
|
height: `${posterHeight}px`
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<div className={styles.container} style={style}>
|
||
|
<div className={styles.content}>
|
||
|
<div className={styles.posterContainer}>
|
||
|
<Label className={styles.controls}>
|
||
|
<SpinnerIconButton
|
||
|
className={styles.action}
|
||
|
name={icons.REFRESH}
|
||
|
title="Refresh Artist"
|
||
|
isSpinning={isRefreshingSeries}
|
||
|
onPress={onRefreshSeriesPress}
|
||
|
/>
|
||
|
|
||
|
<IconButton
|
||
|
className={styles.action}
|
||
|
name={icons.EDIT}
|
||
|
title="Edit Artist"
|
||
|
onPress={this.onEditSeriesPress}
|
||
|
/>
|
||
|
</Label>
|
||
|
|
||
|
{
|
||
|
status === 'ended' &&
|
||
|
<div
|
||
|
className={styles.ended}
|
||
|
title="Ended"
|
||
|
/>
|
||
|
}
|
||
|
|
||
|
<Link
|
||
|
className={styles.link}
|
||
|
style={elementStyle}
|
||
|
to={link}
|
||
|
>
|
||
|
<ArtistPoster
|
||
|
className={styles.poster}
|
||
|
style={elementStyle}
|
||
|
images={images}
|
||
|
size={250}
|
||
|
lazy={false}
|
||
|
overflow={true}
|
||
|
/>
|
||
|
</Link>
|
||
|
</div>
|
||
|
|
||
|
<ArtistIndexPosterProgressBar
|
||
|
monitored={monitored}
|
||
|
status={status}
|
||
|
trackCount={trackCount}
|
||
|
trackFileCount={trackFileCount}
|
||
|
posterWidth={posterWidth}
|
||
|
detailedProgressBar={detailedProgressBar}
|
||
|
/>
|
||
|
|
||
|
{
|
||
|
showTitle &&
|
||
|
<div className={styles.title}>
|
||
|
{artistName}
|
||
|
</div>
|
||
|
}
|
||
|
|
||
|
{
|
||
|
showQualityProfile &&
|
||
|
<div className={styles.title}>
|
||
|
{qualityProfile.name}
|
||
|
</div>
|
||
|
}
|
||
|
|
||
|
<div className={styles.nextAiring}>
|
||
|
{
|
||
|
getRelativeDate(
|
||
|
nextAiring,
|
||
|
shortDateFormat,
|
||
|
showRelativeDates,
|
||
|
{
|
||
|
timeFormat,
|
||
|
timeForToday: true
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
</div>
|
||
|
|
||
|
<ArtistIndexPosterInfo
|
||
|
qualityProfile={qualityProfile}
|
||
|
showRelativeDates={showRelativeDates}
|
||
|
shortDateFormat={shortDateFormat}
|
||
|
timeFormat={timeFormat}
|
||
|
{...otherProps}
|
||
|
/>
|
||
|
|
||
|
<EditArtistModalConnector
|
||
|
isOpen={isEditArtistModalOpen}
|
||
|
artistId={id}
|
||
|
onModalClose={this.onEditSeriesModalClose}
|
||
|
onDeleteSeriesPress={this.onDeleteSeriesPress}
|
||
|
/>
|
||
|
|
||
|
<DeleteArtistModal
|
||
|
isOpen={isDeleteArtistModalOpen}
|
||
|
artistId={id}
|
||
|
onModalClose={this.onDeleteSeriesModalClose}
|
||
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ArtistIndexPoster.propTypes = {
|
||
|
style: PropTypes.object.isRequired,
|
||
|
id: PropTypes.number.isRequired,
|
||
|
artistName: PropTypes.string.isRequired,
|
||
|
monitored: PropTypes.bool.isRequired,
|
||
|
status: PropTypes.string.isRequired,
|
||
|
nameSlug: PropTypes.string.isRequired,
|
||
|
nextAiring: PropTypes.string,
|
||
|
trackCount: PropTypes.number,
|
||
|
trackFileCount: PropTypes.number,
|
||
|
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||
|
posterWidth: PropTypes.number.isRequired,
|
||
|
posterHeight: PropTypes.number.isRequired,
|
||
|
detailedProgressBar: PropTypes.bool.isRequired,
|
||
|
showTitle: PropTypes.bool.isRequired,
|
||
|
showQualityProfile: PropTypes.bool.isRequired,
|
||
|
qualityProfile: PropTypes.object.isRequired,
|
||
|
showRelativeDates: PropTypes.bool.isRequired,
|
||
|
shortDateFormat: PropTypes.string.isRequired,
|
||
|
timeFormat: PropTypes.string.isRequired,
|
||
|
isRefreshingSeries: PropTypes.bool.isRequired,
|
||
|
onRefreshSeriesPress: PropTypes.func.isRequired
|
||
|
};
|
||
|
|
||
|
ArtistIndexPoster.defaultProps = {
|
||
|
trackCount: 0,
|
||
|
trackFileCount: 0
|
||
|
};
|
||
|
|
||
|
export default ArtistIndexPoster;
|