@codingame/monaco-vscode-user-data-profile-service-override 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/package.json +31 -0
  4. package/userDataProfile.js +118 -0
  5. package/vscode/src/vs/platform/userDataProfile/browser/userDataProfile.js +95 -0
  6. package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.js +84 -0
  7. package/vscode/src/vs/platform/userDataSync/common/extensionsMerge.js +331 -0
  8. package/vscode/src/vs/platform/userDataSync/common/extensionsSync.js +545 -0
  9. package/vscode/src/vs/platform/userDataSync/common/globalStateMerge.js +102 -0
  10. package/vscode/src/vs/platform/userDataSync/common/globalStateSync.js +431 -0
  11. package/vscode/src/vs/platform/userDataSync/common/keybindingsMerge.js +277 -0
  12. package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +328 -0
  13. package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +322 -0
  14. package/vscode/src/vs/platform/userDataSync/common/snippetsMerge.js +126 -0
  15. package/vscode/src/vs/platform/userDataSync/common/snippetsSync.js +478 -0
  16. package/vscode/src/vs/platform/userDataSync/common/tasksSync.js +245 -0
  17. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +9 -0
  18. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +495 -0
  19. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfileActions.js +159 -0
  20. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilePreview.js +24 -0
  21. package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +62 -0
  22. package/vscode/src/vs/workbench/services/userDataProfile/browser/extensionsResource.js +328 -0
  23. package/vscode/src/vs/workbench/services/userDataProfile/browser/globalStateResource.js +144 -0
  24. package/vscode/src/vs/workbench/services/userDataProfile/browser/keybindingsResource.js +119 -0
  25. package/vscode/src/vs/workbench/services/userDataProfile/browser/media/userDataProfileView.css.js +6 -0
  26. package/vscode/src/vs/workbench/services/userDataProfile/browser/settingsResource.js +140 -0
  27. package/vscode/src/vs/workbench/services/userDataProfile/browser/snippetsResource.js +155 -0
  28. package/vscode/src/vs/workbench/services/userDataProfile/browser/tasksResource.js +118 -0
  29. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.js +1453 -0
  30. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileInit.js +151 -0
  31. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.js +180 -0
  32. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.js +39 -0
  33. package/vscode/src/vs/workbench/services/userDataSync/browser/userDataSyncInit.js +448 -0
