2017-09-04 02:20:56 +00:00
|
|
|
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';
|
2017-10-15 06:17:53 +00:00
|
|
|
import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar';
|
2017-09-04 02:20:56 +00:00
|
|
|
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
|
|
|
|
|
2017-09-16 20:22:06 +00:00
|
|
|
onEditArtistPress = () => {
|
2017-09-04 02:20:56 +00:00
|
|
|
this.setState({ isEditArtistModalOpen: true });
|
|
|
|
}
|
|
|
|
|
2017-09-16 20:22:06 +00:00
|
|
|
onEditArtistModalClose = () => {
|
2017-09-04 02:20:56 +00:00
|
|
|
this.setState({ isEditArtistModalOpen: false });
|
|
|
|
}
|
|
|
|
|
2017-09-16 20:22:06 +00:00
|
|
|
onDeleteArtistPress = () => {
|
2017-09-04 02:20:56 +00:00
|
|
|
this.setState({
|
|
|
|
isEditArtistModalOpen: false,
|
|
|
|
isDeleteArtistModalOpen: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-12 03:11:32 +00:00
|
|
|
onDeleteArtistModalClose = () => {
|
2017-09-04 02:20:56 +00:00
|
|
|
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,
|
2017-09-16 20:22:06 +00:00
|
|
|
isRefreshingArtist,
|
2017-09-12 03:11:32 +00:00
|
|
|
onRefreshArtistPress,
|
2017-09-04 02:20:56 +00:00
|
|
|
...otherProps
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
isEditArtistModalOpen,
|
|
|
|
isDeleteArtistModalOpen
|
|
|
|
} = this.state;
|
|
|
|
|
2017-09-12 03:11:32 +00:00
|
|
|
const link = `/artist/${nameSlug}`;
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
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"
|
2017-09-16 20:22:06 +00:00
|
|
|
isSpinning={isRefreshingArtist}
|
2017-09-12 03:11:32 +00:00
|
|
|
onPress={onRefreshArtistPress}
|
2017-09-04 02:20:56 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<IconButton
|
|
|
|
className={styles.action}
|
|
|
|
name={icons.EDIT}
|
|
|
|
title="Edit Artist"
|
2017-09-16 20:22:06 +00:00
|
|
|
onPress={this.onEditArtistPress}
|
2017-09-04 02:20:56 +00:00
|
|
|
/>
|
|
|
|
</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>
|
|
|
|
|
2017-10-15 06:17:53 +00:00
|
|
|
<ArtistIndexProgressBar
|
2017-09-04 02:20:56 +00:00
|
|
|
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}
|
2017-10-15 06:17:53 +00:00
|
|
|
showQualityProfile={showQualityProfile}
|
2017-09-04 02:20:56 +00:00
|
|
|
showRelativeDates={showRelativeDates}
|
|
|
|
shortDateFormat={shortDateFormat}
|
|
|
|
timeFormat={timeFormat}
|
|
|
|
{...otherProps}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<EditArtistModalConnector
|
|
|
|
isOpen={isEditArtistModalOpen}
|
|
|
|
artistId={id}
|
2017-09-16 20:22:06 +00:00
|
|
|
onModalClose={this.onEditArtistModalClose}
|
|
|
|
onDeleteArtistPress={this.onDeleteArtistPress}
|
2017-09-04 02:20:56 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<DeleteArtistModal
|
|
|
|
isOpen={isDeleteArtistModalOpen}
|
|
|
|
artistId={id}
|
2017-09-12 03:11:32 +00:00
|
|
|
onModalClose={this.onDeleteArtistModalClose}
|
2017-09-04 02:20:56 +00:00
|
|
|
/>
|
|
|
|
</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,
|
2017-09-16 20:22:06 +00:00
|
|
|
isRefreshingArtist: PropTypes.bool.isRequired,
|
2017-09-12 03:11:32 +00:00
|
|
|
onRefreshArtistPress: PropTypes.func.isRequired
|
2017-09-04 02:20:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ArtistIndexPoster.defaultProps = {
|
|
|
|
trackCount: 0,
|
|
|
|
trackFileCount: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ArtistIndexPoster;
|