@@ -3,16 +3,15 @@ import debounce = require('lodash.debounce');
3
3
import { Event } from '@theia/core/lib/common/event' ;
4
4
import { CommandService } from '@theia/core/lib/common/command' ;
5
5
import { MessageService } from '@theia/core/lib/common/message-service' ;
6
- import { OutputCommands } from '@theia/output/lib/browser/output-commands' ;
7
6
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs' ;
8
7
import { Searchable } from '../../../common/protocol/searchable' ;
9
8
import { Installable } from '../../../common/protocol/installable' ;
10
9
import { ArduinoComponent } from '../../../common/protocol/arduino-component' ;
11
- import { InstallationProgressDialog , UninstallationProgressDialog } from '../progress-dialog' ;
12
10
import { SearchBar } from './search-bar' ;
13
11
import { ListWidget } from './list-widget' ;
14
12
import { ComponentList } from './component-list' ;
15
13
import { ListItemRenderer } from './list-item-renderer' ;
14
+ import { ResponseServiceImpl } from '../../response-service-impl' ;
16
15
17
16
export class FilterableListContainer < T extends ArduinoComponent > extends React . Component < FilterableListContainer . Props < T > , FilterableListContainer . State < T > > {
18
17
@@ -84,20 +83,14 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
84
83
}
85
84
86
85
protected async install ( item : T , version : Installable . Version ) : Promise < void > {
87
- const { install, searchable, itemLabel } = this . props ;
88
- const dialog = new InstallationProgressDialog ( itemLabel ( item ) , version ) ;
89
- try {
90
- dialog . open ( ) ;
91
- await this . clearArduinoChannel ( ) ;
92
- await install ( { item, version } ) ;
93
- const items = await searchable . search ( { query : this . state . filterText } ) ;
94
- this . setState ( { items : this . sort ( items ) } ) ;
95
- } catch ( error ) {
96
- this . props . messageService . error ( error instanceof Error ? error . message : String ( error ) ) ;
97
- throw error ;
98
- } finally {
99
- dialog . close ( ) ;
100
- }
86
+ const { install, searchable } = this . props ;
87
+ await Installable . doWithProgress ( {
88
+ ...this . props ,
89
+ progressText : `Processing ${ item . name } :${ version } ` ,
90
+ run : ( { progressId } ) => install ( { item, progressId, version } )
91
+ } ) ;
92
+ const items = await searchable . search ( { query : this . state . filterText } ) ;
93
+ this . setState ( { items : this . sort ( items ) } ) ;
101
94
}
102
95
103
96
protected async uninstall ( item : T ) : Promise < void > {
@@ -110,21 +103,14 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
110
103
if ( ! ok ) {
111
104
return ;
112
105
}
113
- const { uninstall, searchable, itemLabel } = this . props ;
114
- const dialog = new UninstallationProgressDialog ( itemLabel ( item ) ) ;
115
- try {
116
- await this . clearArduinoChannel ( ) ;
117
- dialog . open ( ) ;
118
- await uninstall ( { item } ) ;
119
- const items = await searchable . search ( { query : this . state . filterText } ) ;
120
- this . setState ( { items : this . sort ( items ) } ) ;
121
- } finally {
122
- dialog . close ( ) ;
123
- }
124
- }
125
-
126
- private async clearArduinoChannel ( ) : Promise < void > {
127
- return this . props . commandService . executeCommand ( OutputCommands . CLEAR . id , { name : 'Arduino' } ) ;
106
+ const { uninstall, searchable } = this . props ;
107
+ await Installable . doWithProgress ( {
108
+ ...this . props ,
109
+ progressText : `Processing ${ item . name } ${ item . installedVersion ? `:${ item . installedVersion } ` : '' } ` ,
110
+ run : ( { progressId } ) => uninstall ( { item, progressId } )
111
+ } ) ;
112
+ const items = await searchable . search ( { query : this . state . filterText } ) ;
113
+ this . setState ( { items : this . sort ( items ) } ) ;
128
114
}
129
115
130
116
}
@@ -139,9 +125,10 @@ export namespace FilterableListContainer {
139
125
readonly resolveContainer : ( element : HTMLElement ) => void ;
140
126
readonly resolveFocus : ( element : HTMLElement | undefined ) => void ;
141
127
readonly filterTextChangeEvent : Event < string | undefined > ;
142
- readonly install : ( { item, version } : { item : T , version : Installable . Version } ) => Promise < void > ;
143
- readonly uninstall : ( { item } : { item : T } ) => Promise < void > ;
144
128
readonly messageService : MessageService ;
129
+ readonly responseService : ResponseServiceImpl ;
130
+ readonly install : ( { item, progressId, version } : { item : T , progressId : string , version : Installable . Version } ) => Promise < void > ;
131
+ readonly uninstall : ( { item, progressId } : { item : T , progressId : string } ) => Promise < void > ;
145
132
readonly commandService : CommandService ;
146
133
}
147
134
0 commit comments