1
+ import { WindowService } from '@theia/core/lib/browser/window/window-service' ;
1
2
import { nls } from '@theia/core/lib/common' ;
2
3
import { shell } from 'electron' ;
3
4
import * as React from 'react' ;
@@ -8,6 +9,7 @@ import ProgressBar from '../../components/ProgressBar';
8
9
9
10
export type IDEUpdaterComponentProps = {
10
11
updateInfo : UpdateInfo ;
12
+ windowService : WindowService ;
11
13
downloadFinished ?: boolean ;
12
14
downloadStarted ?: boolean ;
13
15
progress ?: ProgressInfo ;
@@ -22,6 +24,7 @@ export const IDEUpdaterComponent = ({
22
24
updateInfo : { version, releaseNotes } ,
23
25
downloadStarted = false ,
24
26
downloadFinished = false ,
27
+ windowService,
25
28
progress,
26
29
error,
27
30
onDownload,
@@ -62,98 +65,147 @@ export const IDEUpdaterComponent = ({
62
65
</ button >
63
66
) ;
64
67
65
- return (
66
- < div className = "ide-updater-dialog--content" >
67
- { downloadFinished ? (
68
- < div className = "ide-updater-dialog--downloaded" >
69
- < div >
70
- { nls . localize (
71
- 'arduino/ide-updater/versionDownloaded' ,
72
- 'Arduino IDE {0} has been downloaded.' ,
73
- version
74
- ) }
75
- </ div >
76
- < div >
68
+ const DownloadCompleted : ( ) => React . ReactElement = ( ) => (
69
+ < div className = "ide-updater-dialog--downloaded" >
70
+ < div >
71
+ { nls . localize (
72
+ 'arduino/ide-updater/versionDownloaded' ,
73
+ 'Arduino IDE {0} has been downloaded.' ,
74
+ version
75
+ ) }
76
+ </ div >
77
+ < div >
78
+ { nls . localize (
79
+ 'arduino/ide-updater/closeToInstallNotice' ,
80
+ 'Close the software and install the update on your machine.'
81
+ ) }
82
+ </ div >
83
+ < div className = "buttons-container" >
84
+ { closeButton }
85
+ < button
86
+ onClick = { onCloseAndInstall }
87
+ type = "button"
88
+ className = "theia-button close-and-install"
89
+ >
90
+ { nls . localize (
91
+ 'arduino/ide-updater/closeAndInstallButton' ,
92
+ 'Close and Install'
93
+ ) }
94
+ </ button >
95
+ </ div >
96
+ </ div >
97
+ ) ;
98
+
99
+ const DownloadStarted : ( ) => React . ReactElement = ( ) => (
100
+ < div className = "ide-updater-dialog--downloading" >
101
+ < div >
102
+ { nls . localize (
103
+ 'arduino/ide-updater/downloadingNotice' ,
104
+ 'Downloading the latest version of the Arduino IDE.'
105
+ ) }
106
+ </ div >
107
+ < ProgressBar percent = { progress ?. percent } showPercentage />
108
+ </ div >
109
+ ) ;
110
+
111
+ const PreDownload : ( ) => React . ReactElement = ( ) => (
112
+ < div className = "ide-updater-dialog--pre-download" >
113
+ < div className = "ide-updater-dialog--logo-container" >
114
+ < div className = "ide-updater-dialog--logo" > </ div >
115
+ </ div >
116
+ < div className = "ide-updater-dialog--new-version-text dialogSection" >
117
+ < div className = "dialogRow" >
118
+ < div className = "bold" >
77
119
{ nls . localize (
78
- 'arduino/ide-updater/closeToInstallNotice ' ,
79
- 'Close the software and install the update on your machine. '
120
+ 'arduino/ide-updater/updateAvailable ' ,
121
+ 'Update Available '
80
122
) }
81
123
</ div >
82
- < div className = "buttons-container" >
83
- { closeButton }
84
- < button
85
- onClick = { onCloseAndInstall }
86
- type = "button"
87
- className = "theia-button close-and-install"
88
- >
89
- { nls . localize (
90
- 'arduino/ide-updater/closeAndInstallButton' ,
91
- 'Close and Install'
92
- ) }
93
- </ button >
94
- </ div >
95
124
</ div >
96
- ) : downloadStarted ? (
97
- < div className = "ide-updater-dialog--downloading" >
98
- < div >
99
- { nls . localize (
100
- 'arduino/ide-updater/downloadingNotice' ,
101
- 'Downloading the latest version of the Arduino IDE.'
102
- ) }
103
- </ div >
104
- < ProgressBar percent = { progress ?. percent } showPercentage />
125
+ < div className = "dialogRow" >
126
+ { nls . localize (
127
+ 'arduino/ide-updater/newVersionAvailable' ,
128
+ 'A new version of Arduino IDE ({0}) is available for download.' ,
129
+ version
130
+ ) }
105
131
</ div >
106
- ) : (
107
- < div className = "ide-updater-dialog--pre-download" >
108
- < div className = "ide-updater-dialog--logo-container" >
109
- < div className = "ide-updater-dialog--logo" > </ div >
132
+ { releaseNotes && (
133
+ < div className = "dialogRow" >
134
+ < div className = "changelog-container" ref = { changelogDivRef } />
110
135
</ div >
111
- < div className = "ide-updater-dialog--new-version-text dialogSection" >
112
- < div className = "dialogRow" >
113
- < div className = "bold" >
114
- { nls . localize (
115
- 'arduino/ide-updater/updateAvailable' ,
116
- 'Update Available'
117
- ) }
118
- </ div >
119
- </ div >
120
- < div className = "dialogRow" >
121
- { nls . localize (
122
- 'arduino/ide-updater/newVersionAvailable' ,
123
- 'A new version of Arduino IDE ({0}) is available for download.' ,
124
- version
125
- ) }
126
- </ div >
127
- { releaseNotes && (
128
- < div className = "dialogRow" >
129
- < div className = "changelog-container" ref = { changelogDivRef } />
130
- </ div >
136
+ ) }
137
+ < div className = "buttons-container" >
138
+ < button
139
+ onClick = { onSkipVersion }
140
+ type = "button"
141
+ className = "theia-button secondary skip-version"
142
+ >
143
+ { nls . localize (
144
+ 'arduino/ide-updater/skipVersionButton' ,
145
+ 'Skip Version'
131
146
) }
132
- < div className = "buttons-container" >
133
- < button
134
- onClick = { onSkipVersion }
135
- type = "button"
136
- className = "theia-button secondary skip-version"
137
- >
138
- { nls . localize (
139
- 'arduino/ide-updater/skipVersionButton' ,
140
- 'Skip Version'
141
- ) }
142
- </ button >
143
- < div className = "push" > </ div >
144
- { closeButton }
145
- < button
146
- onClick = { onDownload }
147
- type = "button"
148
- className = "theia-button primary"
149
- >
150
- { nls . localize ( 'arduino/ide-updater/downloadButton' , 'Download' ) }
151
- </ button >
152
- </ div >
153
- </ div >
147
+ </ button >
148
+ < div className = "push" > </ div >
149
+ { closeButton }
150
+ < button
151
+ onClick = { onDownload }
152
+ type = "button"
153
+ className = "theia-button primary"
154
+ >
155
+ { nls . localize ( 'arduino/ide-updater/downloadButton' , 'Download' ) }
156
+ </ button >
154
157
</ div >
158
+ </ div >
159
+ </ div >
160
+ ) ;
161
+
162
+ const onGoToDownloadClick = (
163
+ event : React . SyntheticEvent < HTMLAnchorElement , Event >
164
+ ) => {
165
+ const { target } = event . nativeEvent ;
166
+ if ( target instanceof HTMLAnchorElement ) {
167
+ event . nativeEvent . preventDefault ( ) ;
168
+ windowService . openNewWindow ( target . href , { external : true } ) ;
169
+ onClose ( ) ;
170
+ }
171
+ } ;
172
+
173
+ const GoToDownloadPage : ( ) => React . ReactElement = ( ) => (
174
+ < div className = "ide-updater-dialog--go-to-download-page" >
175
+ < div >
176
+ { nls . localize (
177
+ 'arduino/ide-updater/goToDownloadPage' ,
178
+ "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."
179
+ ) }
180
+ </ div >
181
+ < div className = "buttons-container" >
182
+ { closeButton }
183
+ < a
184
+ className = "theia-button primary"
185
+ href = "https://www.arduino.cc/en/software#experimental-software"
186
+ onClick = { onGoToDownloadClick }
187
+ >
188
+ { nls . localize (
189
+ 'arduino/ide-updater/goToDownloadButton' ,
190
+ 'Go To Download'
191
+ ) }
192
+ </ a >
193
+ </ div >
194
+ </ div >
195
+ ) ;
196
+
197
+ return (
198
+ < div className = "ide-updater-dialog--content" >
199
+ { ! ! error ? (
200
+ < GoToDownloadPage />
201
+ ) : downloadFinished ? (
202
+ < DownloadCompleted />
203
+ ) : downloadStarted ? (
204
+ < DownloadStarted />
205
+ ) : (
206
+ < PreDownload />
155
207
) }
156
- { ! ! error && < div className = "error-container" > { error } </ div > }
208
+ { /* { !!error && <div className="error-container">{error}</div> } */ }
157
209
</ div >
158
210
) ;
159
211
} ;
0 commit comments