diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index f4ebbb2f6..af90e2035 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -280,7 +280,8 @@ export class ArduinoFrontendContribution } this.updaterService.init( - this.arduinoPreferences.get('arduino.ide.updateChannel') + this.arduinoPreferences.get('arduino.ide.updateChannel'), + this.arduinoPreferences.get('arduino.ide.updateBaseUrl') ); this.updater.checkForUpdates(true).then(async (updateInfo) => { if (!updateInfo) return; diff --git a/arduino-ide-extension/src/browser/arduino-preferences.ts b/arduino-ide-extension/src/browser/arduino-preferences.ts index 910d724bc..ba6bc83c4 100644 --- a/arduino-ide-extension/src/browser/arduino-preferences.ts +++ b/arduino-ide-extension/src/browser/arduino-preferences.ts @@ -78,6 +78,14 @@ export const ArduinoConfigSchema: PreferenceSchema = { "Release channel to get updated from. 'stable' is the stable release, 'nightly' is the latest development build." ), }, + 'arduino.ide.updateBaseUrl': { + type: 'string', + default: 'https://downloads.arduino.cc/arduino-ide', + description: nls.localize( + 'arduino/preferences/ide.updateBaseUrl', + `The base URL where to download updates from. Defaults to 'https://downloads.arduino.cc/arduino-ide'` + ), + }, 'arduino.board.certificates': { type: 'string', description: nls.localize( @@ -178,6 +186,7 @@ export interface ArduinoConfiguration { 'arduino.window.autoScale': boolean; 'arduino.window.zoomLevel': number; 'arduino.ide.updateChannel': UpdateChannel; + 'arduino.ide.updateBaseUrl': string; 'arduino.board.certificates': string; 'arduino.sketchbook.showAllFiles': boolean; 'arduino.cloud.enabled': boolean; 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 3c1c4911e..0d2fa3a49 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 = ({ ); - return ( -
- {downloadFinished ? ( -
-
- {nls.localize( - 'arduino/ide-updater/versionDownloaded', - 'Arduino IDE {0} has been downloaded.', - version - )} -
-
+ 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/closeToInstallNotice', - 'Close the software and install the update on your machine.' + 'arduino/ide-updater/updateAvailable', + 'Update Available' )}
-
- {closeButton} - -
- ) : downloadStarted ? ( -
-
- {nls.localize( - 'arduino/ide-updater/downloadingNotice', - 'Downloading the latest version of the Arduino IDE.' - )} -
- +
+ {nls.localize( + 'arduino/ide-updater/newVersionAvailable', + 'A new version of Arduino IDE ({0}) is available for download.', + version + )}
- ) : ( -
-
-
+ {releaseNotes && ( +
+
-
-
-
- {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} - -
-
+ +
+ {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." + )} +
+ +
+ ); + + return ( +
+ {!!error ? ( + + ) : downloadFinished ? ( + + ) : downloadStarted ? ( + + ) : ( + )} - {!!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 56b8c84f5..dbba6df96 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 {
{ - init(channel: UpdateChannel): void; + init(channel: UpdateChannel, baseUrl: string): void; checkForUpdates(initialCheck?: boolean): Promise; downloadUpdate(): Promise; quitAndInstall(): void; diff --git a/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts b/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts index 06e840999..3a0627546 100644 --- a/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts +++ b/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts @@ -8,7 +8,6 @@ import { } from '../../common/protocol/ide-updater'; const CHANGELOG_BASE_URL = 'https://downloads.arduino.cc/arduino-ide/changelog'; -const IDE_DOWNLOAD_BASE_URL = 'https://downloads.arduino.cc/arduino-ide'; @injectable() export class IDEUpdaterImpl implements IDEUpdater { @@ -18,14 +17,12 @@ export class IDEUpdaterImpl implements IDEUpdater { protected theiaFEClient?: IDEUpdaterClient; protected clients: Array = []; - init(channel: UpdateChannel): void { + init(channel: UpdateChannel, baseUrl: string): void { this.updater.autoDownload = false; this.updater.channel = channel; this.updater.setFeedURL({ provider: 'generic', - url: `${IDE_DOWNLOAD_BASE_URL}/${ - channel === UpdateChannel.Nightly ? 'nightly' : '' - }`, + url: `${baseUrl}/${channel === UpdateChannel.Nightly ? 'nightly' : ''}`, channel, }); @@ -107,7 +104,7 @@ export class IDEUpdaterImpl implements IDEUpdater { await this.updater.downloadUpdate(this.cancellationToken); } catch (e) { if (e.message === 'cancelled') return; - throw e; + this.clients.forEach((c) => c.notifyError(e)); } } diff --git a/i18n/en.json b/i18n/en.json index 614dbdf2b..c3c20371f 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"