import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component, Fragment } 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 InlineMarkdown from 'Components/Markdown/InlineMarkdown'; 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, updateMechanism, isDocker, updateMechanismMessage, 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; const externalUpdaterPrefix = 'Unable to update Radarr directly,'; const externalUpdaterMessages = { external: 'Readarr is configured to use an external update mechanism', apt: 'use apt to install the update', docker: 'update the docker container to receive the update' }; return ( { !isPopulated && !error && } { noUpdates &&
No updates are available
} { hasUpdateToInstall &&
{ (updateMechanism === 'builtIn' || updateMechanism === 'script') && !isDocker ? Install Latest :
{externalUpdaterPrefix}
} { 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, updateMechanism: PropTypes.string, updateMechanismMessage: PropTypes.string, shortDateFormat: PropTypes.string.isRequired, onInstallLatestPress: PropTypes.func.isRequired }; export default Updates;