1
- import * as React from '@theia/core/shared/react' ;
1
+ import { DialogProps } from '@theia/core/lib/browser/dialogs' ;
2
+ import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
3
+ import {
4
+ PreferenceScope ,
5
+ PreferenceService ,
6
+ } from '@theia/core/lib/browser/preferences/preference-service' ;
7
+ import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget' ;
8
+ import { CommandRegistry } from '@theia/core/lib/common/command' ;
9
+ import { nls } from '@theia/core/lib/common/nls' ;
10
+ import type { Message } from '@theia/core/shared/@phosphor/messaging' ;
11
+ import { Widget } from '@theia/core/shared/@phosphor/widgets' ;
2
12
import {
3
13
inject ,
4
14
injectable ,
5
15
postConstruct ,
6
16
} from '@theia/core/shared/inversify' ;
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' ;
10
- import { Message } from '@theia/core/shared/@phosphor/messaging' ;
11
- import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget' ;
12
- import { BoardsServiceProvider } from '../../boards/boards-service-provider' ;
13
- // import { CertificateUploaderComponent } from './certificate-uploader-component';
14
- import { ArduinoPreferences } from '../../arduino-preferences' ;
15
- import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service' ;
16
- import { CommandRegistry } from '@theia/core/lib/common/command' ;
17
- import { certificateList } from './utils' ;
17
+ import * as React from '@theia/core/shared/react' ;
18
18
import { ArduinoFirmwareUploader } from '../../../common/protocol/arduino-firmware-uploader' ;
19
- import { nls } from '@theia/core/lib/common' ;
20
- import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
19
+ import { createBoardList } from '../../../common/protocol/board-list' ;
20
+ import { ArduinoPreferences } from '../../arduino-preferences' ;
21
+ import { BoardsServiceProvider } from '../../boards/boards-service-provider' ;
22
+ import { AbstractDialog } from '../../theia/dialogs/dialogs' ;
23
+ import { CertificateUploaderComponent } from './certificate-uploader-component' ;
24
+ import { certificateList , sanifyCertString } from './utils' ;
21
25
22
26
@injectable ( )
23
27
export class UploadCertificateDialogWidget extends ReactWidget {
24
28
@inject ( BoardsServiceProvider )
25
- protected readonly boardsServiceProvider : BoardsServiceProvider ;
26
-
29
+ private readonly boardsServiceProvider : BoardsServiceProvider ;
27
30
@inject ( ArduinoPreferences )
28
- protected readonly arduinoPreferences : ArduinoPreferences ;
29
-
31
+ private readonly arduinoPreferences : ArduinoPreferences ;
30
32
@inject ( PreferenceService )
31
- protected readonly preferenceService : PreferenceService ;
32
-
33
+ private readonly preferenceService : PreferenceService ;
33
34
@inject ( CommandRegistry )
34
- protected readonly commandRegistry : CommandRegistry ;
35
-
35
+ private readonly commandRegistry : CommandRegistry ;
36
36
@inject ( ArduinoFirmwareUploader )
37
- protected readonly arduinoFirmwareUploader : ArduinoFirmwareUploader ;
38
-
37
+ private readonly arduinoFirmwareUploader : ArduinoFirmwareUploader ;
39
38
@inject ( FrontendApplicationStateService )
40
39
private readonly appStateService : FrontendApplicationStateService ;
41
40
42
- protected certificates : string [ ] = [ ] ;
43
- protected updatableFqbns : string [ ] = [ ] ;
44
- // protected availableBoards: AvailableBoard[] = [] ;
41
+ private certificates : string [ ] = [ ] ;
42
+ private updatableFqbns : string [ ] = [ ] ;
43
+ private boardList = createBoardList ( { } ) ;
45
44
46
- public busyCallback = ( busy : boolean ) => {
45
+ busyCallback = ( busy : boolean ) => {
47
46
return ;
48
47
} ;
49
48
50
- constructor ( ) {
51
- super ( ) ;
52
- }
53
-
54
49
@postConstruct ( )
55
50
protected init ( ) : void {
56
51
this . arduinoPreferences . ready . then ( ( ) => {
@@ -75,25 +70,25 @@ export class UploadCertificateDialogWidget extends ReactWidget {
75
70
} )
76
71
) ;
77
72
78
- // this.boardsServiceProvider.onAvailableBoardsChanged((availableBoards ) => {
79
- // this.availableBoards = availableBoards ;
80
- // this.update();
81
- // });
73
+ this . boardsServiceProvider . onBoardListDidChange ( ( boardList ) => {
74
+ this . boardList = boardList ;
75
+ this . update ( ) ;
76
+ } ) ;
82
77
}
83
78
84
- // private addCertificate(certificate: string) {
85
- // const certString = sanifyCertString(certificate);
79
+ private addCertificate ( certificate : string ) {
80
+ const certString = sanifyCertString ( certificate ) ;
86
81
87
- // if (certString.length > 0) {
88
- // this.certificates.push(sanifyCertString(certificate));
89
- // }
82
+ if ( certString . length > 0 ) {
83
+ this . certificates . push ( sanifyCertString ( certificate ) ) ;
84
+ }
90
85
91
- // this.preferenceService.set(
92
- // 'arduino.board.certificates',
93
- // this.certificates.join(','),
94
- // PreferenceScope.User
95
- // );
96
- // }
86
+ this . preferenceService . set (
87
+ 'arduino.board.certificates' ,
88
+ this . certificates . join ( ',' ) ,
89
+ PreferenceScope . User
90
+ ) ;
91
+ }
97
92
98
93
protected openContextMenu ( x : number , y : number , cert : string ) : void {
99
94
this . commandRegistry . executeCommand (
@@ -118,17 +113,16 @@ export class UploadCertificateDialogWidget extends ReactWidget {
118
113
}
119
114
120
115
protected render ( ) : React . ReactNode {
121
- // return (
122
- // <CertificateUploaderComponent
123
- // availableBoards={this.availableBoards}
124
- // certificates={this.certificates}
125
- // updatableFqbns={this.updatableFqbns}
126
- // addCertificate={this.addCertificate.bind(this)}
127
- // uploadCertificates={this.uploadCertificates.bind(this)}
128
- // openContextMenu={this.openContextMenu.bind(this)}
129
- // />
130
- // );
131
- return undefined ;
116
+ return (
117
+ < CertificateUploaderComponent
118
+ boardList = { this . boardList }
119
+ certificates = { this . certificates }
120
+ updatableFqbns = { this . updatableFqbns }
121
+ addCertificate = { this . addCertificate . bind ( this ) }
122
+ uploadCertificates = { this . uploadCertificates . bind ( this ) }
123
+ openContextMenu = { this . openContextMenu . bind ( this ) }
124
+ />
125
+ ) ;
132
126
}
133
127
}
134
128
@@ -138,7 +132,7 @@ export class UploadCertificateDialogProps extends DialogProps {}
138
132
@injectable ( )
139
133
export class UploadCertificateDialog extends AbstractDialog < void > {
140
134
@inject ( UploadCertificateDialogWidget )
141
- protected readonly widget : UploadCertificateDialogWidget ;
135
+ private readonly widget : UploadCertificateDialogWidget ;
142
136
143
137
private busy = false ;
144
138
0 commit comments