import PropTypes from 'prop-types'; import React, { Component } from 'react'; import TextTruncate from 'react-text-truncate'; import AuthorPoster from 'Author/AuthorPoster'; import DeleteAuthorModal from 'Author/Delete/DeleteAuthorModal'; import EditAuthorModalConnector from 'Author/Edit/EditAuthorModalConnector'; import AuthorIndexProgressBar from 'Author/Index/ProgressBar/AuthorIndexProgressBar'; import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import { icons } from 'Helpers/Props'; import dimensions from 'Styles/Variables/dimensions'; import fonts from 'Styles/Variables/fonts'; import stripHtml from 'Utilities/String/stripHtml'; import AuthorIndexOverviewInfo from './AuthorIndexOverviewInfo'; import styles from './AuthorIndexOverview.css'; const columnPadding = parseInt(dimensions.authorIndexColumnPadding); const columnPaddingSmallScreen = parseInt(dimensions.authorIndexColumnPaddingSmallScreen); const defaultFontSize = parseInt(fonts.defaultFontSize); const lineHeight = parseFloat(fonts.lineHeight); // Hardcoded height beased on line-height of 32 + bottom margin of 10. // Less side-effecty than using react-measure. const titleRowHeight = 42; function getContentHeight(rowHeight, isSmallScreen) { const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; return rowHeight - padding; } class AuthorIndexOverview extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isEditAuthorModalOpen: false, isDeleteAuthorModalOpen: false }; } // // Listeners onEditAuthorPress = () => { this.setState({ isEditAuthorModalOpen: true }); } onEditAuthorModalClose = () => { this.setState({ isEditAuthorModalOpen: false }); } onDeleteAuthorPress = () => { this.setState({ isEditAuthorModalOpen: false, isDeleteAuthorModalOpen: true }); } onDeleteAuthorModalClose = () => { this.setState({ isDeleteAuthorModalOpen: false }); } // // Render render() { const { id, authorName, overview, monitored, status, titleSlug, nextAiring, statistics, images, posterWidth, posterHeight, qualityProfile, overviewOptions, showSearchAction, showRelativeDates, shortDateFormat, longDateFormat, timeFormat, rowHeight, isSmallScreen, isRefreshingAuthor, isSearchingAuthor, onRefreshAuthorPress, onSearchPress, ...otherProps } = this.props; const { bookCount, sizeOnDisk, bookFileCount, totalBookCount } = statistics; const { isEditAuthorModalOpen, isDeleteAuthorModalOpen } = this.state; const link = `/author/${titleSlug}`; const elementStyle = { width: `${posterWidth}px`, height: `${posterHeight}px`, objectFit: 'contain' }; const contentHeight = getContentHeight(rowHeight, isSmallScreen); const overviewHeight = contentHeight - titleRowHeight; return (