From f2122607ba47bb6d076b035105cf3d34e58b8384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 31 May 2021 12:57:55 +0100 Subject: [PATCH] fix: use correct alert messages for updating apps --- i18n/en.pot | 54 ++++++++++--------- .../AppDetails/ManageInstalledVersion.js | 30 +++++++---- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index 10b468d..f0a8ccb 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,55 +5,67 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2021-05-31T10:57:26.807Z\n" -"PO-Revision-Date: 2021-05-31T10:57:26.807Z\n" +"POT-Creation-Date: 2021-05-31T12:04:27.077Z\n" +"PO-Revision-Date: 2021-05-31T12:04:27.077Z\n" -msgid "App uninstalled successfully" +msgid "Version {{version}} installed" msgstr "" -msgid "Failed to uninstall app: {{errorMessage}}" +msgid "Version {{version}}" msgstr "" -msgid "Update to latest version" +msgid "Last updated {{relativeTime}}" msgstr "" -msgid "Install" +msgid "First published {{relativeTime}}" msgstr "" -msgid "{{channel}} release {{version}}" +msgid "by {{- developer}}" msgstr "" -msgid "Uninstall" +msgid "About this app" msgstr "" -msgid "Version {{version}} installed" +msgid "The developer of this application has not provided a description" msgstr "" -msgid "Version {{version}}" +msgid "Additional information" msgstr "" -msgid "Last updated {{relativeTime}}" +msgid "Screenshots" msgstr "" -msgid "First published {{relativeTime}}" +msgid "All compatible versions of this application" msgstr "" -msgid "by {{- developer}}" +msgid "App updated successfully" msgstr "" -msgid "About this app" +msgid "App installed successfully" msgstr "" -msgid "The developer of this application has not provided a description" +msgid "Failed to update app: {{errorMessage}}" msgstr "" -msgid "Additional information" +msgid "Failed to install app: {{errorMessage}}" msgstr "" -msgid "Screenshots" +msgid "App uninstalled successfully" msgstr "" -msgid "All compatible versions of this application" +msgid "Failed to uninstall app: {{errorMessage}}" +msgstr "" + +msgid "Update to latest version" +msgstr "" + +msgid "Install" +msgstr "" + +msgid "{{channel}} release {{version}}" +msgstr "" + +msgid "Uninstall" msgstr "" msgid "Channel" @@ -71,12 +83,6 @@ msgstr "" msgid "Download" msgstr "" -msgid "App installed successfully" -msgstr "" - -msgid "Failed to install app: {{errorMessage}}" -msgstr "" - msgid "There are no compatible versions matching your criteria" msgstr "" diff --git a/src/components/AppDetails/ManageInstalledVersion.js b/src/components/AppDetails/ManageInstalledVersion.js index 0bc418a..734e90d 100644 --- a/src/components/AppDetails/ManageInstalledVersion.js +++ b/src/components/AppDetails/ManageInstalledVersion.js @@ -19,23 +19,34 @@ export const ManageInstalledVersion = ({ // apps their `version` field has a value const isBundled = installedApp && installedApp.bundled && !installedApp.version + const latestVersion = getLatestVersion(versions) + const canUpdate = + installedApp && + latestVersion && + semverGt(latestVersion, installedApp.version) const { installVersion, uninstallApp } = useApi() const successAlert = useAlert(({ message }) => message, { success: true }) const errorAlert = useAlert(({ message }) => message, { critical: true }) - const latestVersion = getLatestVersion(versions) - const handleUpdate = async () => { + const handleInstall = async () => { try { await installVersion(latestVersion.id) successAlert.show({ - message: i18n.t('App uninstalled successfully'), + message: canUpdate + ? i18n.t('App updated successfully') + : i18n.t('App installed successfully'), }) onVersionInstall() } catch (error) { errorAlert.show({ - message: i18n.t('Failed to uninstall app: {{errorMessage}}', { - errorMessage: error.message, - nsSeparator: null, - }), + message: canUpdate + ? i18n.t('Failed to update app: {{errorMessage}}', { + errorMessage: error.message, + nsSeparator: null, + }) + : i18n.t('Failed to install app: {{errorMessage}}', { + errorMessage: error.message, + nsSeparator: null, + }), }) } } @@ -60,9 +71,8 @@ export const ManageInstalledVersion = ({
{latestVersion && ( <> -