From 11942b1d08285aad439fd40a4a4806815e740cad Mon Sep 17 00:00:00 2001 From: Oskar Nyberg Date: Wed, 27 Sep 2023 11:06:08 +0200 Subject: [PATCH] Add platform to download urls --- gui/src/config.json | 3 +-- gui/src/renderer/components/ProblemReport.tsx | 4 ++-- gui/src/renderer/components/Settings.tsx | 11 +++++----- .../notifications/unsupported-version.ts | 6 ++--- .../shared/notifications/update-available.ts | 6 ++--- gui/src/shared/version.ts | 22 +++++++++++++++++++ 6 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 gui/src/shared/version.ts diff --git a/gui/src/config.json b/gui/src/config.json index 117d99cbeb62..b5d454fe4aa7 100644 --- a/gui/src/config.json +++ b/gui/src/config.json @@ -4,8 +4,7 @@ "purchase": "https://mullvad.net/account/", "faq": "https://mullvad.net/help/tag/mullvad-app/", "privacyGuide": "https://mullvad.net/help/first-steps-towards-online-privacy/", - "download": "https://mullvad.net/download/", - "betaDownload": "https://mullvad.net/download/beta" + "download": "https://mullvad.net/download/vpn/" }, "colors": { "darkBlue": "rgb(25, 46, 69)", diff --git a/gui/src/renderer/components/ProblemReport.tsx b/gui/src/renderer/components/ProblemReport.tsx index 907f9cb9e4cf..3a0a9bbd0e9e 100644 --- a/gui/src/renderer/components/ProblemReport.tsx +++ b/gui/src/renderer/components/ProblemReport.tsx @@ -12,8 +12,8 @@ import { useState, } from 'react'; -import { links } from '../../config.json'; import { messages } from '../../shared/gettext'; +import { getDownloadUrl } from '../../shared/version'; import { useAppContext } from '../context'; import useActions from '../lib/actionsHook'; import { useHistory } from '../lib/history'; @@ -326,7 +326,7 @@ function OutdatedVersionWarningDialog() { }, []); const openDownloadLink = useCallback(async () => { - await openUrl(suggestedIsBeta ? links.betaDownload : links.download); + await openUrl(getDownloadUrl(suggestedIsBeta)); }, [suggestedIsBeta]); const onClose = useCallback(() => history.pop(), [history.pop]); diff --git a/gui/src/renderer/components/Settings.tsx b/gui/src/renderer/components/Settings.tsx index 01becd27b657..26d40fb134a0 100644 --- a/gui/src/renderer/components/Settings.tsx +++ b/gui/src/renderer/components/Settings.tsx @@ -1,7 +1,8 @@ import { useCallback } from 'react'; -import { colors, links } from '../../config.json'; +import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; +import { getDownloadUrl } from '../../shared/version'; import { useAppContext } from '../context'; import { useHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; @@ -148,10 +149,10 @@ function AppVersionButton() { const isOffline = useSelector((state) => state.connection.isBlocked); const { openUrl } = useAppContext(); - const openDownloadLink = useCallback( - () => openUrl(suggestedIsBeta ? links.betaDownload : links.download), - [openUrl, suggestedIsBeta], - ); + const openDownloadLink = useCallback(() => openUrl(getDownloadUrl(suggestedIsBeta)), [ + openUrl, + suggestedIsBeta, + ]); let icon; let footer; diff --git a/gui/src/shared/notifications/unsupported-version.ts b/gui/src/shared/notifications/unsupported-version.ts index 8c2f87460b4d..9d41bc268cdb 100644 --- a/gui/src/shared/notifications/unsupported-version.ts +++ b/gui/src/shared/notifications/unsupported-version.ts @@ -1,5 +1,5 @@ -import { links } from '../../config.json'; import { messages } from '../../shared/gettext'; +import { getDownloadUrl } from '../version'; import { InAppNotification, InAppNotificationProvider, @@ -31,7 +31,7 @@ export class UnsupportedVersionNotificationProvider severity: SystemNotificationSeverityType.high, action: { type: 'open-url', - url: this.context.suggestedIsBeta ? links.betaDownload : links.download, + url: getDownloadUrl(this.context.suggestedIsBeta ?? false), text: messages.pgettext('notifications', 'Upgrade'), }, presentOnce: { value: true, name: this.constructor.name }, @@ -46,7 +46,7 @@ export class UnsupportedVersionNotificationProvider subtitle: this.getMessage(), action: { type: 'open-url', - url: this.context.suggestedIsBeta ? links.betaDownload : links.download, + url: getDownloadUrl(this.context.suggestedIsBeta ?? false), }, }; } diff --git a/gui/src/shared/notifications/update-available.ts b/gui/src/shared/notifications/update-available.ts index 0394ef15a5b5..6f63bafd89c8 100644 --- a/gui/src/shared/notifications/update-available.ts +++ b/gui/src/shared/notifications/update-available.ts @@ -1,7 +1,7 @@ import { sprintf } from 'sprintf-js'; -import { links } from '../../config.json'; import { messages } from '../../shared/gettext'; +import { getDownloadUrl } from '../version'; import { InAppNotification, InAppNotificationProvider, @@ -33,7 +33,7 @@ export class UpdateAvailableNotificationProvider subtitle: this.inAppMessage(), action: { type: 'open-url', - url: this.context.suggestedIsBeta ? links.betaDownload : links.download, + url: getDownloadUrl(this.context.suggestedIsBeta ?? false), }, }; } @@ -45,7 +45,7 @@ export class UpdateAvailableNotificationProvider severity: SystemNotificationSeverityType.medium, action: { type: 'open-url', - url: this.context.suggestedIsBeta ? links.betaDownload : links.download, + url: getDownloadUrl(this.context.suggestedIsBeta ?? false), text: messages.pgettext('notifications', 'Upgrade'), }, presentOnce: { value: true, name: this.constructor.name }, diff --git a/gui/src/shared/version.ts b/gui/src/shared/version.ts new file mode 100644 index 000000000000..dc87afaae0ab --- /dev/null +++ b/gui/src/shared/version.ts @@ -0,0 +1,22 @@ +import { links } from '../config.json'; + +export function getDownloadUrl(suggestedIsBeta: boolean): string { + let url = links.download; + switch (process.platform ?? window.env.platform) { + case 'win32': + url += 'windows/'; + break; + case 'linux': + url += 'linux/'; + break; + case 'darwin': + url += 'macos/'; + break; + } + + if (suggestedIsBeta) { + url += 'beta/'; + } + + return url; +}