mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-08 11:56:36 +00:00
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
This commit is contained in:
parent
2a27a14a68
commit
a5a6a0b611
@ -1,3 +1,4 @@
|
|||||||
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
import { nls } from '@theia/core/lib/common';
|
import { nls } from '@theia/core/lib/common';
|
||||||
import { shell } from 'electron';
|
import { shell } from 'electron';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
@ -8,6 +9,7 @@ import ProgressBar from '../../components/ProgressBar';
|
|||||||
|
|
||||||
export type IDEUpdaterComponentProps = {
|
export type IDEUpdaterComponentProps = {
|
||||||
updateInfo: UpdateInfo;
|
updateInfo: UpdateInfo;
|
||||||
|
windowService: WindowService;
|
||||||
downloadFinished?: boolean;
|
downloadFinished?: boolean;
|
||||||
downloadStarted?: boolean;
|
downloadStarted?: boolean;
|
||||||
progress?: ProgressInfo;
|
progress?: ProgressInfo;
|
||||||
@ -22,6 +24,7 @@ export const IDEUpdaterComponent = ({
|
|||||||
updateInfo: { version, releaseNotes },
|
updateInfo: { version, releaseNotes },
|
||||||
downloadStarted = false,
|
downloadStarted = false,
|
||||||
downloadFinished = false,
|
downloadFinished = false,
|
||||||
|
windowService,
|
||||||
progress,
|
progress,
|
||||||
error,
|
error,
|
||||||
onDownload,
|
onDownload,
|
||||||
@ -62,9 +65,7 @@ export const IDEUpdaterComponent = ({
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
const DownloadCompleted: () => React.ReactElement = () => (
|
||||||
<div className="ide-updater-dialog--content">
|
|
||||||
{downloadFinished ? (
|
|
||||||
<div className="ide-updater-dialog--downloaded">
|
<div className="ide-updater-dialog--downloaded">
|
||||||
<div>
|
<div>
|
||||||
{nls.localize(
|
{nls.localize(
|
||||||
@ -93,7 +94,9 @@ export const IDEUpdaterComponent = ({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : downloadStarted ? (
|
);
|
||||||
|
|
||||||
|
const DownloadStarted: () => React.ReactElement = () => (
|
||||||
<div className="ide-updater-dialog--downloading">
|
<div className="ide-updater-dialog--downloading">
|
||||||
<div>
|
<div>
|
||||||
{nls.localize(
|
{nls.localize(
|
||||||
@ -103,7 +106,9 @@ export const IDEUpdaterComponent = ({
|
|||||||
</div>
|
</div>
|
||||||
<ProgressBar percent={progress?.percent} showPercentage />
|
<ProgressBar percent={progress?.percent} showPercentage />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
);
|
||||||
|
|
||||||
|
const PreDownload: () => React.ReactElement = () => (
|
||||||
<div className="ide-updater-dialog--pre-download">
|
<div className="ide-updater-dialog--pre-download">
|
||||||
<div className="ide-updater-dialog--logo-container">
|
<div className="ide-updater-dialog--logo-container">
|
||||||
<div className="ide-updater-dialog--logo"></div>
|
<div className="ide-updater-dialog--logo"></div>
|
||||||
@ -152,8 +157,55 @@ export const IDEUpdaterComponent = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const onGoToDownloadClick = (
|
||||||
|
event: React.SyntheticEvent<HTMLAnchorElement, Event>
|
||||||
|
) => {
|
||||||
|
const { target } = event.nativeEvent;
|
||||||
|
if (target instanceof HTMLAnchorElement) {
|
||||||
|
event.nativeEvent.preventDefault();
|
||||||
|
windowService.openNewWindow(target.href, { external: true });
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const GoToDownloadPage: () => React.ReactElement = () => (
|
||||||
|
<div className="ide-updater-dialog--go-to-download-page">
|
||||||
|
<div>
|
||||||
|
{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."
|
||||||
)}
|
)}
|
||||||
{!!error && <div className="error-container">{error}</div>}
|
</div>
|
||||||
|
<div className="buttons-container">
|
||||||
|
{closeButton}
|
||||||
|
<a
|
||||||
|
className="theia-button primary"
|
||||||
|
href="https://www.arduino.cc/en/software#experimental-software"
|
||||||
|
onClick={onGoToDownloadClick}
|
||||||
|
>
|
||||||
|
{nls.localize(
|
||||||
|
'arduino/ide-updater/goToDownloadButton',
|
||||||
|
'Go To Download'
|
||||||
|
)}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ide-updater-dialog--content">
|
||||||
|
{!!error ? (
|
||||||
|
<GoToDownloadPage />
|
||||||
|
) : downloadFinished ? (
|
||||||
|
<DownloadCompleted />
|
||||||
|
) : downloadStarted ? (
|
||||||
|
<DownloadStarted />
|
||||||
|
) : (
|
||||||
|
<PreDownload />
|
||||||
|
)}
|
||||||
|
{/* {!!error && <div className="error-container">{error}</div>} */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@ import {
|
|||||||
} from '../../../common/protocol/ide-updater';
|
} from '../../../common/protocol/ide-updater';
|
||||||
import { LocalStorageService } from '@theia/core/lib/browser';
|
import { LocalStorageService } from '@theia/core/lib/browser';
|
||||||
import { SKIP_IDE_VERSION } from '../../arduino-frontend-contribution';
|
import { SKIP_IDE_VERSION } from '../../arduino-frontend-contribution';
|
||||||
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class IDEUpdaterDialogWidget extends ReactWidget {
|
export class IDEUpdaterDialogWidget extends ReactWidget {
|
||||||
@ -35,6 +36,9 @@ export class IDEUpdaterDialogWidget extends ReactWidget {
|
|||||||
@inject(LocalStorageService)
|
@inject(LocalStorageService)
|
||||||
protected readonly localStorageService: LocalStorageService;
|
protected readonly localStorageService: LocalStorageService;
|
||||||
|
|
||||||
|
@inject(WindowService)
|
||||||
|
protected windowService: WindowService;
|
||||||
|
|
||||||
init(updateInfo: UpdateInfo, onClose: () => void): void {
|
init(updateInfo: UpdateInfo, onClose: () => void): void {
|
||||||
this.updateInfo = updateInfo;
|
this.updateInfo = updateInfo;
|
||||||
this.progressInfo = undefined;
|
this.progressInfo = undefined;
|
||||||
@ -92,9 +96,11 @@ export class IDEUpdaterDialogWidget extends ReactWidget {
|
|||||||
<form>
|
<form>
|
||||||
<IDEUpdaterComponent
|
<IDEUpdaterComponent
|
||||||
updateInfo={this.updateInfo}
|
updateInfo={this.updateInfo}
|
||||||
|
windowService={this.windowService}
|
||||||
downloadStarted={this.downloadStarted}
|
downloadStarted={this.downloadStarted}
|
||||||
downloadFinished={this.downloadFinished}
|
downloadFinished={this.downloadFinished}
|
||||||
progress={this.progressInfo}
|
progress={this.progressInfo}
|
||||||
|
error={this.error}
|
||||||
onClose={this.close.bind(this)}
|
onClose={this.close.bind(this)}
|
||||||
onSkipVersion={this.onSkipVersion.bind(this)}
|
onSkipVersion={this.onSkipVersion.bind(this)}
|
||||||
onDownload={this.onDownload.bind(this)}
|
onDownload={this.onDownload.bind(this)}
|
||||||
|
@ -62,6 +62,17 @@
|
|||||||
margin-top: 28px;
|
margin-top: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ide-updater-dialog .buttons-container a.theia-button {
|
||||||
|
text-decoration: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ide-updater-dialog .buttons-container a.theia-button:hover {
|
||||||
|
color: var(--theia-button-foreground);
|
||||||
|
}
|
||||||
|
|
||||||
.ide-updater-dialog .buttons-container .push {
|
.ide-updater-dialog .buttons-container .push {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ export class IDEUpdaterImpl implements IDEUpdater {
|
|||||||
await this.updater.downloadUpdate(this.cancellationToken);
|
await this.updater.downloadUpdate(this.cancellationToken);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.message === 'cancelled') return;
|
if (e.message === 'cancelled') return;
|
||||||
throw e;
|
this.clients.forEach((c) => c.notifyError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,9 @@
|
|||||||
"updateAvailable": "Update Available",
|
"updateAvailable": "Update Available",
|
||||||
"newVersionAvailable": "A new version of Arduino IDE ({0}) is available for download.",
|
"newVersionAvailable": "A new version of Arduino IDE ({0}) is available for download.",
|
||||||
"skipVersionButton": "Skip Version",
|
"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": {
|
"updater": {
|
||||||
"ideUpdaterDialog": "Software Update"
|
"ideUpdaterDialog": "Software Update"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user