1
- import { WindowService } from '@theia/core/lib/browser/window/window-service' ;
2
1
import { nls } from '@theia/core/lib/common' ;
3
2
import { shell } from 'electron' ;
4
3
import * as React from '@theia/core/shared/react' ;
@@ -7,36 +6,32 @@ import ReactMarkdown from 'react-markdown';
7
6
import { ProgressInfo , UpdateInfo } from '../../../common/protocol/ide-updater' ;
8
7
import ProgressBar from '../../components/ProgressBar' ;
9
8
10
- export type IDEUpdaterComponentProps = {
11
- updateInfo : UpdateInfo ;
12
- windowService : WindowService ;
9
+ export type UpdateProgress = {
10
+ progressInfo ?: ProgressInfo | undefined ;
13
11
downloadFinished ?: boolean ;
14
12
downloadStarted ?: boolean ;
15
- progress ?: ProgressInfo ;
16
13
error ?: Error ;
17
- onDownload : ( ) => void ;
18
- onClose : ( ) => void ;
19
- onSkipVersion : ( ) => void ;
20
- onCloseAndInstall : ( ) => void ;
14
+ } ;
15
+
16
+ export type IDEUpdaterComponentProps = {
17
+ updateInfo : UpdateInfo ;
18
+ updateProgress : UpdateProgress ;
21
19
} ;
22
20
23
21
export const IDEUpdaterComponent = ( {
24
- updateInfo : { version, releaseNotes } ,
25
- downloadStarted = false ,
26
- downloadFinished = false ,
27
- windowService,
28
- progress,
29
- error,
30
- onDownload,
31
- onClose,
32
- onSkipVersion,
33
- onCloseAndInstall,
22
+ updateInfo,
23
+ updateProgress : {
24
+ downloadStarted = false ,
25
+ downloadFinished = false ,
26
+ progressInfo,
27
+ error,
28
+ } ,
34
29
} : IDEUpdaterComponentProps ) : React . ReactElement => {
35
- const changelogDivRef = React . useRef ( ) as React . MutableRefObject <
36
- HTMLDivElement
37
- > ;
30
+ const { version , releaseNotes } = updateInfo ;
31
+ const changelogDivRef =
32
+ React . useRef ( ) as React . MutableRefObject < HTMLDivElement > ;
38
33
React . useEffect ( ( ) => {
39
- if ( ! ! releaseNotes ) {
34
+ if ( ! ! releaseNotes && changelogDivRef . current ) {
40
35
let changelog : string ;
41
36
if ( typeof releaseNotes === 'string' ) changelog = releaseNotes ;
42
37
else
@@ -58,12 +53,7 @@ export const IDEUpdaterComponent = ({
58
53
changelogDivRef . current
59
54
) ;
60
55
}
61
- } , [ releaseNotes ] ) ;
62
- const closeButton = (
63
- < button onClick = { onClose } type = "button" className = "theia-button secondary" >
64
- { nls . localize ( 'arduino/ide-updater/notNowButton' , 'Not now' ) }
65
- </ button >
66
- ) ;
56
+ } , [ updateInfo ] ) ;
67
57
68
58
const DownloadCompleted : ( ) => React . ReactElement = ( ) => (
69
59
< div className = "ide-updater-dialog--downloaded" >
@@ -80,19 +70,6 @@ export const IDEUpdaterComponent = ({
80
70
'Close the software and install the update on your machine.'
81
71
) }
82
72
</ 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
73
</ div >
97
74
) ;
98
75
@@ -104,7 +81,7 @@ export const IDEUpdaterComponent = ({
104
81
'Downloading the latest version of the Arduino IDE.'
105
82
) }
106
83
</ div >
107
- < ProgressBar percent = { progress ?. percent } showPercentage />
84
+ < ProgressBar percent = { progressInfo ?. percent } showPercentage />
108
85
</ div >
109
86
) ;
110
87
@@ -130,46 +107,14 @@ export const IDEUpdaterComponent = ({
130
107
) }
131
108
</ div >
132
109
{ releaseNotes && (
133
- < div className = "dialogRow" >
134
- < div className = "changelog-container " ref = { changelogDivRef } />
110
+ < div className = "dialogRow changelog-container " >
111
+ < div className = "changelog" ref = { changelogDivRef } />
135
112
</ div >
136
113
) }
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'
146
- ) }
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 >
157
- </ div >
158
114
</ div >
159
115
</ div >
160
116
) ;
161
117
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
118
const GoToDownloadPage : ( ) => React . ReactElement = ( ) => (
174
119
< div className = "ide-updater-dialog--go-to-download-page" >
175
120
< div >
@@ -178,19 +123,6 @@ export const IDEUpdaterComponent = ({
178
123
"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
124
) }
180
125
</ 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
126
</ div >
195
127
) ;
196
128
0 commit comments