From a5a6a0b611fb7939b7cff73cee819adf73c49914 Mon Sep 17 00:00:00 2001 From: Alberto Iannaccone Date: Tue, 1 Mar 2022 08:24:29 +0000 Subject: [PATCH] Go to download page when automatic update fails (#871) * add preference to set a custom update url * go to download page when update fails * fix i18n check --- .../ide-updater/ide-updater-component.tsx | 226 +++++++++++------- .../ide-updater/ide-updater-dialog.tsx | 6 + .../src/browser/style/ide-updater-dialog.css | 11 + .../ide-updater/ide-updater-impl.ts | 2 +- i18n/en.json | 4 +- 5 files changed, 160 insertions(+), 89 deletions(-) diff --git a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx index 3c1c4911..0d2fa3a4 100644 --- a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx +++ b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx @@ -1,3 +1,4 @@ +import { WindowService } from '@theia/core/lib/browser/window/window-service'; import { nls } from '@theia/core/lib/common'; import { shell } from 'electron'; import * as React from 'react'; @@ -8,6 +9,7 @@ import ProgressBar from '../../components/ProgressBar'; export type IDEUpdaterComponentProps = { updateInfo: UpdateInfo; + windowService: WindowService; downloadFinished?: boolean; downloadStarted?: boolean; progress?: ProgressInfo; @@ -22,6 +24,7 @@ export const IDEUpdaterComponent = ({ updateInfo: { version, releaseNotes }, downloadStarted = false, downloadFinished = false, + windowService, progress, error, onDownload, @@ -62,98 +65,147 @@ export const IDEUpdaterComponent = ({ ); + const DownloadCompleted: () => React.ReactElement = () => ( +
+
+ {nls.localize( + 'arduino/ide-updater/versionDownloaded', + 'Arduino IDE {0} has been downloaded.', + version + )} +
+
+ {nls.localize( + 'arduino/ide-updater/closeToInstallNotice', + 'Close the software and install the update on your machine.' + )} +
+
+ {closeButton} + +
+
+ ); + + const DownloadStarted: () => React.ReactElement = () => ( +
+
+ {nls.localize( + 'arduino/ide-updater/downloadingNotice', + 'Downloading the latest version of the Arduino IDE.' + )} +
+ +
+ ); + + const PreDownload: () => React.ReactElement = () => ( +
+
+
+
+
+
+
+ {nls.localize( + 'arduino/ide-updater/updateAvailable', + 'Update Available' + )} +
+
+
+ {nls.localize( + 'arduino/ide-updater/newVersionAvailable', + 'A new version of Arduino IDE ({0}) is available for download.', + version + )} +
+ {releaseNotes && ( +
+
+
+ )} +
+ +
+ {closeButton} + +
+
+
+ ); + + const onGoToDownloadClick = ( + event: React.SyntheticEvent + ) => { + const { target } = event.nativeEvent; + if (target instanceof HTMLAnchorElement) { + event.nativeEvent.preventDefault(); + windowService.openNewWindow(target.href, { external: true }); + onClose(); + } + }; + + const GoToDownloadPage: () => React.ReactElement = () => ( +
+
+ {nls.localize( + 'arduino/ide-updater/goToDownloadPage', + "An update for the Arduino IDE is available, but we're not able to download and install it automatically. Please go to the download page and download the latest version from there." + )} +
+
+ {closeButton} + + {nls.localize( + 'arduino/ide-updater/goToDownloadButton', + 'Go To Download' + )} + +
+
+ ); + return (
- {downloadFinished ? ( -
-
- {nls.localize( - 'arduino/ide-updater/versionDownloaded', - 'Arduino IDE {0} has been downloaded.', - version - )} -
-
- {nls.localize( - 'arduino/ide-updater/closeToInstallNotice', - 'Close the software and install the update on your machine.' - )} -
-
- {closeButton} - -
-
+ {!!error ? ( + + ) : downloadFinished ? ( + ) : downloadStarted ? ( -
-
- {nls.localize( - 'arduino/ide-updater/downloadingNotice', - 'Downloading the latest version of the Arduino IDE.' - )} -
- -
+ ) : ( -
-
-
-
-
-
-
- {nls.localize( - 'arduino/ide-updater/updateAvailable', - 'Update Available' - )} -
-
-
- {nls.localize( - 'arduino/ide-updater/newVersionAvailable', - 'A new version of Arduino IDE ({0}) is available for download.', - version - )} -
- {releaseNotes && ( -
-
-
- )} -
- -
- {closeButton} - -
-
-
+ )} - {!!error &&
{error}
} + {/* {!!error &&
{error}
} */}
); }; diff --git a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx index 56b8c84f..dbba6df9 100644 --- a/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx +++ b/arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx @@ -15,6 +15,7 @@ import { } from '../../../common/protocol/ide-updater'; import { LocalStorageService } from '@theia/core/lib/browser'; import { SKIP_IDE_VERSION } from '../../arduino-frontend-contribution'; +import { WindowService } from '@theia/core/lib/browser/window/window-service'; @injectable() export class IDEUpdaterDialogWidget extends ReactWidget { @@ -35,6 +36,9 @@ export class IDEUpdaterDialogWidget extends ReactWidget { @inject(LocalStorageService) protected readonly localStorageService: LocalStorageService; + @inject(WindowService) + protected windowService: WindowService; + init(updateInfo: UpdateInfo, onClose: () => void): void { this.updateInfo = updateInfo; this.progressInfo = undefined; @@ -92,9 +96,11 @@ export class IDEUpdaterDialogWidget extends ReactWidget {
c.notifyError(e)); } } diff --git a/i18n/en.json b/i18n/en.json index 614dbdf2..c3c20371 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -264,7 +264,9 @@ "updateAvailable": "Update Available", "newVersionAvailable": "A new version of Arduino IDE ({0}) is available for download.", "skipVersionButton": "Skip Version", - "downloadButton": "Download" + "downloadButton": "Download", + "goToDownloadPage": "An update for the Arduino IDE is available, but we're not able to download and install it automatically. Please go to the download page and download the latest version from there.", + "goToDownloadButton": "Go To Download" }, "updater": { "ideUpdaterDialog": "Software Update"