import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { icons, kinds } from 'Helpers/Props'; import formatDate from 'Utilities/Date/formatDate'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import SpinnerButton from 'Components/Link/SpinnerButton'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; import PageContent from 'Components/Page/PageContent'; import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; import UpdateChanges from './UpdateChanges'; import styles from './Updates.css'; class Updates extends Component { // // Render render() { const { currentVersion, isFetching, isPopulated, error, items, isInstallingUpdate, isDocker, shortDateFormat, onInstallLatestPress } = this.props; const hasUpdates = isPopulated && !error && items.length > 0; const noUpdates = isPopulated && !error && !items.length; const hasUpdateToInstall = hasUpdates && _.some(items, { installable: true, latest: true }); const noUpdateToInstall = hasUpdates && !hasUpdateToInstall; return ( { !isPopulated && !error && } { noUpdates &&
No updates are available
} { hasUpdateToInstall &&
{ !isDocker && Install Latest } { isDocker &&
An update is available. Please update your Docker image and re-create the container.
} { isFetching && }
} { noUpdateToInstall &&
The latest version of Readarr is already installed
{ isFetching && }
} { hasUpdates &&
{ items.map((update) => { const hasChanges = !!update.changes; return (
{update.version}
{formatDate(update.releaseDate, shortDateFormat)}
{ update.branch === 'master' ? null : } { update.version === currentVersion ? : null }
{ !hasChanges &&
Maintenance release
} { hasChanges &&
}
); }) }
} { !!error &&
Failed to fetch updates
}
); } } Updates.propTypes = { currentVersion: PropTypes.string.isRequired, isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, items: PropTypes.array.isRequired, isInstallingUpdate: PropTypes.bool.isRequired, isDocker: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, onInstallLatestPress: PropTypes.func.isRequired }; export default Updates;