@@ -179,29 +179,12 @@ export class UserDataProfileImportExportService extends Disposable implements IU
179
179
}
180
180
181
181
async exportProfile ( ) : Promise < void > {
182
- const view = this . viewsService . getViewWithId ( EXPORT_PROFILE_PREVIEW_VIEW ) ;
183
- if ( view ) {
184
- this . viewsService . openView ( view . id , true ) ;
185
- return ;
186
- }
187
-
188
182
if ( this . isProfileExportInProgressContextKey . get ( ) ) {
189
183
this . logService . warn ( 'Profile export already in progress.' ) ;
190
184
return ;
191
185
}
192
186
193
- const disposables = new DisposableStore ( ) ;
194
- try {
195
- const userDataProfilesExportState = disposables . add ( this . instantiationService . createInstance ( UserDataProfileExportState , this . userDataProfileService . currentProfile ) ) ;
196
- const barrier = new Barrier ( ) ;
197
- const exportAction = this . getExportAction ( barrier , userDataProfilesExportState ) ;
198
- const cancelAction = new BarrierAction ( barrier , new Action ( 'cancel' , localize ( 'cancel' , "Cancel" ) ) ) ;
199
- await this . showProfilePreviewView ( EXPORT_PROFILE_PREVIEW_VIEW , userDataProfilesExportState . profile . name , [ exportAction ] , cancelAction , true , userDataProfilesExportState ) ;
200
- await barrier . wait ( ) ;
201
- await this . hideProfilePreviewView ( EXPORT_PROFILE_PREVIEW_VIEW ) ;
202
- } finally {
203
- disposables . dispose ( ) ;
204
- }
187
+ return this . showProfileContents ( ) ;
205
188
}
206
189
207
190
async importProfile ( uri : URI , options ?: IProfileImportOptions ) : Promise < void > {
@@ -243,24 +226,20 @@ export class UserDataProfileImportExportService extends Disposable implements IU
243
226
try {
244
227
const userDataProfilesExportState = disposables . add ( this . instantiationService . createInstance ( UserDataProfileExportState , this . userDataProfileService . currentProfile ) ) ;
245
228
const barrier = new Barrier ( ) ;
246
- const exportAction = this . getExportAction ( barrier , userDataProfilesExportState ) ;
229
+ const exportAction = new BarrierAction ( barrier , new Action ( 'export' , localize ( 'export' , "Export" ) , undefined , true , ( ) => {
230
+ exportAction . enabled = false ;
231
+ return this . doExportProfile ( userDataProfilesExportState ) ;
232
+ } ) ) ;
247
233
const closeAction = new BarrierAction ( barrier , new Action ( 'close' , localize ( 'close' , "Close" ) ) ) ;
248
234
await this . showProfilePreviewView ( EXPORT_PROFILE_PREVIEW_VIEW , userDataProfilesExportState . profile . name , [ exportAction ] , closeAction , true , userDataProfilesExportState ) ;
235
+ disposables . add ( this . userDataProfileService . onDidChangeCurrentProfile ( e => barrier . open ( ) ) ) ;
249
236
await barrier . wait ( ) ;
250
237
await this . hideProfilePreviewView ( EXPORT_PROFILE_PREVIEW_VIEW ) ;
251
238
} finally {
252
239
disposables . dispose ( ) ;
253
240
}
254
241
}
255
242
256
- private getExportAction ( barrier : Barrier , userDataProfilesExportState : UserDataProfileExportState ) {
257
- const exportAction = new BarrierAction ( barrier , new Action ( 'export' , localize ( 'export' , "Export" ) , undefined , true , ( ) => {
258
- exportAction . enabled = false ;
259
- return this . doExportProfile ( userDataProfilesExportState ) ;
260
- } ) ) ;
261
- return exportAction ;
262
- }
263
-
264
243
private async doExportProfile ( userDataProfilesExportState : UserDataProfileExportState ) : Promise < void > {
265
244
const profile = await userDataProfilesExportState . getProfileToExport ( ) ;
266
245
if ( ! profile ) {
@@ -749,7 +728,6 @@ class UserDataProfilePreviewViewPane extends TreeViewPane {
749
728
super ( options , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , telemetryService , notificationService ) ;
750
729
}
751
730
752
-
753
731
protected override renderTreeView ( container : HTMLElement ) : void {
754
732
this . treeView . dataProvider = this . userDataProfileData ;
755
733
super . renderTreeView ( DOM . append ( container , DOM . $ ( '' ) ) ) ;
@@ -759,13 +737,17 @@ class UserDataProfilePreviewViewPane extends TreeViewPane {
759
737
this . updateConfirmButtonEnablement ( ) ;
760
738
} ) ) ;
761
739
this . computeAndLayout ( ) ;
762
- this . _register ( this . userDataProfileData . onDidChangeRoots ( ( ) => this . computeAndLayout ( ) ) ) ;
740
+ this . _register ( Event . any ( this . userDataProfileData . onDidChangeRoots , this . treeView . onDidCollapseItem , this . treeView . onDidExpandItem ) ( ( ) => this . computeAndLayout ( ) ) ) ;
763
741
}
764
742
765
743
private async computeAndLayout ( ) {
766
744
const roots = await this . userDataProfileData . getRoots ( ) ;
767
745
const children = await Promise . all ( roots . map ( async ( root ) => {
768
- if ( root . collapsibleState === TreeItemCollapsibleState . Expanded ) {
746
+ let expanded = root . collapsibleState === TreeItemCollapsibleState . Expanded ;
747
+ try {
748
+ expanded = ! this . treeView . isCollapsed ( root ) ;
749
+ } catch ( error ) { /* Ignore because element might not be added yet */ }
750
+ if ( expanded ) {
769
751
const children = await root . getChildren ( ) ;
770
752
return children ?? [ ] ;
771
753
}
@@ -806,14 +788,13 @@ class UserDataProfilePreviewViewPane extends TreeViewPane {
806
788
} ) ) ;
807
789
}
808
790
809
-
810
791
protected override layoutTreeView ( height : number , width : number ) : void {
811
792
this . dimension = new DOM . Dimension ( width , height ) ;
812
793
const buttonContainerHeight = 108 ;
813
794
this . buttonsContainer . style . height = `${ buttonContainerHeight } px` ;
814
795
this . buttonsContainer . style . width = `${ width } px` ;
815
796
816
- super . layoutTreeView ( Math . min ( height - buttonContainerHeight , 22 * ( Math . max ( this . totalTreeItemsCount , 6 ) || 12 ) ) , width ) ;
797
+ super . layoutTreeView ( Math . min ( height - buttonContainerHeight , 22 * this . totalTreeItemsCount ) , width ) ;
817
798
}
818
799
819
800
private updateConfirmButtonEnablement ( ) : void {
0 commit comments