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' ;
5
4
import * as ReactDOM from '@theia/core/shared/react-dom' ;
6
5
import ReactMarkdown from 'react-markdown' ;
7
- import { ProgressInfo , UpdateInfo } from '../../../common/protocol/ide-updater' ;
6
+ import {
7
+ UpdateInfo ,
8
+ UpdateProgress ,
9
+ } from '../../../common/protocol/ide-updater' ;
8
10
import ProgressBar from '../../components/ProgressBar' ;
9
11
10
12
export type IDEUpdaterComponentProps = {
11
13
updateInfo : UpdateInfo ;
12
- windowService : WindowService ;
13
- downloadFinished ?: boolean ;
14
- downloadStarted ?: boolean ;
15
- progress ?: ProgressInfo ;
16
- error ?: Error ;
17
- onDownload : ( ) => void ;
18
- onClose : ( ) => void ;
19
- onSkipVersion : ( ) => void ;
20
- onCloseAndInstall : ( ) => void ;
14
+ updateProgress : UpdateProgress ;
21
15
} ;
22
16
23
17
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,
18
+ updateInfo,
19
+ updateProgress : {
20
+ downloadStarted = false ,
21
+ downloadFinished = false ,
22
+ progressInfo,
23
+ error,
24
+ } ,
34
25
} : IDEUpdaterComponentProps ) : React . ReactElement => {
35
- const changelogDivRef = React . useRef ( ) as React . MutableRefObject <
36
- HTMLDivElement
37
- > ;
26
+ const { version , releaseNotes } = updateInfo ;
27
+ const changelogDivRef =
28
+ React . useRef ( ) as React . MutableRefObject < HTMLDivElement > ;
38
29
React . useEffect ( ( ) => {
39
- if ( ! ! releaseNotes ) {
30
+ if ( ! ! releaseNotes && changelogDivRef . current ) {
40
31
let changelog : string ;
41
32
if ( typeof releaseNotes === 'string' ) changelog = releaseNotes ;
42
33
else
@@ -58,12 +49,7 @@ export const IDEUpdaterComponent = ({
58
49
changelogDivRef . current
59
50
) ;
60
51
}
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
- ) ;
52
+ } , [ updateInfo ] ) ;
67
53
68
54
const DownloadCompleted : ( ) => React . ReactElement = ( ) => (
69
55
< div className = "ide-updater-dialog--downloaded" >
@@ -80,19 +66,6 @@ export const IDEUpdaterComponent = ({
80
66
'Close the software and install the update on your machine.'
81
67
) }
82
68
</ 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
69
</ div >
97
70
) ;
98
71
@@ -104,7 +77,7 @@ export const IDEUpdaterComponent = ({
104
77
'Downloading the latest version of the Arduino IDE.'
105
78
) }
106
79
</ div >
107
- < ProgressBar percent = { progress ?. percent } showPercentage />
80
+ < ProgressBar percent = { progressInfo ?. percent } showPercentage />
108
81
</ div >
109
82
) ;
110
83
@@ -130,46 +103,14 @@ export const IDEUpdaterComponent = ({
130
103
) }
131
104
</ div >
132
105
{ releaseNotes && (
133
- < div className = "dialogRow" >
134
- < div className = "changelog-container " ref = { changelogDivRef } />
106
+ < div className = "dialogRow changelog-container " >
107
+ < div className = "changelog" ref = { changelogDivRef } />
135
108
</ div >
136
109
) }
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
110
</ div >
159
111
</ div >
160
112
) ;
161
113
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
114
const GoToDownloadPage : ( ) => React . ReactElement = ( ) => (
174
115
< div className = "ide-updater-dialog--go-to-download-page" >
175
116
< div >
@@ -178,19 +119,6 @@ export const IDEUpdaterComponent = ({
178
119
"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
120
) }
180
121
</ 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
122
</ div >
195
123
) ;
196
124
0 commit comments