From c8d2fcb2230c8a70a8ddc515a69132979f0d5980 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 3 May 2020 17:28:18 +0200 Subject: [PATCH] Added UpdateMechanismMessage to allow package maintainers provide custom message --- frontend/src/System/Updates/Updates.js | 12 ++++++++---- frontend/src/System/Updates/UpdatesConnector.js | 4 ++++ .../Configuration/DeploymentInfoProvider.cs | 3 +++ src/Sonarr.Api.V3/System/SystemModule.cs | 3 ++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/System/Updates/Updates.js b/frontend/src/System/Updates/Updates.js index 77b78a695..87890df2f 100644 --- a/frontend/src/System/Updates/Updates.js +++ b/frontend/src/System/Updates/Updates.js @@ -5,6 +5,7 @@ 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'; @@ -27,6 +28,7 @@ class Updates extends Component { items, isInstallingUpdate, updateMechanism, + updateMechanismMessage, shortDateFormat, onInstallLatestPress } = this.props; @@ -37,10 +39,11 @@ class Updates extends Component { const hasUpdateToInstall = hasUpdates && _.some(items, { installable: true, latest: true }); const noUpdateToInstall = hasUpdates && !hasUpdateToInstall; + const externalUpdaterPrefix = 'Unable to update Sonarr directly,'; const externalUpdaterMessages = { - external: 'Unable to update Sonarr directly, Sonarr is configured to use an external update mechanism', - apt: 'Unable to update Sonarr directly, use apt to install the update', - docker: 'Unable to update Sonarr directly, update the docker container to receive the update' + external: 'Sonarr 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 ( @@ -78,7 +81,7 @@ class Updates extends Component { />
- {externalUpdaterMessages[updateMechanism] || externalUpdaterMessages.external} + {externalUpdaterPrefix}
} @@ -210,6 +213,7 @@ Updates.propTypes = { items: PropTypes.array.isRequired, isInstallingUpdate: PropTypes.bool.isRequired, updateMechanism: PropTypes.string, + updateMechanismMessage: PropTypes.string, shortDateFormat: PropTypes.string.isRequired, onInstallLatestPress: PropTypes.func.isRequired }; diff --git a/frontend/src/System/Updates/UpdatesConnector.js b/frontend/src/System/Updates/UpdatesConnector.js index 8836bbb94..d93b3ba4a 100644 --- a/frontend/src/System/Updates/UpdatesConnector.js +++ b/frontend/src/System/Updates/UpdatesConnector.js @@ -7,18 +7,21 @@ import { fetchUpdates } from 'Store/Actions/systemActions'; import { executeCommand } from 'Store/Actions/commandActions'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector'; import * as commandNames from 'Commands/commandNames'; import Updates from './Updates'; function createMapStateToProps() { return createSelector( (state) => state.app.version, + createSystemStatusSelector(), (state) => state.system.updates, (state) => state.settings.general, createUISettingsSelector(), createCommandExecutingSelector(commandNames.APPLICATION_UPDATE), ( currentVersion, + status, updates, generalSettings, uiSettings, @@ -41,6 +44,7 @@ function createMapStateToProps() { items, isInstallingUpdate, updateMechanism: generalSettings.item.updateMechanism, + updateMechanismMessage: status.packageUpdateMechanismMessage, shortDateFormat: uiSettings.shortDateFormat }; } diff --git a/src/NzbDrone.Core/Configuration/DeploymentInfoProvider.cs b/src/NzbDrone.Core/Configuration/DeploymentInfoProvider.cs index f19ce68ac..ff812527a 100644 --- a/src/NzbDrone.Core/Configuration/DeploymentInfoProvider.cs +++ b/src/NzbDrone.Core/Configuration/DeploymentInfoProvider.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Core.Configuration string PackageAuthor { get; } string PackageBranch { get; } UpdateMechanism PackageUpdateMechanism { get; } + string PackageUpdateMechanismMessage { get; } string ReleaseVersion { get; } string ReleaseBranch { get; } @@ -45,6 +46,7 @@ namespace NzbDrone.Core.Configuration PackageVersion = ReadValue(data, "PackageVersion"); PackageAuthor = ReadValue(data, "PackageAuthor"); PackageUpdateMechanism = ReadEnumValue(data, "UpdateMethod", UpdateMechanism.BuiltIn); + PackageUpdateMechanismMessage = ReadValue(data, "UpdateMethodMessage"); PackageBranch = ReadValue(data, "Branch"); ReleaseVersion = ReadValue(data, "ReleaseVersion"); @@ -98,6 +100,7 @@ namespace NzbDrone.Core.Configuration public string PackageAuthor { get; private set; } public string PackageBranch { get; private set; } public UpdateMechanism PackageUpdateMechanism { get; private set; } + public string PackageUpdateMechanismMessage { get; private set; } public string ReleaseVersion { get; private set; } public string ReleaseBranch { get; set; } diff --git a/src/Sonarr.Api.V3/System/SystemModule.cs b/src/Sonarr.Api.V3/System/SystemModule.cs index d79415c7a..408015ef5 100644 --- a/src/Sonarr.Api.V3/System/SystemModule.cs +++ b/src/Sonarr.Api.V3/System/SystemModule.cs @@ -75,7 +75,8 @@ namespace Sonarr.Api.V3.System StartTime = _runtimeInfo.StartTime, PackageVersion = _deploymentInfoProvider.PackageVersion, PackageAuthor = _deploymentInfoProvider.PackageAuthor, - PackageUpdateMechanism = _deploymentInfoProvider.PackageUpdateMechanism + PackageUpdateMechanism = _deploymentInfoProvider.PackageUpdateMechanism, + PackageUpdateMechanismMessage = _deploymentInfoProvider.PackageUpdateMechanismMessage }; }