import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component, Fragment } from 'react'; import Alert from 'Components/Alert'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; import SpinnerButton from 'Components/Link/SpinnerButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import InlineMarkdown from 'Components/Markdown/InlineMarkdown'; import PageContent from 'Components/Page/PageContent'; import PageContentBody from 'Components/Page/PageContentBody'; import { icons, kinds } from 'Helpers/Props'; import formatDate from 'Utilities/Date/formatDate'; import formatDateTime from 'Utilities/Date/formatDateTime'; import translate from 'Utilities/String/translate'; import UpdateChanges from './UpdateChanges'; import styles from './Updates.css'; class Updates extends Component { // // Render render() { const { currentVersion, isFetching, isPopulated, updatesError, generalSettingsError, items, isInstallingUpdate, updateMechanism, updateMechanismMessage, shortDateFormat, longDateFormat, timeFormat, 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; const externalUpdaterPrefix = 'Unable to update Lidarr directly,'; const externalUpdaterMessages = { external: 'Lidarr 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 && !hasError && } { noUpdates && {translate('NoUpdatesAreAvailable')} } { hasUpdateToInstall &&
{ updateMechanism === 'builtIn' || updateMechanism === 'script' ? Install Latest :
{externalUpdaterPrefix}
} { isFetching && }
} { noUpdateToInstall &&
The latest version of Lidarr 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 } { update.version !== currentVersion && update.installedOn ? : null }
{ !hasChanges &&
{translate('MaintenanceRelease')}
} { 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, updateMechanism: PropTypes.string, updateMechanismMessage: PropTypes.string, shortDateFormat: PropTypes.string.isRequired, longDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, onInstallLatestPress: PropTypes.func.isRequired }; export default Updates;