@@ -5,10 +5,8 @@ import {
5
5
postConstruct ,
6
6
} from '@theia/core/shared/inversify' ;
7
7
import { DialogProps } from '@theia/core/lib/browser/dialogs' ;
8
- import { AbstractDialog } from '../../theia/dialogs/dialogs' ;
9
- import { Widget } from '@theia/core/shared/@phosphor/widgets' ;
8
+ import { ReactDialog } from '../../theia/dialogs/dialogs' ;
10
9
import { Message } from '@theia/core/shared/@phosphor/messaging' ;
11
- import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget' ;
12
10
import {
13
11
AvailableBoard ,
14
12
BoardsServiceProvider ,
@@ -23,26 +21,30 @@ import { Port } from '../../../common/protocol';
23
21
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
24
22
25
23
@injectable ( )
26
- export class UploadFirmwareDialogWidget extends ReactWidget {
27
- @inject ( BoardsServiceProvider )
28
- protected readonly boardsServiceClient : BoardsServiceProvider ;
24
+ export class UploadFirmwareDialogProps extends DialogProps { }
29
25
26
+ @injectable ( )
27
+ export class UploadFirmwareDialog extends ReactDialog < void > {
28
+ @inject ( BoardsServiceProvider )
29
+ private readonly boardsServiceClient : BoardsServiceProvider ;
30
30
@inject ( ArduinoFirmwareUploader )
31
- protected readonly arduinoFirmwareUploader : ArduinoFirmwareUploader ;
32
-
31
+ private readonly arduinoFirmwareUploader : ArduinoFirmwareUploader ;
33
32
@inject ( FrontendApplicationStateService )
34
33
private readonly appStatusService : FrontendApplicationStateService ;
35
34
36
- protected updatableFqbns : string [ ] = [ ] ;
37
- protected availableBoards : AvailableBoard [ ] = [ ] ;
38
- protected isOpen = new Object ( ) ;
39
-
40
- public busyCallback = ( busy : boolean ) => {
41
- return ;
42
- } ;
35
+ private updatableFqbns : string [ ] = [ ] ;
36
+ private availableBoards : AvailableBoard [ ] = [ ] ;
37
+ private isOpen = new Object ( ) ;
38
+ private busy = false ;
43
39
44
- constructor ( ) {
45
- super ( ) ;
40
+ constructor (
41
+ @inject ( UploadFirmwareDialogProps )
42
+ protected override readonly props : UploadFirmwareDialogProps
43
+ ) {
44
+ super ( { title : UploadFirmware . Commands . OPEN . label || '' } ) ;
45
+ this . node . id = 'firmware-uploader-dialog-container' ;
46
+ this . contentNode . classList . add ( 'firmware-uploader-dialog' ) ;
47
+ this . acceptButton = undefined ;
46
48
}
47
49
48
50
@postConstruct ( )
@@ -59,19 +61,11 @@ export class UploadFirmwareDialogWidget extends ReactWidget {
59
61
} ) ;
60
62
}
61
63
62
- protected flashFirmware ( firmware : FirmwareInfo , port : Port ) : Promise < any > {
63
- this . busyCallback ( true ) ;
64
- return this . arduinoFirmwareUploader
65
- . flash ( firmware , port )
66
- . finally ( ( ) => this . busyCallback ( false ) ) ;
67
- }
68
-
69
- protected override onCloseRequest ( msg : Message ) : void {
70
- super . onCloseRequest ( msg ) ;
71
- this . isOpen = new Object ( ) ;
64
+ get value ( ) : void {
65
+ return ;
72
66
}
73
67
74
- protected render ( ) : React . ReactNode {
68
+ protected override render ( ) : React . ReactNode {
75
69
return (
76
70
< form >
77
71
< FirmwareUploaderComponent
@@ -84,54 +78,20 @@ export class UploadFirmwareDialogWidget extends ReactWidget {
84
78
</ form >
85
79
) ;
86
80
}
87
- }
88
-
89
- @injectable ( )
90
- export class UploadFirmwareDialogProps extends DialogProps { }
91
-
92
- @injectable ( )
93
- export class UploadFirmwareDialog extends AbstractDialog < void > {
94
- @inject ( UploadFirmwareDialogWidget )
95
- protected readonly widget : UploadFirmwareDialogWidget ;
96
-
97
- private busy = false ;
98
-
99
- constructor (
100
- @inject ( UploadFirmwareDialogProps )
101
- protected override readonly props : UploadFirmwareDialogProps
102
- ) {
103
- super ( { title : UploadFirmware . Commands . OPEN . label || '' } ) ;
104
- this . node . id = 'firmware-uploader-dialog-container' ;
105
- this . contentNode . classList . add ( 'firmware-uploader-dialog' ) ;
106
- this . acceptButton = undefined ;
107
- }
108
-
109
- get value ( ) : void {
110
- return ;
111
- }
112
81
113
82
protected override onAfterAttach ( msg : Message ) : void {
114
- if ( this . widget . isAttached ) {
115
- Widget . detach ( this . widget ) ;
116
- }
117
- Widget . attach ( this . widget , this . contentNode ) ;
118
- const firstButton = this . widget . node . querySelector ( 'button' ) ;
83
+ const firstButton = this . node . querySelector ( 'button' ) ;
119
84
firstButton ?. focus ( ) ;
120
- this . widget . busyCallback = this . busyCallback . bind ( this ) ;
121
85
super . onAfterAttach ( msg ) ;
122
86
this . update ( ) ;
123
87
}
124
88
125
89
protected override onUpdateRequest ( msg : Message ) : void {
126
90
super . onUpdateRequest ( msg ) ;
127
- this . widget . update ( ) ;
128
- }
129
-
130
- protected override onActivateRequest ( msg : Message ) : void {
131
- super . onActivateRequest ( msg ) ;
132
- this . widget . activate ( ) ;
91
+ this . update ( ) ;
133
92
}
134
93
94
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
135
95
protected override handleEnter ( event : KeyboardEvent ) : boolean | void {
136
96
return false ;
137
97
}
@@ -140,16 +100,23 @@ export class UploadFirmwareDialog extends AbstractDialog<void> {
140
100
if ( this . busy ) {
141
101
return ;
142
102
}
143
- this . widget . close ( ) ;
144
103
super . close ( ) ;
104
+ this . isOpen = new Object ( ) ;
145
105
}
146
106
147
- busyCallback ( busy : boolean ) : void {
107
+ private busyCallback ( busy : boolean ) : void {
148
108
this . busy = busy ;
149
109
if ( busy ) {
150
110
this . closeCrossNode . classList . add ( 'disabled' ) ;
151
111
} else {
152
112
this . closeCrossNode . classList . remove ( 'disabled' ) ;
153
113
}
154
114
}
115
+
116
+ private flashFirmware ( firmware : FirmwareInfo , port : Port ) : Promise < any > {
117
+ this . busyCallback ( true ) ;
118
+ return this . arduinoFirmwareUploader
119
+ . flash ( firmware , port )
120
+ . finally ( ( ) => this . busyCallback ( false ) ) ;
121
+ }
155
122
}
0 commit comments