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, updatesError, generalSettingsError, items, isInstallingUpdate, isDocker, shortDateFormat, onInstallLatestPress } = this.props; const hasError = !!(updatesError || generalSettingsError); const hasUpdates = isPopulated && !hasError && items.length > 0; const noUpdates = isPopulated && !hasError && !items.length; const hasUpdateToInstall = hasUpdates && _.some(items, { installable: true, latest: true }); const noUpdateToInstall = hasUpdates && !hasUpdateToInstall; return ( { !isPopulated && !hasError && } { 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 Radarr 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 &&
}
); }) }
} { !!updatesError &&
Failed to fetch updates
} { !!generalSettingsError &&
Failed to update settings
}
); } } Updates.propTypes = { currentVersion: PropTypes.string.isRequired, isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, updatesError: PropTypes.object, generalSettingsError: PropTypes.object, items: PropTypes.array.isRequired, isInstallingUpdate: PropTypes.bool.isRequired, isDocker: PropTypes.bool.isRequired, updateMechanism: PropTypes.string, shortDateFormat: PropTypes.string.isRequired, onInstallLatestPress: PropTypes.func.isRequired }; export default Updates;