@@ -50,6 +50,7 @@ export type ChangeEvent = {
50
50
readonly copyFromInfo ?: boolean ;
51
51
readonly copyFlags ?: boolean ;
52
52
readonly preview ?: boolean ;
53
+ readonly profile ?: boolean ;
53
54
readonly disabled ?: boolean ;
54
55
readonly newWindowProfile ?: boolean ;
55
56
} ;
@@ -353,17 +354,22 @@ export class UserDataProfileElement extends AbstractUserDataProfileElement {
353
354
}
354
355
) ) ;
355
356
this . _register ( this . userDataProfileService . onDidChangeCurrentProfile ( ( ) => this . active = this . userDataProfileService . currentProfile . id === this . profile . id ) ) ;
356
- this . _register ( this . userDataProfilesService . onDidChangeProfiles ( ( ) => {
357
- const profile = this . userDataProfilesService . profiles . find ( p => p . id === this . profile . id ) ;
357
+ this . _register ( this . userDataProfilesService . onDidChangeProfiles ( ( { updated } ) => {
358
+ const profile = updated . find ( p => p . id === this . profile . id ) ;
358
359
if ( profile ) {
359
360
this . _profile = profile ;
360
- this . name = profile . name ;
361
- this . icon = profile . icon ;
362
- this . flags = profile . useDefaultFlags ;
361
+ this . reset ( ) ;
362
+ this . _onDidChange . fire ( { profile : true } ) ;
363
363
}
364
364
} ) ) ;
365
365
}
366
366
367
+ reset ( ) : void {
368
+ this . name = this . _profile . name ;
369
+ this . icon = this . _profile . icon ;
370
+ this . flags = this . _profile . useDefaultFlags ;
371
+ }
372
+
367
373
public async toggleNewWindowProfile ( ) : Promise < void > {
368
374
if ( this . _isNewWindowProfile ) {
369
375
await this . configurationService . updateValue ( CONFIG_NEW_WINDOW_PROFILE , null ) ;
@@ -783,7 +789,7 @@ export class UserDataProfilesEditorModel extends EditorModel {
783
789
localize ( 'export' , "Export..." ) ,
784
790
ThemeIcon . asClassName ( Codicon . export ) ,
785
791
true ,
786
- ( ) => this . exportProfile ( profileElement . profile )
792
+ ( ) => this . userDataProfileImportExportService . exportProfile ( profile )
787
793
) ) ;
788
794
789
795
const deleteAction = disposables . add ( new Action (
@@ -906,11 +912,18 @@ export class UserDataProfilesEditorModel extends EditorModel {
906
912
if ( ! isWeb ) {
907
913
secondaryActions . push ( previewProfileAction ) ;
908
914
}
915
+ const exportAction = disposables . add ( new Action (
916
+ 'userDataProfile.export' ,
917
+ localize ( 'export' , "Export..." ) ,
918
+ ThemeIcon . asClassName ( Codicon . export ) ,
919
+ isUserDataProfile ( copyFrom ) ,
920
+ ( ) => this . exportNewProfile ( cancellationTokenSource . token )
921
+ ) ) ;
909
922
this . newProfileElement = disposables . add ( this . instantiationService . createInstance ( NewProfileElement ,
910
923
copyFrom ? '' : localize ( 'untitled' , "Untitled" ) ,
911
924
copyFrom ,
912
925
[ primaryActions , secondaryActions ] ,
913
- [ [ cancelAction ] , [ ] ] ,
926
+ [ [ cancelAction ] , [ exportAction ] ] ,
914
927
) ) ;
915
928
const updateCreateActionLabel = ( ) => {
916
929
if ( createAction . enabled ) {
@@ -931,6 +944,7 @@ export class UserDataProfilesEditorModel extends EditorModel {
931
944
}
932
945
if ( e . name || e . copyFrom ) {
933
946
updateCreateActionLabel ( ) ;
947
+ exportAction . enabled = isUserDataProfile ( this . newProfileElement ?. copyFrom ) ;
934
948
}
935
949
} ) ) ;
936
950
disposables . add ( this . userDataProfilesService . onDidChangeProfiles ( ( e ) => {
@@ -972,6 +986,27 @@ export class UserDataProfilesEditorModel extends EditorModel {
972
986
}
973
987
}
974
988
989
+ private async exportNewProfile ( token : CancellationToken ) : Promise < void > {
990
+ if ( ! this . newProfileElement ) {
991
+ return ;
992
+ }
993
+ if ( ! isUserDataProfile ( this . newProfileElement . copyFrom ) ) {
994
+ return ;
995
+ }
996
+ const profile = toUserDataProfile (
997
+ generateUuid ( ) ,
998
+ this . newProfileElement . name ,
999
+ this . newProfileElement . copyFrom . location ,
1000
+ this . newProfileElement . copyFrom . cacheHome ,
1001
+ {
1002
+ icon : this . newProfileElement . icon ,
1003
+ useDefaultFlags : this . newProfileElement . flags ,
1004
+ } ,
1005
+ this . userDataProfilesService . defaultProfile
1006
+ ) ;
1007
+ await this . userDataProfileImportExportService . exportProfile ( profile , this . newProfileElement . copyFlags ) ;
1008
+ }
1009
+
975
1010
async saveNewProfile ( transient ?: boolean , token ?: CancellationToken ) : Promise < IUserDataProfile | undefined > {
976
1011
if ( ! this . newProfileElement ) {
977
1012
return undefined ;
@@ -1097,8 +1132,4 @@ export class UserDataProfilesEditorModel extends EditorModel {
1097
1132
private async openWindow ( profile : IUserDataProfile ) : Promise < void > {
1098
1133
await this . hostService . openWindow ( { forceProfile : profile . name } ) ;
1099
1134
}
1100
-
1101
- private async exportProfile ( profile : IUserDataProfile ) : Promise < void > {
1102
- return this . userDataProfileImportExportService . exportProfile ( profile ) ;
1103
- }
1104
1135
}
0 commit comments