-
Notifications
You must be signed in to change notification settings - Fork 27.9k
/
userDataProfile.ts
593 lines (546 loc) · 24.3 KB
/
userDataProfile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { isWeb } from 'vs/base/common/platform';
import { Event } from 'vs/base/common/event';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import { localize } from 'vs/nls';
import { Action2, ISubmenuItem, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IProductService } from 'vs/platform/product/common/productService';
import { Registry } from 'vs/platform/registry/common/platform';
import { IUserDataProfile, IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG } from 'vs/platform/userDataProfile/common/userDataProfile';
import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { RenameProfileAction } from 'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions';
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { CURRENT_PROFILE_CONTEXT, HAS_PROFILES_CONTEXT, isUserDataProfileTemplate, IS_CURRENT_PROFILE_TRANSIENT_CONTEXT, IS_PROFILE_IMPORT_IN_PROGRESS_CONTEXT, IUserDataProfileImportExportService, IUserDataProfileManagementService, IUserDataProfileService, IUserDataProfileTemplate, ManageProfilesSubMenu, PROFILES_CATEGORY, PROFILES_ENABLEMENT_CONTEXT, PROFILES_TTILE, PROFILE_FILTER, IS_PROFILE_EXPORT_IN_PROGRESS_CONTEXT, defaultUserDataProfileIcon } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
import { IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IDialogService, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { getAllCodicons, getCodiconFontCharacters } from 'vs/base/common/codicons';
import { IFileService } from 'vs/platform/files/common/files';
import { asJson, asText, IRequestService } from 'vs/platform/request/common/request';
import { CancellationToken } from 'vs/base/common/cancellation';
import { URI } from 'vs/base/common/uri';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceTagsService } from 'vs/workbench/contrib/tags/common/workspaceTags';
import { getErrorMessage } from 'vs/base/common/errors';
import { ThemeIcon } from 'vs/base/common/themables';
import { distinct } from 'vs/base/common/arrays';
const SelectProfileSubMenu = new MenuId('SelectProfile');
const CREATE_EMPTY_PROFILE_ACTION_ID = 'workbench.profiles.actions.createEmptyProfile';
const CREATE_EMPTY_PROFILE_ACTION_TITLE = {
value: localize('create empty profile', "Create an Empty Profile..."),
original: 'Create an Empty Profile...'
};
const CREATE_FROM_CURRENT_PROFILE_ACTION_ID = 'workbench.profiles.actions.createFromCurrentProfile';
const CREATE_FROM_CURRENT_PROFILE_ACTION_TITLE = {
value: localize('save profile as', "Create from Current Profile..."),
original: 'Create from Current Profile...'
};
export class UserDataProfilesWorkbenchContribution extends Disposable implements IWorkbenchContribution {
private readonly currentProfileContext: IContextKey<string>;
private readonly isCurrentProfileTransientContext: IContextKey<boolean>;
private readonly hasProfilesContext: IContextKey<boolean>;
constructor(
@IUserDataProfileService private readonly userDataProfileService: IUserDataProfileService,
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
@IUserDataProfileManagementService private readonly userDataProfileManagementService: IUserDataProfileManagementService,
@IProductService private readonly productService: IProductService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService,
@IContextKeyService contextKeyService: IContextKeyService,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@INotificationService private readonly notificationService: INotificationService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
) {
super();
this.registerConfiguration();
this.currentProfileContext = CURRENT_PROFILE_CONTEXT.bindTo(contextKeyService);
PROFILES_ENABLEMENT_CONTEXT.bindTo(contextKeyService).set(this.userDataProfilesService.isEnabled());
this.isCurrentProfileTransientContext = IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.bindTo(contextKeyService);
this.currentProfileContext.set(this.userDataProfileService.currentProfile.id);
this.isCurrentProfileTransientContext.set(!!this.userDataProfileService.currentProfile.isTransient);
this._register(this.userDataProfileService.onDidChangeCurrentProfile(e => {
this.currentProfileContext.set(this.userDataProfileService.currentProfile.id);
this.isCurrentProfileTransientContext.set(!!this.userDataProfileService.currentProfile.isTransient);
}));
this.hasProfilesContext = HAS_PROFILES_CONTEXT.bindTo(contextKeyService);
this.hasProfilesContext.set(this.userDataProfilesService.profiles.length > 1);
this._register(this.userDataProfilesService.onDidChangeProfiles(e => this.hasProfilesContext.set(this.userDataProfilesService.profiles.length > 1)));
this.registerActions();
if (isWeb) {
lifecycleService.when(LifecyclePhase.Eventually).then(() => userDataProfilesService.cleanUp());
}
this.reportWorkspaceProfileInfo();
}
private registerConfiguration(): void {
if (this.productService.quality === 'stable') {
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
...workbenchConfigurationNodeBase,
'properties': {
[PROFILES_ENABLEMENT_CONFIG]: {
'type': 'boolean',
'default': false,
'description': localize('workbench.experimental.profiles.enabled', "Controls whether to enable the Profiles preview feature."),
scope: ConfigurationScope.APPLICATION,
ignoreSync: true
}
}
});
}
}
private registerActions(): void {
this.registerManageProfilesSubMenu();
this.registerSelectProfileSubMenu();
this.registerProfilesActions();
this._register(this.userDataProfilesService.onDidChangeProfiles(() => this.registerProfilesActions()));
this.registerCurrentProfilesActions();
this._register(Event.any(this.userDataProfileService.onDidChangeCurrentProfile, this.userDataProfileService.onDidUpdateCurrentProfile)(() => this.registerCurrentProfilesActions()));
this.registerCreateEmptyProfileAction();
this.registerCreateFromCurrentProfileAction();
this.registerCreateProfileAction();
}
private registerManageProfilesSubMenu(): void {
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, <ISubmenuItem>{
title: PROFILES_TTILE,
submenu: ManageProfilesSubMenu,
group: '5_settings',
when: PROFILES_ENABLEMENT_CONTEXT,
order: 1
});
}
private registerSelectProfileSubMenu(): IDisposable {
const that = this;
return MenuRegistry.appendMenuItem(ManageProfilesSubMenu, <ISubmenuItem>{
get title() { return localize('profile', "Profile ({0})", that.userDataProfileService.currentProfile.name); },
submenu: SelectProfileSubMenu,
group: '0_profiles',
when: PROFILES_ENABLEMENT_CONTEXT,
});
}
private readonly profilesDisposable = this._register(new MutableDisposable<DisposableStore>());
private registerProfilesActions(): void {
this.profilesDisposable.value = new DisposableStore();
for (const profile of this.userDataProfilesService.profiles) {
this.profilesDisposable.value.add(this.registerProfileEntryAction(profile));
}
}
private registerProfileEntryAction(profile: IUserDataProfile): IDisposable {
const that = this;
return registerAction2(class ProfileEntryAction extends Action2 {
constructor() {
super({
id: `workbench.profiles.actions.profileEntry.${profile.id}`,
title: profile.name,
toggled: ContextKeyExpr.equals(CURRENT_PROFILE_CONTEXT.key, profile.id),
menu: [
{
id: SelectProfileSubMenu,
group: '0_profiles',
when: PROFILES_ENABLEMENT_CONTEXT,
}
]
});
}
async run(accessor: ServicesAccessor) {
if (that.userDataProfileService.currentProfile.id !== profile.id) {
return that.userDataProfileManagementService.switchProfile(profile);
}
}
});
}
private readonly currentprofileActionsDisposable = this._register(new MutableDisposable<DisposableStore>());
private registerCurrentProfilesActions(): void {
this.currentprofileActionsDisposable.value = new DisposableStore();
this.currentprofileActionsDisposable.value.add(this.registerChangeIconForCurrentProfileAction());
this.currentprofileActionsDisposable.value.add(this.registerRenameCurrentProfileAction());
this.currentprofileActionsDisposable.value.add(this.registerShowCurrentProfileContentsAction());
this.currentprofileActionsDisposable.value.add(this.registerExportCurrentProfileAction());
this.currentprofileActionsDisposable.value.add(this.registerImportProfileAction());
}
private registerChangeIconForCurrentProfileAction(): IDisposable {
const that = this;
return registerAction2(class ChangeIconForCurrentProfileAction extends Action2 {
constructor() {
super({
id: `workbench.profiles.actions.changeIconForCurrentProfile`,
title: {
value: localize('change icon', "Change Icon..."),
original: `Change Icon...`
},
menu: [
{
id: ManageProfilesSubMenu,
group: '2_manage_current',
when: ContextKeyExpr.and(ContextKeyExpr.notEquals(CURRENT_PROFILE_CONTEXT.key, that.userDataProfilesService.defaultProfile.id), IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.toNegated()),
order: 1
}
]
});
}
async run(accessor: ServicesAccessor) {
const profile = that.userDataProfileService.currentProfile;
const shortName = await that.pickIcon(profile);
if (shortName && shortName !== profile.shortName) {
try {
await that.userDataProfileManagementService.updateProfile(profile, { shortName });
} catch (error) {
that.notificationService.error(error);
}
}
}
});
}
private registerRenameCurrentProfileAction(): IDisposable {
const that = this;
return registerAction2(class RenameCurrentProfileAction extends Action2 {
constructor() {
super({
id: `workbench.profiles.actions.renameCurrentProfile`,
title: {
value: localize('rename profile', "Rename..."),
original: `Rename...`
},
menu: [
{
id: ManageProfilesSubMenu,
group: '2_manage_current',
when: ContextKeyExpr.and(ContextKeyExpr.notEquals(CURRENT_PROFILE_CONTEXT.key, that.userDataProfilesService.defaultProfile.id), IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.toNegated()),
order: 2
}
]
});
}
async run(accessor: ServicesAccessor) {
accessor.get(ICommandService).executeCommand(RenameProfileAction.ID, that.userDataProfileService.currentProfile);
}
});
}
private registerShowCurrentProfileContentsAction(): IDisposable {
const id = 'workbench.profiles.actions.showProfileContents';
return registerAction2(class ShowProfileContentsAction extends Action2 {
constructor() {
super({
id,
title: {
value: localize('show profile contents', "Show Contents..."),
original: `ShowContents...`
},
category: PROFILES_CATEGORY,
menu: [
{
id: ManageProfilesSubMenu,
group: '2_manage_current',
when: PROFILES_ENABLEMENT_CONTEXT,
order: 3
}, {
id: MenuId.CommandPalette
}
]
});
}
async run(accessor: ServicesAccessor) {
const userDataProfileImportExportService = accessor.get(IUserDataProfileImportExportService);
return userDataProfileImportExportService.showProfileContents();
}
});
}
private registerExportCurrentProfileAction(): IDisposable {
const that = this;
const disposables = new DisposableStore();
const id = 'workbench.profiles.actions.exportProfile';
disposables.add(registerAction2(class ExportProfileAction extends Action2 {
constructor() {
super({
id,
title: {
value: localize('export profile', "Export Profile ({0})...", that.userDataProfileService.currentProfile.name),
original: `Export Profile (${that.userDataProfileService.currentProfile.name})...`
},
category: PROFILES_CATEGORY,
precondition: IS_PROFILE_EXPORT_IN_PROGRESS_CONTEXT.toNegated(),
menu: [
{
id: ManageProfilesSubMenu,
group: '4_import_export_profiles',
when: PROFILES_ENABLEMENT_CONTEXT,
order: 1
}, {
id: MenuId.CommandPalette
}
]
});
}
async run(accessor: ServicesAccessor) {
const userDataProfileImportExportService = accessor.get(IUserDataProfileImportExportService);
return userDataProfileImportExportService.exportProfile();
}
}));
disposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarShare, {
command: {
id,
title: {
value: localize('export profile in share', "Export Profile ({0})...", that.userDataProfileService.currentProfile.name),
original: `Export Profile (${that.userDataProfileService.currentProfile.name})...`
},
precondition: PROFILES_ENABLEMENT_CONTEXT,
},
}));
return disposables;
}
private registerImportProfileAction(): IDisposable {
const disposables = new DisposableStore();
const id = 'workbench.profiles.actions.importProfile';
disposables.add(registerAction2(class ImportProfileAction extends Action2 {
constructor() {
super({
id,
title: {
value: localize('import profile', "Import Profile..."),
original: 'Import Profile...'
},
category: PROFILES_CATEGORY,
f1: true,
precondition: IS_PROFILE_IMPORT_IN_PROGRESS_CONTEXT.toNegated(),
menu: [
{
id: ManageProfilesSubMenu,
group: '4_import_export_profiles',
when: PROFILES_ENABLEMENT_CONTEXT,
order: 2
}
]
});
}
async run(accessor: ServicesAccessor) {
const fileDialogService = accessor.get(IFileDialogService);
const quickInputService = accessor.get(IQuickInputService);
const fileService = accessor.get(IFileService);
const requestService = accessor.get(IRequestService);
const userDataProfileImportExportService = accessor.get(IUserDataProfileImportExportService);
const dialogService = accessor.get(IDialogService);
const contextKeyService = accessor.get(IContextKeyService);
const notificationService = accessor.get(INotificationService);
const isSettingProfilesEnabled = contextKeyService.contextMatchesRules(PROFILES_ENABLEMENT_CONTEXT);
if (!isSettingProfilesEnabled) {
if (!(await dialogService.confirm({
title: localize('import profile title', "Import Settings from a Profile"),
message: localize('confiirmation message', "This will replace your current settings. Are you sure you want to continue?"),
})).confirmed) {
return;
}
}
const disposables = new DisposableStore();
const quickPick = disposables.add(quickInputService.createQuickPick());
const updateQuickPickItems = (value?: string) => {
const selectFromFileItem: IQuickPickItem = { label: localize('import from file', "Import from profile file") };
quickPick.items = value ? [{ label: localize('import from url', "Import from URL"), description: quickPick.value }, selectFromFileItem] : [selectFromFileItem];
};
quickPick.title = localize('import profile quick pick title', "Import Profile");
quickPick.placeholder = localize('import profile placeholder', "Provide profile URL or select profile file to import");
quickPick.ignoreFocusOut = true;
disposables.add(quickPick.onDidChangeValue(updateQuickPickItems));
updateQuickPickItems();
quickPick.matchOnLabel = false;
quickPick.matchOnDescription = false;
disposables.add(quickPick.onDidAccept(async () => {
try {
quickPick.hide();
if (isSettingProfilesEnabled) {
const profile = quickPick.selectedItems[0].description ? URI.parse(quickPick.value) : await this.getProfileUriFromFileSystem(fileDialogService);
if (profile) {
await userDataProfileImportExportService.importProfile(profile);
}
} else {
const profile = quickPick.selectedItems[0].description ? await this.getProfileFromURL(quickPick.value, requestService) : await this.getProfileFromFileSystem(fileDialogService, fileService);
if (profile) {
await userDataProfileImportExportService.setProfile(profile);
}
}
} catch (error) {
notificationService.error(localize('profile import error', "Error while importing profile: {0}", getErrorMessage(error)));
}
}));
disposables.add(quickPick.onDidHide(() => disposables.dispose()));
quickPick.show();
}
private async getProfileUriFromFileSystem(fileDialogService: IFileDialogService): Promise<URI | null> {
const profileLocation = await fileDialogService.showOpenDialog({
canSelectFolders: false,
canSelectFiles: true,
canSelectMany: false,
filters: PROFILE_FILTER,
title: localize('import profile dialog', "Import Profile"),
});
if (!profileLocation) {
return null;
}
return profileLocation[0];
}
private async getProfileFromFileSystem(fileDialogService: IFileDialogService, fileService: IFileService): Promise<IUserDataProfileTemplate | null> {
const profileLocation = await this.getProfileUriFromFileSystem(fileDialogService);
if (!profileLocation) {
return null;
}
const content = (await fileService.readFile(profileLocation)).value.toString();
const parsed = JSON.parse(content);
return isUserDataProfileTemplate(parsed) ? parsed : null;
}
private async getProfileFromURL(url: string, requestService: IRequestService): Promise<IUserDataProfileTemplate | null> {
const options = { type: 'GET', url };
const context = await requestService.request(options, CancellationToken.None);
if (context.res.statusCode === 200) {
const result = await asJson(context);
return isUserDataProfileTemplate(result) ? result : null;
} else {
const message = await asText(context);
throw new Error(`Expected 200, got back ${context.res.statusCode} instead.\n\n${message}`);
}
}
}));
disposables.add(MenuRegistry.appendMenuItem(MenuId.MenubarShare, {
command: {
id,
title: {
value: localize('import profile share', "Import Profile...",),
original: 'Import Profile...'
},
precondition: PROFILES_ENABLEMENT_CONTEXT,
},
}));
return disposables;
}
private registerCreateFromCurrentProfileAction(): void {
const that = this;
this._register(registerAction2(class CreateFromCurrentProfileAction extends Action2 {
constructor() {
super({
id: CREATE_FROM_CURRENT_PROFILE_ACTION_ID,
title: CREATE_FROM_CURRENT_PROFILE_ACTION_TITLE,
category: PROFILES_CATEGORY,
f1: true,
precondition: PROFILES_ENABLEMENT_CONTEXT
});
}
run(accessor: ServicesAccessor) {
return that.createProfile(true);
}
}));
}
private registerCreateEmptyProfileAction(): void {
const that = this;
this._register(registerAction2(class CreateEmptyProfileAction extends Action2 {
constructor() {
super({
id: CREATE_EMPTY_PROFILE_ACTION_ID,
title: CREATE_EMPTY_PROFILE_ACTION_TITLE,
category: PROFILES_CATEGORY,
f1: true,
precondition: PROFILES_ENABLEMENT_CONTEXT
});
}
run(accessor: ServicesAccessor) {
return that.createProfile(false);
}
}));
}
private async createProfile(fromExisting: boolean): Promise<void> {
const name = await this.quickInputService.input({
placeHolder: localize('name', "Profile name"),
title: fromExisting ? localize('create from current profle', "Create from Current Profile...") : localize('create empty profile', "Create an Empty Profile..."),
validateInput: async (value: string) => {
if (this.userDataProfilesService.profiles.some(p => p.name === value)) {
return localize('profileExists', "Profile with name {0} already exists.", value);
}
return undefined;
}
});
if (!name) {
return;
}
try {
await this.userDataProfileManagementService.createAndEnterProfile(name, undefined, fromExisting);
} catch (error) {
this.notificationService.error(error);
}
}
private async pickIcon(profile?: IUserDataProfile): Promise<string | undefined> {
const codiconQuickPicks: Array<IQuickPickItem | IQuickPickSeparator> = [];
codiconQuickPicks.push({ label: `$(${defaultUserDataProfileIcon.id})`, description: localize('default', "Default") });
codiconQuickPicks.push({ label: '', type: 'separator' });
const currentIcon = profile?.shortName ? ThemeIcon.fromString(profile.shortName) : undefined;
const fontCharacters = getCodiconFontCharacters();
for (const codicon of distinct(getAllCodicons(), c => fontCharacters[c.id])) {
codiconQuickPicks.push({ label: `$(${codicon.id})`, description: `${codicon.id}${currentIcon?.id === codicon.id ? ` (${localize('current', "Current")})` : ''}` });
}
const result = await this.quickInputService.pick(codiconQuickPicks, {
title: profile ? localize('change icon title', "Change icon for {0} Profile", profile.name) : localize('pick icon', "Pick icon..."),
matchOnDescription: true,
});
return result?.label;
}
private registerCreateProfileAction(): void {
this._register(registerAction2(class CreateProfileAction extends Action2 {
constructor() {
super({
id: 'workbench.profiles.actions.createProfile',
title: {
value: localize('create profile', "Create Profile..."),
original: 'Create Profile...'
},
category: PROFILES_CATEGORY,
precondition: PROFILES_ENABLEMENT_CONTEXT,
menu: [
{
id: ManageProfilesSubMenu,
group: '3_manage_profiles',
when: PROFILES_ENABLEMENT_CONTEXT,
order: 1
}
]
});
}
async run(accessor: ServicesAccessor) {
const quickInputService = accessor.get(IQuickInputService);
const commandService = accessor.get(ICommandService);
const pick = await quickInputService.pick(
[{
id: CREATE_EMPTY_PROFILE_ACTION_ID,
label: CREATE_EMPTY_PROFILE_ACTION_TITLE.value,
}, {
id: CREATE_FROM_CURRENT_PROFILE_ACTION_ID,
label: CREATE_FROM_CURRENT_PROFILE_ACTION_TITLE.value,
}], { hideInput: true, canPickMany: false, title: localize('create profile title', "{0}: Create...", PROFILES_CATEGORY.value) });
if (pick?.id) {
return commandService.executeCommand(pick.id);
}
}
}));
}
private async reportWorkspaceProfileInfo(): Promise<void> {
await this.lifecycleService.when(LifecyclePhase.Eventually);
const workspaceId = await this.workspaceTagsService.getTelemetryWorkspaceId(this.workspaceContextService.getWorkspace(), this.workspaceContextService.getWorkbenchState());
type WorkspaceProfileInfoClassification = {
owner: 'sandy081';
comment: 'Report profile information of the current workspace';
workspaceId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'A UUID given to a workspace to identify it.' };
defaultProfile: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether the profile of the workspace is default or not.' };
};
type WorkspaceProfileInfoEvent = {
workspaceId: string | undefined;
defaultProfile: boolean;
};
this.telemetryService.publicLog2<WorkspaceProfileInfoEvent, WorkspaceProfileInfoClassification>('workspaceProfileInfo', {
workspaceId,
defaultProfile: this.userDataProfileService.currentProfile.isDefault
});
}
}