Skip to content

Commit

Permalink
fix: use correct alert messages for updating apps
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi committed May 31, 2021
1 parent a2281b0 commit f212260
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 34 deletions.
54 changes: 30 additions & 24 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ""

Expand Down
30 changes: 20 additions & 10 deletions src/components/AppDetails/ManageInstalledVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
})
}
}
Expand All @@ -60,9 +71,8 @@ export const ManageInstalledVersion = ({
<div className={styles.manageInstalledVersion}>
{latestVersion && (
<>
<Button primary onClick={handleUpdate}>
{installedApp &&
semverGt(latestVersion, installedApp.version)
<Button primary onClick={handleInstall}>
{canUpdate
? i18n.t('Update to latest version')
: i18n.t('Install')}
</Button>
Expand Down

0 comments on commit f212260

Please sign in to comment.