@@ -18,7 +18,7 @@ import { localize } from 'vs/nls';
18
18
import { MenuId , MenuRegistry , registerAction2 , Action2 } from 'vs/platform/actions/common/actions' ;
19
19
import { ICommandService } from 'vs/platform/commands/common/commands' ;
20
20
import { ContextKeyExpr , ContextKeyTrueExpr , IContextKey , IContextKeyService , RawContextKey } from 'vs/platform/contextkey/common/contextkey' ;
21
- import { IDialogService , IFileDialogService } from 'vs/platform/dialogs/common/dialogs' ;
21
+ import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
22
22
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
23
23
import { INotificationService , Severity } from 'vs/platform/notification/common/notification' ;
24
24
import { QuickPickItem , IQuickInputService } from 'vs/platform/quickinput/common/quickInput' ;
@@ -42,7 +42,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
42
42
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
43
43
import { ViewContainerLocation , IViewContainersRegistry , Extensions , ViewContainer } from 'vs/workbench/common/views' ;
44
44
import { UserDataSyncDataViews } from 'vs/workbench/contrib/userDataSync/browser/userDataSyncViews' ;
45
- import { IUserDataSyncWorkbenchService , getSyncAreaLabel , AccountStatus , CONTEXT_SYNC_STATE , CONTEXT_SYNC_ENABLEMENT , CONTEXT_ACCOUNT_STATE , CONFIGURE_SYNC_COMMAND_ID , SHOW_SYNC_LOG_COMMAND_ID , SYNC_VIEW_CONTAINER_ID , SYNC_TITLE , SYNC_ORIGINAL_TITLE , SYNC_VIEW_ICON , CONTEXT_HAS_CONFLICTS } from 'vs/workbench/services/userDataSync/common/userDataSync' ;
45
+ import { IUserDataSyncWorkbenchService , getSyncAreaLabel , AccountStatus , CONTEXT_SYNC_STATE , CONTEXT_SYNC_ENABLEMENT , CONTEXT_ACCOUNT_STATE , CONFIGURE_SYNC_COMMAND_ID , SHOW_SYNC_LOG_COMMAND_ID , SYNC_VIEW_CONTAINER_ID , SYNC_TITLE , SYNC_ORIGINAL_TITLE , SYNC_VIEW_ICON , CONTEXT_HAS_CONFLICTS , DOWNLOAD_ACTIVITY_ACTION_DESCRIPTOR } from 'vs/workbench/services/userDataSync/common/userDataSync' ;
46
46
import { Codicon } from 'vs/base/common/codicons' ;
47
47
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer' ;
48
48
import { Categories } from 'vs/platform/action/common/actionCommonCategories' ;
@@ -53,11 +53,7 @@ import { ctxIsMergeResultEditor, ctxMergeBaseUri } from 'vs/workbench/contrib/me
53
53
import { IWorkbenchIssueService } from 'vs/workbench/services/issue/common/issue' ;
54
54
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile' ;
55
55
import { ILocalizedString } from 'vs/platform/action/common/action' ;
56
- import { IProgressService , ProgressLocation } from 'vs/platform/progress/common/progress' ;
57
- import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity' ;
58
- import { IFileService } from 'vs/platform/files/common/files' ;
59
- import { escapeRegExpCharacters } from 'vs/base/common/strings' ;
60
- import { IUserDataSyncMachinesService } from 'vs/platform/userDataSync/common/userDataSyncMachines' ;
56
+ import { isWeb } from 'vs/base/common/platform' ;
61
57
62
58
type ConfigureSyncQuickPickItem = { id : SyncResource ; label : string ; description ?: string } ;
63
59
@@ -714,7 +710,10 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
714
710
this . registerShowLogAction ( ) ;
715
711
this . registerResetSyncDataAction ( ) ;
716
712
this . registerAcceptMergesAction ( ) ;
717
- this . registerDownloadSyncActivityAction ( ) ;
713
+
714
+ if ( isWeb ) {
715
+ this . registerDownloadSyncActivityAction ( ) ;
716
+ }
718
717
}
719
718
720
719
private registerTurnOnSyncAction ( ) : void {
@@ -1131,60 +1130,15 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
1131
1130
private registerDownloadSyncActivityAction ( ) : void {
1132
1131
this . _register ( registerAction2 ( class DownloadSyncActivityAction extends Action2 {
1133
1132
constructor ( ) {
1134
- super ( {
1135
- id : 'workbench.userDataSync.actions.downloadSyncActivity' ,
1136
- title : { original : 'Download Settings Sync Activity' , value : localize ( 'download sync activity title' , "Download Settings Sync Activity" ) } ,
1137
- category : Categories . Developer ,
1138
- f1 : true ,
1139
- precondition : ContextKeyExpr . and ( CONTEXT_ACCOUNT_STATE . isEqualTo ( AccountStatus . Available ) , CONTEXT_SYNC_STATE . notEqualsTo ( SyncStatus . Uninitialized ) )
1140
- } ) ;
1133
+ super ( DOWNLOAD_ACTIVITY_ACTION_DESCRIPTOR ) ;
1141
1134
}
1142
-
1143
1135
async run ( accessor : ServicesAccessor ) : Promise < void > {
1144
1136
const userDataSyncWorkbenchService = accessor . get ( IUserDataSyncWorkbenchService ) ;
1145
- const fileDialogService = accessor . get ( IFileDialogService ) ;
1146
- const progressService = accessor . get ( IProgressService ) ;
1147
- const uriIdentityService = accessor . get ( IUriIdentityService ) ;
1148
- const fileService = accessor . get ( IFileService ) ;
1149
- const userDataSyncMachinesService = accessor . get ( IUserDataSyncMachinesService ) ;
1150
1137
const notificationService = accessor . get ( INotificationService ) ;
1151
-
1152
- const result = await fileDialogService . showOpenDialog ( {
1153
- title : localize ( 'download sync activity dialog title' , "Select folder to download Settings Sync activity" ) ,
1154
- canSelectFiles : false ,
1155
- canSelectFolders : true ,
1156
- canSelectMany : false ,
1157
- openLabel : localize ( 'download sync activity dialog open label' , "Save" ) ,
1158
- } ) ;
1159
-
1160
- if ( ! result ?. [ 0 ] ) {
1161
- return ;
1138
+ const folder = await userDataSyncWorkbenchService . downloadSyncActivity ( ) ;
1139
+ if ( folder ) {
1140
+ notificationService . info ( localize ( 'download sync activity complete' , "Successfully downloaded Settings Sync activity." ) ) ;
1162
1141
}
1163
-
1164
- await progressService . withProgress ( { location : ProgressLocation . Window } , async ( ) => {
1165
- const machines = await userDataSyncMachinesService . getMachines ( ) ;
1166
- const currentMachine = machines . find ( m => m . isCurrent ) ;
1167
- const name = ( currentMachine ? currentMachine . name + ' - ' : '' ) + 'Settings Sync Activity' ;
1168
- const stat = await fileService . resolve ( result [ 0 ] ) ;
1169
-
1170
- const nameRegEx = new RegExp ( `${ escapeRegExpCharacters ( name ) } \\s(\\d+)` ) ;
1171
- const indexes : number [ ] = [ ] ;
1172
- for ( const child of stat . children ?? [ ] ) {
1173
- if ( child . name === name ) {
1174
- indexes . push ( 0 ) ;
1175
- } else {
1176
- const matches = nameRegEx . exec ( child . name ) ;
1177
- if ( matches ) {
1178
- indexes . push ( parseInt ( matches [ 1 ] ) ) ;
1179
- }
1180
- }
1181
- }
1182
- indexes . sort ( ( a , b ) => a - b ) ;
1183
-
1184
- return userDataSyncWorkbenchService . downloadSyncActivity ( uriIdentityService . extUri . joinPath ( result [ 0 ] , indexes [ 0 ] !== 0 ? name : `${ name } ${ indexes [ indexes . length - 1 ] + 1 } ` ) ) ;
1185
- } ) ;
1186
-
1187
- notificationService . info ( localize ( 'download sync activity complete' , "Successfully downloaded Settings Sync activity." ) ) ;
1188
1142
}
1189
1143
1190
1144
} ) ) ;
0 commit comments