@@ -0,0 +1,495 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { Disposable, MutableDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import { isWeb } from 'vscode/vscode/vs/base/common/platform';
4
+ import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
5
+ import { MenuRegistry, MenuId, registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
6
+ import { IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions.service';
7
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
8
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
9
+ import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
10
+ import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
11
+ import { CURRENT_PROFILE_CONTEXT, PROFILES_ENABLEMENT_CONTEXT, IS_CURRENT_PROFILE_TRANSIENT_CONTEXT, HAS_PROFILES_CONTEXT, ProfilesMenu, PROFILES_CATEGORY, IS_PROFILE_EXPORT_IN_PROGRESS_CONTEXT, IS_PROFILE_IMPORT_IN_PROGRESS_CONTEXT, PROFILE_FILTER, PROFILES_TITLE } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
12
+ import { IUserDataProfileImportExportService, IUserDataProfileService, IUserDataProfileManagementService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
13
+ import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
14
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
15
+ import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
16
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
17
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
18
+ import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
19
+ import { IWorkspaceTagsService } from 'vscode/vscode/vs/workbench/contrib/tags/common/workspaceTags.service';
20
+ import { getErrorMessage } from 'vscode/vscode/vs/base/common/errors';
21
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
22
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
23
+
24
+ const _moduleId = "vs/workbench/contrib/userDataProfile/browser/userDataProfile";
25
+ let UserDataProfilesWorkbenchContribution = class UserDataProfilesWorkbenchContribution extends Disposable {
26
+ static { this.ID = 'workbench.contrib.userDataProfiles'; }
27
+ constructor(userDataProfileService, userDataProfilesService, userDataProfileManagementService, userDataProfileImportExportService, telemetryService, workspaceContextService, workspaceTagsService, contextKeyService, lifecycleService) {
28
+ super();
29
+ this.userDataProfileService = userDataProfileService;
30
+ this.userDataProfilesService = userDataProfilesService;
31
+ this.userDataProfileManagementService = userDataProfileManagementService;
32
+ this.userDataProfileImportExportService = userDataProfileImportExportService;
33
+ this.telemetryService = telemetryService;
34
+ this.workspaceContextService = workspaceContextService;
35
+ this.workspaceTagsService = workspaceTagsService;
36
+ this.lifecycleService = lifecycleService;
37
+ this.profilesDisposable = this._register(( (new MutableDisposable())));
38
+ this.currentprofileActionsDisposable = this._register(( (new MutableDisposable())));
39
+ this.currentProfileContext = CURRENT_PROFILE_CONTEXT.bindTo(contextKeyService);
40
+ PROFILES_ENABLEMENT_CONTEXT.bindTo(contextKeyService).set(this.userDataProfilesService.isEnabled());
41
+ this.isCurrentProfileTransientContext = IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.bindTo(contextKeyService);
42
+ this.currentProfileContext.set(this.userDataProfileService.currentProfile.id);
43
+ this.isCurrentProfileTransientContext.set(!!this.userDataProfileService.currentProfile.isTransient);
44
+ this._register(this.userDataProfileService.onDidChangeCurrentProfile(e => {
45
+ this.currentProfileContext.set(this.userDataProfileService.currentProfile.id);
46
+ this.isCurrentProfileTransientContext.set(!!this.userDataProfileService.currentProfile.isTransient);
47
+ }));
48
+ this.hasProfilesContext = HAS_PROFILES_CONTEXT.bindTo(contextKeyService);
49
+ this.hasProfilesContext.set(this.userDataProfilesService.profiles.length > 1);
50
+ this._register(this.userDataProfilesService.onDidChangeProfiles(e => this.hasProfilesContext.set(this.userDataProfilesService.profiles.length > 1)));
51
+ this.registerActions();
52
+ if (isWeb) {
53
+ lifecycleService.when(4 ).then(() => userDataProfilesService.cleanUp());
54
+ }
55
+ this.reportWorkspaceProfileInfo();
56
+ }
57
+ registerActions() {
58
+ this.registerProfileSubMenu();
59
+ this._register(this.registerSwitchProfileAction());
60
+ this.registerProfilesActions();
61
+ this._register(this.userDataProfilesService.onDidChangeProfiles(() => this.registerProfilesActions()));
62
+ this.registerCurrentProfilesActions();
63
+ this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => this.registerCurrentProfilesActions()));
64
+ this.registerCreateFromCurrentProfileAction();
65
+ this.registerCreateProfileAction();
66
+ this.registerDeleteProfileAction();
67
+ this.registerHelpAction();
68
+ }
69
+ registerProfileSubMenu() {
70
+ const getProfilesTitle = () => {
71
+ return ( localizeWithPath(
72
+ _moduleId,
73
+ 0,
74
+ "Profiles ({0})",
75
+ this.userDataProfileService.currentProfile.name
76
+ ));
77
+ };
78
+ MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
79
+ get title() {
80
+ return getProfilesTitle();
81
+ },
82
+ submenu: ProfilesMenu,
83
+ group: '2_configuration',
84
+ order: 1,
85
+ });
86
+ MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
87
+ get title() {
88
+ return getProfilesTitle();
89
+ },
90
+ submenu: ProfilesMenu,
91
+ group: '2_configuration',
92
+ order: 1,
93
+ when: PROFILES_ENABLEMENT_CONTEXT,
94
+ });
95
+ }
96
+ registerProfilesActions() {
97
+ this.profilesDisposable.value = ( (new DisposableStore()));
98
+ for (const profile of this.userDataProfilesService.profiles) {
99
+ this.profilesDisposable.value.add(this.registerProfileEntryAction(profile));
100
+ }
101
+ }
102
+ registerProfileEntryAction(profile) {
103
+ const that = this;
104
+ return registerAction2(class ProfileEntryAction extends Action2 {
105
+ constructor() {
106
+ super({
107
+ id: `workbench.profiles.actions.profileEntry.${profile.id}`,
108
+ title: profile.name,
109
+ toggled: ( (ContextKeyExpr.equals(CURRENT_PROFILE_CONTEXT.key, profile.id))),
110
+ menu: [
111
+ {
112
+ id: ProfilesMenu,
113
+ group: '0_profiles',
114
+ when: PROFILES_ENABLEMENT_CONTEXT,
115
+ }
116
+ ]
117
+ });
118
+ }
119
+ async run(accessor) {
120
+ if (that.userDataProfileService.currentProfile.id !== profile.id) {
121
+ return that.userDataProfileManagementService.switchProfile(profile);
122
+ }
123
+ }
124
+ });
125
+ }
126
+ registerSwitchProfileAction() {
127
+ return registerAction2(class SwitchProfileAction extends Action2 {
128
+ constructor() {
129
+ super({
130
+ id: `workbench.profiles.actions.switchProfile`,
131
+ title: ( localize2WithPath(_moduleId, 1, 'Switch Profile...')),
132
+ category: PROFILES_CATEGORY,
133
+ f1: true,
134
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
135
+ });
136
+ }
137
+ async run(accessor) {
138
+ const quickInputService = accessor.get(IQuickInputService);
139
+ const menuService = accessor.get(IMenuService);
140
+ const menu = menuService.createMenu(ProfilesMenu, accessor.get(IContextKeyService));
141
+ const actions = menu.getActions().find(([group]) => group === '0_profiles')?.[1] ?? [];
142
+ try {
143
+ const result = await quickInputService.pick(( (actions.map(action => ({
144
+ action,
145
+ label: action.checked ? `$(check) ${action.label}` : action.label,
146
+ })))), {
147
+ placeHolder: ( localizeWithPath(_moduleId, 2, "Select Profile"))
148
+ });
149
+ await result?.action.run();
150
+ }
151
+ finally {
152
+ menu.dispose();
153
+ }
154
+ }
155
+ });
156
+ }
157
+ registerCurrentProfilesActions() {
158
+ this.currentprofileActionsDisposable.value = ( (new DisposableStore()));
159
+ this.currentprofileActionsDisposable.value.add(this.registerEditCurrentProfileAction());
160
+ this.currentprofileActionsDisposable.value.add(this.registerShowCurrentProfileContentsAction());
161
+ this.currentprofileActionsDisposable.value.add(this.registerExportCurrentProfileAction());
162
+ this.currentprofileActionsDisposable.value.add(this.registerImportProfileAction());
163
+ }
164
+ registerEditCurrentProfileAction() {
165
+ const that = this;
166
+ return registerAction2(class RenameCurrentProfileAction extends Action2 {
167
+ constructor() {
168
+ const when = ( (ContextKeyExpr.and( (ContextKeyExpr.notEquals(
169
+ CURRENT_PROFILE_CONTEXT.key,
170
+ that.userDataProfilesService.defaultProfile.id
171
+ )), (IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.toNegated()))));
172
+ super({
173
+ id: `workbench.profiles.actions.editCurrentProfile`,
174
+ title: ( localize2WithPath(_moduleId, 3, "Edit Profile...")),
175
+ precondition: when,
176
+ f1: true,
177
+ menu: [
178
+ {
179
+ id: ProfilesMenu,
180
+ group: '2_manage_current',
181
+ when,
182
+ order: 2
183
+ }
184
+ ]
185
+ });
186
+ }
187
+ run() {
188
+ return that.userDataProfileImportExportService.editProfile(that.userDataProfileService.currentProfile);
189
+ }
190
+ });
191
+ }
192
+ registerShowCurrentProfileContentsAction() {
193
+ const id = 'workbench.profiles.actions.showProfileContents';
194
+ return registerAction2(class ShowProfileContentsAction extends Action2 {
195
+ constructor() {
196
+ super({
197
+ id,
198
+ title: ( localize2WithPath(_moduleId, 4, "Show Profile Contents")),
199
+ category: PROFILES_CATEGORY,
200
+ menu: [
201
+ {
202
+ id: ProfilesMenu,
203
+ group: '2_manage_current',
204
+ order: 3
205
+ }, {
206
+ id: MenuId.CommandPalette
207
+ }
208
+ ]
209
+ });
210
+ }
211
+ async run(accessor) {
212
+ const userDataProfileImportExportService = accessor.get(IUserDataProfileImportExportService);
213
+ return userDataProfileImportExportService.showProfileContents();
214
+ }
215
+ });
216
+ }
217
+ registerExportCurrentProfileAction() {
218
+ const that = this;
219
+ const disposables = ( (new DisposableStore()));
220
+ const id = 'workbench.profiles.actions.exportProfile';
221
+ disposables.add(registerAction2(class ExportProfileAction extends Action2 {
222
+ constructor() {
223
+ super({
224
+ id,
225
+ title: ( localize2WithPath(_moduleId, 5, "Export Profile...")),
226
+ category: PROFILES_CATEGORY,
227
+ precondition: ( (IS_PROFILE_EXPORT_IN_PROGRESS_CONTEXT.toNegated())),
228
+ menu: [
229
+ {
230
+ id: ProfilesMenu,
231
+ group: '4_import_export_profiles',
232
+ order: 1
233
+ }, {
234
+ id: MenuId.CommandPalette
235
+ }
236
+ ]
237
+ });
238
+ }
239
+ async run(accessor) {
240
+ const userDataProfileImportExportService = accessor.get(IUserDataProfileImportExportService);
241
+ return userDataProfileImportExportService.exportProfile();
242
+ }
243
+ }));
244
+ disposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarShare, {
245
+ command: {
246
+ id,
247
+ title: ( localize2WithPath(
248
+ _moduleId,
249
+ 6,
250
+ "Export Profile ({0})...",
251
+ that.userDataProfileService.currentProfile.name
252
+ )),
253
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
254
+ },
255
+ }));
256
+ return disposables;
257
+ }
258
+ registerImportProfileAction() {
259
+ const disposables = ( (new DisposableStore()));
260
+ const id = 'workbench.profiles.actions.importProfile';
261
+ const that = this;
262
+ disposables.add(registerAction2(class ImportProfileAction extends Action2 {
263
+ constructor() {
264
+ super({
265
+ id,
266
+ title: ( localize2WithPath(_moduleId, 7, "Import Profile...")),
267
+ category: PROFILES_CATEGORY,
268
+ precondition: ( (IS_PROFILE_IMPORT_IN_PROGRESS_CONTEXT.toNegated())),
269
+ menu: [
270
+ {
271
+ id: ProfilesMenu,
272
+ group: '4_import_export_profiles',
273
+ when: PROFILES_ENABLEMENT_CONTEXT,
274
+ order: 2
275
+ }, {
276
+ id: MenuId.CommandPalette,
277
+ when: PROFILES_ENABLEMENT_CONTEXT,
278
+ }
279
+ ]
280
+ });
281
+ }
282
+ async run(accessor) {
283
+ const fileDialogService = accessor.get(IFileDialogService);
284
+ const quickInputService = accessor.get(IQuickInputService);
285
+ const userDataProfileImportExportService = accessor.get(IUserDataProfileImportExportService);
286
+ const notificationService = accessor.get(INotificationService);
287
+ const disposables = ( (new DisposableStore()));
288
+ const quickPick = disposables.add(quickInputService.createQuickPick());
289
+ const profileTemplateQuickPickItems = await that.getProfileTemplatesQuickPickItems();
290
+ const updateQuickPickItems = (value) => {
291
+ const quickPickItems = [];
292
+ if (value) {
293
+ quickPickItems.push({ label: quickPick.value, description: ( localizeWithPath(_moduleId, 8, "Import from URL")) });
294
+ }
295
+ quickPickItems.push({ label: ( localizeWithPath(_moduleId, 9, "Select File...")) });
296
+ if (profileTemplateQuickPickItems.length) {
297
+ quickPickItems.push({
298
+ type: 'separator',
299
+ label: ( localizeWithPath(_moduleId, 10, "Profile Templates"))
300
+ }, ...profileTemplateQuickPickItems);
301
+ }
302
+ quickPick.items = quickPickItems;
303
+ };
304
+ quickPick.title = ( localizeWithPath(_moduleId, 11, "Import from Profile Template..."));
305
+ quickPick.placeholder = ( localizeWithPath(_moduleId, 12, "Provide Profile Template URL"));
306
+ quickPick.ignoreFocusOut = true;
307
+ disposables.add(quickPick.onDidChangeValue(updateQuickPickItems));
308
+ updateQuickPickItems();
309
+ quickPick.matchOnLabel = false;
310
+ quickPick.matchOnDescription = false;
311
+ disposables.add(quickPick.onDidAccept(async () => {
312
+ quickPick.hide();
313
+ const selectedItem = quickPick.selectedItems[0];
314
+ if (!selectedItem) {
315
+ return;
316
+ }
317
+ try {
318
+ if (selectedItem.url) {
319
+ return await that.userDataProfileImportExportService.createProfile(( (URI.parse(selectedItem.url))));
320
+ }
321
+ const profile = selectedItem.label === quickPick.value ? ( (URI.parse(quickPick.value))) : await this.getProfileUriFromFileSystem(fileDialogService);
322
+ if (profile) {
323
+ await userDataProfileImportExportService.importProfile(profile);
324
+ }
325
+ }
326
+ catch (error) {
327
+ notificationService.error(( localizeWithPath(_moduleId, 13, "Error while creating profile: {0}", getErrorMessage(error))));
328
+ }
329
+ }));
330
+ disposables.add(quickPick.onDidHide(() => disposables.dispose()));
331
+ quickPick.show();
332
+ }
333
+ async getProfileUriFromFileSystem(fileDialogService) {
334
+ const profileLocation = await fileDialogService.showOpenDialog({
335
+ canSelectFolders: false,
336
+ canSelectFiles: true,
337
+ canSelectMany: false,
338
+ filters: PROFILE_FILTER,
339
+ title: ( localizeWithPath(_moduleId, 14, "Select Profile Template File")),
340
+ });
341
+ if (!profileLocation) {
342
+ return null;
343
+ }
344
+ return profileLocation[0];
345
+ }
346
+ }));
347
+ disposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarShare, {
348
+ command: {
349
+ id,
350
+ title: ( localize2WithPath(_moduleId, 15, "Import Profile...")),
351
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
352
+ },
353
+ }));
354
+ return disposables;
355
+ }
356
+ registerCreateFromCurrentProfileAction() {
357
+ const that = this;
358
+ this._register(registerAction2(class CreateFromCurrentProfileAction extends Action2 {
359
+ constructor() {
360
+ super({
361
+ id: 'workbench.profiles.actions.createFromCurrentProfile',
362
+ title: ( localize2WithPath(_moduleId, 16, "Save Current Profile As...")),
363
+ category: PROFILES_CATEGORY,
364
+ f1: true,
365
+ precondition: PROFILES_ENABLEMENT_CONTEXT
366
+ });
367
+ }
368
+ run(accessor) {
369
+ return that.userDataProfileImportExportService.createProfile(that.userDataProfileService.currentProfile);
370
+ }
371
+ }));
372
+ }
373
+ registerCreateProfileAction() {
374
+ const that = this;
375
+ this._register(registerAction2(class CreateProfileAction extends Action2 {
376
+ constructor() {
377
+ super({
378
+ id: 'workbench.profiles.actions.createProfile',
379
+ title: ( localize2WithPath(_moduleId, 17, "Create Profile...")),
380
+ category: PROFILES_CATEGORY,
381
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
382
+ f1: true,
383
+ menu: [
384
+ {
385
+ id: ProfilesMenu,
386
+ group: '3_manage_profiles',
387
+ when: PROFILES_ENABLEMENT_CONTEXT,
388
+ order: 1
389
+ }
390
+ ]
391
+ });
392
+ }
393
+ async run(accessor) {
394
+ return that.userDataProfileImportExportService.createProfile();
395
+ }
396
+ }));
397
+ }
398
+ registerDeleteProfileAction() {
399
+ this._register(registerAction2(class DeleteProfileAction extends Action2 {
400
+ constructor() {
401
+ super({
402
+ id: 'workbench.profiles.actions.deleteProfile',
403
+ title: ( localize2WithPath(_moduleId, 18, "Delete Profile...")),
404
+ category: PROFILES_CATEGORY,
405
+ f1: true,
406
+ precondition: ( (ContextKeyExpr.and(PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT))),
407
+ menu: [
408
+ {
409
+ id: ProfilesMenu,
410
+ group: '3_manage_profiles',
411
+ when: PROFILES_ENABLEMENT_CONTEXT,
412
+ order: 2
413
+ }
414
+ ]
415
+ });
416
+ }
417
+ async run(accessor) {
418
+ const quickInputService = accessor.get(IQuickInputService);
419
+ const userDataProfileService = accessor.get(IUserDataProfileService);
420
+ const userDataProfilesService = accessor.get(IUserDataProfilesService);
421
+ const userDataProfileManagementService = accessor.get(IUserDataProfileManagementService);
422
+ const notificationService = accessor.get(INotificationService);
423
+ const profiles = userDataProfilesService.profiles.filter(p => !p.isDefault && !p.isTransient);
424
+ if (profiles.length) {
425
+ const picks = await quickInputService.pick(( (profiles.map(profile => ({
426
+ label: profile.name,
427
+ description: profile.id === userDataProfileService.currentProfile.id ? ( localizeWithPath(_moduleId, 19, "Current")) : undefined,
428
+ profile
429
+ })))), {
430
+ title: ( localizeWithPath(_moduleId, 20, "Delete Profile...")),
431
+ placeHolder: ( localizeWithPath(_moduleId, 21, "Select Profiles to Delete")),
432
+ canPickMany: true
433
+ });
434
+ if (picks) {
435
+ try {
436
+ await Promise.all(( (picks.map(pick => userDataProfileManagementService.removeProfile(pick.profile)))));
437
+ }
438
+ catch (error) {
439
+ notificationService.error(error);
440
+ }
441
+ }
442
+ }
443
+ }
444
+ }));
445
+ }
446
+ registerHelpAction() {
447
+ this._register(registerAction2(class HelpAction extends Action2 {
448
+ constructor() {
449
+ super({
450
+ id: 'workbench.profiles.actions.help',
451
+ title: PROFILES_TITLE,
452
+ category: Categories.Help,
453
+ menu: [{
454
+ id: MenuId.CommandPalette,
455
+ }],
456
+ });
457
+ }
458
+ run(accessor) {
459
+ return accessor.get(IOpenerService).open(( (URI.parse('https://aka.ms/vscode-profiles-help'))));
460
+ }
461
+ }));
462
+ }
463
+ async getProfileTemplatesQuickPickItems() {
464
+ const quickPickItems = [];
465
+ const profileTemplates = await this.userDataProfileManagementService.getBuiltinProfileTemplates();
466
+ for (const template of profileTemplates) {
467
+ quickPickItems.push({
468
+ label: template.name,
469
+ ...template
470
+ });
471
+ }
472
+ return quickPickItems;
473
+ }
474
+ async reportWorkspaceProfileInfo() {
475
+ await this.lifecycleService.when(4 );
476
+ const workspaceId = await this.workspaceTagsService.getTelemetryWorkspaceId(this.workspaceContextService.getWorkspace(), this.workspaceContextService.getWorkbenchState());
477
+ this.telemetryService.publicLog2('workspaceProfileInfo', {
478
+ workspaceId,
479
+ defaultProfile: this.userDataProfileService.currentProfile.isDefault
480
+ });
481
+ }
482
+ };
483
+ UserDataProfilesWorkbenchContribution = ( (__decorate([
484
+ ( (__param(0, IUserDataProfileService))),
485
+ ( (__param(1, IUserDataProfilesService))),
486
+ ( (__param(2, IUserDataProfileManagementService))),
487
+ ( (__param(3, IUserDataProfileImportExportService))),
488
+ ( (__param(4, ITelemetryService))),
489
+ ( (__param(5, IWorkspaceContextService))),
490
+ ( (__param(6, IWorkspaceTagsService))),
491
+ ( (__param(7, IContextKeyService))),
492
+ ( (__param(8, ILifecycleService)))
493
+ ], UserDataProfilesWorkbenchContribution)));
494
+
495
+ export { UserDataProfilesWorkbenchContribution };
@@ -0,0 +1,159 @@
1
+ import { Separator } from 'vscode/vscode/vs/base/common/actions';
2
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
3
+ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
4
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
5
+ import { createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
6
+ import { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
7
+ import { IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions.service';
8
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
9
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
10
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
11
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
12
+ import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
13
+ import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
14
+ import { PROFILES_CATEGORY, PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT, MANAGE_PROFILES_ACTION_ID, ProfilesMenu } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
15
+ import { IUserDataProfileManagementService, IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
16
+
17
+ const _moduleId = "vs/workbench/contrib/userDataProfile/browser/userDataProfileActions";
18
+ class CreateTransientProfileAction extends Action2 {
19
+ static { this.ID = 'workbench.profiles.actions.createTemporaryProfile'; }
20
+ static { this.TITLE = ( localize2WithPath(_moduleId, 0, "Create a Temporary Profile")); }
21
+ constructor() {
22
+ super({
23
+ id: CreateTransientProfileAction.ID,
24
+ title: CreateTransientProfileAction.TITLE,
25
+ category: PROFILES_CATEGORY,
26
+ f1: true,
27
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
28
+ });
29
+ }
30
+ async run(accessor) {
31
+ return accessor.get(IUserDataProfileManagementService).createAndEnterTransientProfile();
32
+ }
33
+ }
34
+ registerAction2(CreateTransientProfileAction);
35
+ class RenameProfileAction extends Action2 {
36
+ static { this.ID = 'workbench.profiles.actions.renameProfile'; }
37
+ constructor() {
38
+ super({
39
+ id: RenameProfileAction.ID,
40
+ title: ( localize2WithPath(_moduleId, 1, "Rename...")),
41
+ category: PROFILES_CATEGORY,
42
+ f1: true,
43
+ precondition: ( (ContextKeyExpr.and(PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT))),
44
+ });
45
+ }
46
+ async run(accessor, profile) {
47
+ const quickInputService = accessor.get(IQuickInputService);
48
+ const userDataProfileService = accessor.get(IUserDataProfileService);
49
+ const userDataProfilesService = accessor.get(IUserDataProfilesService);
50
+ const userDataProfileManagementService = accessor.get(IUserDataProfileManagementService);
51
+ const notificationService = accessor.get(INotificationService);
52
+ if (!profile) {
53
+ profile = await this.pickProfile(quickInputService, userDataProfileService, userDataProfilesService);
54
+ }
55
+ if (!profile || profile.isDefault) {
56
+ return;
57
+ }
58
+ const name = await quickInputService.input({
59
+ value: profile.name,
60
+ title: ( localizeWithPath(_moduleId, 2, 'Rename {0}', profile.name)),
61
+ validateInput: async (value) => {
62
+ if (profile.name !== value && ( (userDataProfilesService.profiles.some(p => p.name === value)))) {
63
+ return ( localizeWithPath(_moduleId, 3, "Profile with name {0} already exists.", value));
64
+ }
65
+ return undefined;
66
+ }
67
+ });
68
+ if (name && name !== profile.name) {
69
+ try {
70
+ await userDataProfileManagementService.updateProfile(profile, { name });
71
+ }
72
+ catch (error) {
73
+ notificationService.error(error);
74
+ }
75
+ }
76
+ }
77
+ async pickProfile(quickInputService, userDataProfileService, userDataProfilesService) {
78
+ const profiles = userDataProfilesService.profiles.filter(p => !p.isDefault && !p.isTransient);
79
+ if (!profiles.length) {
80
+ return undefined;
81
+ }
82
+ const pick = await quickInputService.pick(( (profiles.map(profile => ({
83
+ label: profile.name,
84
+ description: profile.id === userDataProfileService.currentProfile.id ? ( localizeWithPath(_moduleId, 4, "Current")) : undefined,
85
+ profile
86
+ })))), {
87
+ title: ( localizeWithPath(_moduleId, 5, "Rename Profile...")),
88
+ placeHolder: ( localizeWithPath(_moduleId, 6, "Select Profile to Rename")),
89
+ });
90
+ return pick?.profile;
91
+ }
92
+ }
93
+ registerAction2(RenameProfileAction);
94
+ registerAction2(class ManageProfilesAction extends Action2 {
95
+ constructor() {
96
+ super({
97
+ id: MANAGE_PROFILES_ACTION_ID,
98
+ title: ( localize2WithPath(_moduleId, 7, "Manage...")),
99
+ category: PROFILES_CATEGORY,
100
+ precondition: ( (ContextKeyExpr.and(PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT))),
101
+ });
102
+ }
103
+ async run(accessor) {
104
+ const quickInputService = accessor.get(IQuickInputService);
105
+ const menuService = accessor.get(IMenuService);
106
+ const contextKeyService = accessor.get(IContextKeyService);
107
+ const commandService = accessor.get(ICommandService);
108
+ const menu = menuService.createMenu(ProfilesMenu, contextKeyService);
109
+ const actions = [];
110
+ createAndFillInActionBarActions(menu, undefined, actions);
111
+ menu.dispose();
112
+ if (actions.length) {
113
+ const picks = ( (actions.map(action => {
114
+ if (action instanceof Separator) {
115
+ return { type: 'separator' };
116
+ }
117
+ return {
118
+ id: action.id,
119
+ label: `${action.label}${action.checked ? ` $(${Codicon.check.id})` : ''}`,
120
+ };
121
+ })));
122
+ const pick = await quickInputService.pick(picks, { canPickMany: false, title: PROFILES_CATEGORY.value });
123
+ if (pick?.id) {
124
+ await commandService.executeCommand(pick.id);
125
+ }
126
+ }
127
+ }
128
+ });
129
+ registerAction2(class CleanupProfilesAction extends Action2 {
130
+ constructor() {
131
+ super({
132
+ id: 'workbench.profiles.actions.cleanupProfiles',
133
+ title: ( localize2WithPath(_moduleId, 8, "Cleanup Profiles")),
134
+ category: Categories.Developer,
135
+ f1: true,
136
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
137
+ });
138
+ }
139
+ async run(accessor) {
140
+ return accessor.get(IUserDataProfilesService).cleanUp();
141
+ }
142
+ });
143
+ registerAction2(class ResetWorkspacesAction extends Action2 {
144
+ constructor() {
145
+ super({
146
+ id: 'workbench.profiles.actions.resetWorkspaces',
147
+ title: ( localize2WithPath(_moduleId, 9, "Reset Workspace Profiles Associations")),
148
+ category: Categories.Developer,
149
+ f1: true,
150
+ precondition: PROFILES_ENABLEMENT_CONTEXT,
151
+ });
152
+ }
153
+ async run(accessor) {
154
+ const userDataProfilesService = accessor.get(IUserDataProfilesService);
155
+ return userDataProfilesService.resetWorkspaces();
156
+ }
157
+ });
158
+
159
+ export { RenameProfileAction };
@@ -0,0 +1,24 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { getErrorMessage } from 'vscode/vscode/vs/base/common/errors';
3
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
5
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
6
+ import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService.service';
7
+ import { IUserDataProfileImportExportService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
8
+
9
+ let UserDataProfilePreviewContribution = class UserDataProfilePreviewContribution extends Disposable {
10
+ constructor(environmentService, userDataProfileImportExportService, logService) {
11
+ super();
12
+ if (environmentService.options?.profileToPreview) {
13
+ userDataProfileImportExportService.importProfile(URI.revive(environmentService.options.profileToPreview), { mode: 'both' })
14
+ .then(null, error => logService.error('Error while previewing the profile', getErrorMessage(error)));
15
+ }
16
+ }
17
+ };
18
+ UserDataProfilePreviewContribution = ( __decorate([
19
+ ( __param(0, IBrowserWorkbenchEnvironmentService)),
20
+ ( __param(1, IUserDataProfileImportExportService)),
21
+ ( __param(2, ILogService))
22
+ ], UserDataProfilePreviewContribution));
23
+
24
+ export { UserDataProfilePreviewContribution };