Skip to content

Commit 1c7c331

Browse files
authored
remove unused enablement code (microsoft#230470)
1 parent a877519 commit 1c7c331

File tree

12 files changed

+29
-116
lines changed

12 files changed

+29
-116
lines changed

src/vs/platform/userDataProfile/common/userDataProfile.ts

+8-48
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export interface IUserDataProfilesService {
109109

110110
readonly onDidResetWorkspaces: Event<void>;
111111

112-
isEnabled(): boolean;
113112
createNamedProfile(name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: IAnyWorkspaceIdentifier): Promise<IUserDataProfile>;
114113
createTransientProfile(workspaceIdentifier?: IAnyWorkspaceIdentifier): Promise<IUserDataProfile>;
115114
createProfile(id: string, name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: IAnyWorkspaceIdentifier): Promise<IUserDataProfile>;
@@ -190,7 +189,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
190189

191190
readonly _serviceBrand: undefined;
192191

193-
protected enabled: boolean = true;
194192
readonly profilesHome: URI;
195193
private readonly profilesCacheHome: URI;
196194

@@ -231,34 +229,21 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
231229
this._profilesObject = undefined;
232230
}
233231

234-
setEnablement(enabled: boolean): void {
235-
if (this.enabled !== enabled) {
236-
this._profilesObject = undefined;
237-
this.enabled = enabled;
238-
}
239-
}
240-
241-
isEnabled(): boolean {
242-
return this.enabled;
243-
}
244-
245232
protected _profilesObject: UserDataProfilesObject | undefined;
246233
protected get profilesObject(): UserDataProfilesObject {
247234
if (!this._profilesObject) {
248235
const defaultProfile = this.createDefaultProfile();
249236
const profiles: Array<Mutable<IUserDataProfile>> = [defaultProfile];
250-
if (this.enabled) {
251-
try {
252-
for (const storedProfile of this.getStoredProfiles()) {
253-
if (!storedProfile.name || !isString(storedProfile.name) || !storedProfile.location) {
254-
this.logService.warn('Skipping the invalid stored profile', storedProfile.location || storedProfile.name);
255-
continue;
256-
}
257-
profiles.push(toUserDataProfile(basename(storedProfile.location), storedProfile.name, storedProfile.location, this.profilesCacheHome, { shortName: storedProfile.shortName, icon: storedProfile.icon, useDefaultFlags: storedProfile.useDefaultFlags }, defaultProfile));
237+
try {
238+
for (const storedProfile of this.getStoredProfiles()) {
239+
if (!storedProfile.name || !isString(storedProfile.name) || !storedProfile.location) {
240+
this.logService.warn('Skipping the invalid stored profile', storedProfile.location || storedProfile.name);
241+
continue;
258242
}
259-
} catch (error) {
260-
this.logService.error(error);
243+
profiles.push(toUserDataProfile(basename(storedProfile.location), storedProfile.name, storedProfile.location, this.profilesCacheHome, { shortName: storedProfile.shortName, icon: storedProfile.icon, useDefaultFlags: storedProfile.useDefaultFlags }, defaultProfile));
261244
}
245+
} catch (error) {
246+
this.logService.error(error);
262247
}
263248
const emptyWindows = new Map<string, IUserDataProfile>();
264249
if (profiles.length) {
@@ -315,10 +300,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
315300
}
316301

317302
async createProfile(id: string, name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: IAnyWorkspaceIdentifier): Promise<IUserDataProfile> {
318-
if (!this.enabled) {
319-
throw new Error(`Profiles are disabled in the current environment.`);
320-
}
321-
322303
const profile = await this.doCreateProfile(id, name, options, workspaceIdentifier);
323304

324305
return profile;
@@ -369,10 +350,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
369350
}
370351

371352
async updateProfile(profile: IUserDataProfile, options: IUserDataProfileUpdateOptions): Promise<IUserDataProfile> {
372-
if (!this.enabled) {
373-
throw new Error(`Profiles are disabled in the current environment.`);
374-
}
375-
376353
const profilesToUpdate: IUserDataProfile[] = [];
377354
for (const existing of this.profiles) {
378355
let profileToUpdate: Mutable<IUserDataProfile> | undefined;
@@ -423,9 +400,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
423400
}
424401

425402
async removeProfile(profileToRemove: IUserDataProfile): Promise<void> {
426-
if (!this.enabled) {
427-
throw new Error(`Profiles are disabled in the current environment.`);
428-
}
429403
if (profileToRemove.isDefault) {
430404
throw new Error('Cannot remove default profile');
431405
}
@@ -460,10 +434,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
460434
}
461435

462436
async setProfileForWorkspace(workspaceIdentifier: IAnyWorkspaceIdentifier, profileToSet: IUserDataProfile): Promise<void> {
463-
if (!this.enabled) {
464-
throw new Error(`Profiles are disabled in the current environment.`);
465-
}
466-
467437
const profile = this.profiles.find(p => p.id === profileToSet.id);
468438
if (!profile) {
469439
throw new Error(`Profile '${profileToSet.name}' does not exist`);
@@ -483,10 +453,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
483453
}
484454

485455
unsetWorkspace(workspaceIdentifier: IAnyWorkspaceIdentifier, transient: boolean = false): void {
486-
if (!this.enabled) {
487-
throw new Error(`Profiles are disabled in the current environment.`);
488-
}
489-
490456
const workspace = this.getWorkspace(workspaceIdentifier);
491457
if (URI.isUri(workspace)) {
492458
const currentlyAssociatedProfile = this.getProfileForWorkspace(workspaceIdentifier);
@@ -510,9 +476,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
510476
}
511477

512478
async cleanUp(): Promise<void> {
513-
if (!this.enabled) {
514-
return;
515-
}
516479
if (await this.fileService.exists(this.profilesHome)) {
517480
const stat = await this.fileService.resolve(this.profilesHome);
518481
await Promise.all((stat.children || [])
@@ -522,9 +485,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
522485
}
523486

524487
async cleanUpTransientProfiles(): Promise<void> {
525-
if (!this.enabled) {
526-
return;
527-
}
528488
const unAssociatedTransientProfiles = this.transientProfilesObject.profiles.filter(p => !this.isProfileAssociatedToWorkspace(p));
529489
await Promise.allSettled(unAssociatedTransientProfiles.map(p => this.removeProfile(p)));
530490
}

src/vs/platform/userDataProfile/common/userDataProfileIpc.ts

-10
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
6767

6868
readonly onDidResetWorkspaces: Event<void>;
6969

70-
private enabled: boolean = true;
71-
7270
constructor(
7371
profiles: readonly UriDto<IUserDataProfile>[],
7472
readonly profilesHome: URI,
@@ -86,14 +84,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
8684
this.onDidResetWorkspaces = this.channel.listen<void>('onDidResetWorkspaces');
8785
}
8886

89-
setEnablement(enabled: boolean) {
90-
this.enabled = enabled;
91-
}
92-
93-
isEnabled(): boolean {
94-
return this.enabled;
95-
}
96-
9787
async createNamedProfile(name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: IAnyWorkspaceIdentifier): Promise<IUserDataProfile> {
9888
const result = await this.channel.call<UriDto<IUserDataProfile>>('createNamedProfile', [name, options, workspaceIdentifier]);
9989
return reviveProfile(result, this.profilesHome.scheme);

src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts

-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ export class UserDataProfilesManifestSynchroniser extends AbstractSynchroniser i
6767
}
6868

6969
protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<IUserDataProfilesManifestResourcePreview[]> {
70-
if (!this.userDataProfilesService.isEnabled()) {
71-
throw new UserDataSyncError('Cannot sync profiles because they are disabled', UserDataSyncErrorCode.LocalError);
72-
}
7370
const remoteProfiles: ISyncUserDataProfile[] | null = remoteUserData.syncData ? parseUserDataProfilesManifest(remoteUserData.syncData) : null;
7471
const lastSyncProfiles: ISyncUserDataProfile[] | null = lastSyncUserData?.syncData ? parseUserDataProfilesManifest(lastSyncUserData.syncData) : null;
7572
const localProfiles = this.getLocalUserDataProfiles();

src/vs/platform/userDataSync/common/userDataSyncService.ts

-8
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,6 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
515515
return isUndefined(result) ? null : result;
516516
}
517517

518-
if (this.userDataProfilesService.isEnabled()) {
519-
return null;
520-
}
521-
522518
const userDataProfileManifestSynchronizer = disposables.add(this.instantiationService.createInstance(UserDataProfilesManifestSynchroniser, profile, undefined));
523519
const manifest = await this.userDataSyncStoreService.manifest(null);
524520
const syncProfiles = (await userDataProfileManifestSynchronizer.getRemoteSyncedProfiles(manifest?.latest ?? null)) || [];
@@ -648,7 +644,6 @@ class ProfileSynchronizer extends Disposable {
648644
@IUserDataSyncStoreManagementService private readonly userDataSyncStoreManagementService: IUserDataSyncStoreManagementService,
649645
@ITelemetryService private readonly telemetryService: ITelemetryService,
650646
@IUserDataSyncLogService private readonly logService: IUserDataSyncLogService,
651-
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
652647
@IConfigurationService private readonly configurationService: IConfigurationService,
653648
) {
654649
super();
@@ -681,9 +676,6 @@ class ProfileSynchronizer extends Disposable {
681676
if (!this.profile.isDefault) {
682677
return;
683678
}
684-
if (!this.userDataProfilesService.isEnabled()) {
685-
return;
686-
}
687679
}
688680
if (syncResource === SyncResource.WorkspaceState) {
689681
return;

src/vs/platform/windows/electron-main/windowsMainService.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -1593,18 +1593,16 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
15931593
}
15941594
}
15951595

1596-
if (this.userDataProfilesMainService.isEnabled()) {
1597-
const workspace = configuration.workspace ?? toWorkspaceIdentifier(configuration.backupPath, false);
1598-
const profilePromise = this.resolveProfileForBrowserWindow(options, workspace, defaultProfile);
1599-
const profile = profilePromise instanceof Promise ? await profilePromise : profilePromise;
1600-
configuration.profiles.profile = profile;
1601-
1602-
if (!configuration.extensionDevelopmentPath) {
1603-
// Associate the configured profile to the workspace
1604-
// unless the window is for extension development,
1605-
// where we do not persist the associations
1606-
await this.userDataProfilesMainService.setProfileForWorkspace(workspace, profile);
1607-
}
1596+
const workspace = configuration.workspace ?? toWorkspaceIdentifier(configuration.backupPath, false);
1597+
const profilePromise = this.resolveProfileForBrowserWindow(options, workspace, defaultProfile);
1598+
const profile = profilePromise instanceof Promise ? await profilePromise : profilePromise;
1599+
configuration.profiles.profile = profile;
1600+
1601+
if (!configuration.extensionDevelopmentPath) {
1602+
// Associate the configured profile to the workspace
1603+
// unless the window is for extension development,
1604+
// where we do not persist the associations
1605+
await this.userDataProfilesMainService.setProfileForWorkspace(workspace, profile);
16081606
}
16091607

16101608
// Load it

src/vs/platform/workspaces/electron-main/workspacesManagementMainService.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
212212
await this.doDeleteUntitledWorkspace(workspace);
213213

214214
// unset workspace from profiles
215-
if (this.userDataProfilesMainService.isEnabled()) {
216-
this.userDataProfilesMainService.unsetWorkspace(workspace);
217-
}
215+
this.userDataProfilesMainService.unsetWorkspace(workspace);
218216

219217
// Event
220218
this._onDidDeleteUntitledWorkspace.fire(workspace);

src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
7070
private readonly defaultOverrideIndicator: SettingIndicator;
7171
private readonly allIndicators: SettingIndicator[];
7272

73-
private readonly profilesEnabled: boolean;
74-
7573
private readonly keybindingListeners: DisposableStore = new DisposableStore();
7674
private focusedIndex = 0;
7775

@@ -81,13 +79,10 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
8179
@IHoverService private readonly hoverService: IHoverService,
8280
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
8381
@ILanguageService private readonly languageService: ILanguageService,
84-
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
8582
@ICommandService private readonly commandService: ICommandService) {
8683
this.indicatorsContainerElement = DOM.append(container, $('.setting-indicators-container'));
8784
this.indicatorsContainerElement.style.display = 'inline';
8885

89-
this.profilesEnabled = this.userDataProfilesService.isEnabled();
90-
9186
this.workspaceTrustIndicator = this.createWorkspaceTrustIndicator();
9287
this.scopeOverridesIndicator = this.createScopeOverridesIndicator();
9388
this.syncIgnoredIndicator = this.createSyncIgnoredIndicator();
@@ -338,7 +333,7 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
338333
}, focus);
339334
};
340335
this.addHoverDisposables(this.scopeOverridesIndicator.disposables, this.scopeOverridesIndicator.element, showHover);
341-
} else if (this.profilesEnabled && element.settingsTarget === ConfigurationTarget.USER_LOCAL && this.configurationService.isSettingAppliedForAllProfiles(element.setting.key)) {
336+
} else if (element.settingsTarget === ConfigurationTarget.USER_LOCAL && this.configurationService.isSettingAppliedForAllProfiles(element.setting.key)) {
342337
this.scopeOverridesIndicator.element.style.display = 'inline';
343338
this.scopeOverridesIndicator.element.classList.add('setting-indicator');
344339

@@ -538,7 +533,7 @@ export function getIndicatorsLabelAriaLabel(element: SettingsTreeSettingElement,
538533

539534
if (element.hasPolicyValue) {
540535
ariaLabelSections.push(localize('policyDescriptionAccessible', "Managed by organization policy; setting value not applied"));
541-
} else if (userDataProfilesService.isEnabled() && element.settingsTarget === ConfigurationTarget.USER_LOCAL && configurationService.isSettingAppliedForAllProfiles(element.setting.key)) {
536+
} else if (element.settingsTarget === ConfigurationTarget.USER_LOCAL && configurationService.isSettingAppliedForAllProfiles(element.setting.key)) {
542537
ariaLabelSections.push(localize('applicationSettingDescriptionAccessible', "Setting value retained when switching profiles"));
543538
} else {
544539
// Add other overrides text

src/vs/workbench/contrib/preferences/browser/settingsTree.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,6 @@ export class SettingTreeRenderers extends Disposable {
20952095
@IInstantiationService private readonly _instantiationService: IInstantiationService,
20962096
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
20972097
@IContextViewService private readonly _contextViewService: IContextViewService,
2098-
@IUserDataProfilesService private readonly _userDataProfilesService: IUserDataProfilesService,
20992098
@IUserDataSyncEnablementService private readonly _userDataSyncEnablementService: IUserDataSyncEnablementService,
21002099
) {
21012100
super();
@@ -2158,7 +2157,7 @@ export class SettingTreeRenderers extends Disposable {
21582157

21592158
private getActionsForSetting(setting: ISetting, settingTarget: SettingsTarget): IAction[] {
21602159
const actions: IAction[] = [];
2161-
if (this._userDataProfilesService.isEnabled() && setting.scope !== ConfigurationScope.APPLICATION && settingTarget === ConfigurationTarget.USER_LOCAL) {
2160+
if (setting.scope !== ConfigurationScope.APPLICATION && settingTarget === ConfigurationTarget.USER_LOCAL) {
21622161
actions.push(this._instantiationService.createInstance(ApplySettingToAllProfilesAction, setting));
21632162
}
21642163
if (this._userDataSyncEnablementService.isEnabled() && !setting.disallowSyncIgnore) {

src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ContextKeyExpr, IContextKey, IContextKeyService } from '../../../../pla
1212
import { IUserDataProfile, IUserDataProfilesService } from '../../../../platform/userDataProfile/common/userDataProfile.js';
1313
import { IWorkbenchContribution } from '../../../common/contributions.js';
1414
import { ILifecycleService, LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';
15-
import { CURRENT_PROFILE_CONTEXT, HAS_PROFILES_CONTEXT, IS_CURRENT_PROFILE_TRANSIENT_CONTEXT, IUserDataProfileManagementService, IUserDataProfileService, PROFILES_CATEGORY, PROFILES_ENABLEMENT_CONTEXT, PROFILES_TITLE, isProfileURL } from '../../../services/userDataProfile/common/userDataProfile.js';
15+
import { CURRENT_PROFILE_CONTEXT, HAS_PROFILES_CONTEXT, IS_CURRENT_PROFILE_TRANSIENT_CONTEXT, IUserDataProfileManagementService, IUserDataProfileService, PROFILES_CATEGORY, PROFILES_TITLE, isProfileURL } from '../../../services/userDataProfile/common/userDataProfile.js';
1616
import { IQuickInputService, IQuickPickItem } from '../../../../platform/quickinput/common/quickInput.js';
1717
import { INotificationService } from '../../../../platform/notification/common/notification.js';
1818
import { URI } from '../../../../base/common/uri.js';
@@ -61,7 +61,6 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
6161
super();
6262

6363
this.currentProfileContext = CURRENT_PROFILE_CONTEXT.bindTo(contextKeyService);
64-
PROFILES_ENABLEMENT_CONTEXT.bindTo(contextKeyService).set(this.userDataProfilesService.isEnabled());
6564
this.isCurrentProfileTransientContext = IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.bindTo(contextKeyService);
6665

6766
this.currentProfileContext.set(this.userDataProfileService.currentProfile.id);
@@ -196,7 +195,6 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
196195
{
197196
id: ProfilesMenu,
198197
group: '0_profiles',
199-
when: PROFILES_ENABLEMENT_CONTEXT,
200198
}
201199
]
202200
});
@@ -288,7 +286,6 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
288286
title: localize2('switchProfile', 'Switch Profile...'),
289287
category: PROFILES_CATEGORY,
290288
f1: true,
291-
precondition: PROFILES_ENABLEMENT_CONTEXT,
292289
});
293290
}
294291
async run(accessor: ServicesAccessor) {
@@ -384,7 +381,6 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
384381
command: {
385382
id,
386383
title: localize2('export profile in share', "Export Profile ({0})...", that.userDataProfileService.currentProfile.name),
387-
precondition: PROFILES_ENABLEMENT_CONTEXT,
388384
},
389385
}));
390386
return disposables;
@@ -400,7 +396,6 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
400396
title: localize2('save profile as', "Save Current Profile As..."),
401397
category: PROFILES_CATEGORY,
402398
f1: true,
403-
precondition: PROFILES_ENABLEMENT_CONTEXT
404399
});
405400
}
406401

@@ -419,7 +414,6 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
419414
id: 'workbench.profiles.actions.createProfile',
420415
title: localize2('create profile', "New Profile..."),
421416
category: PROFILES_CATEGORY,
422-
precondition: PROFILES_ENABLEMENT_CONTEXT,
423417
f1: true,
424418
menu: [
425419
{
@@ -446,7 +440,7 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
446440
title: localize2('delete profile', "Delete Profile..."),
447441
category: PROFILES_CATEGORY,
448442
f1: true,
449-
precondition: ContextKeyExpr.and(PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT),
443+
precondition: HAS_PROFILES_CONTEXT,
450444
});
451445
}
452446

src/vs/workbench/contrib/userDataProfile/browser/userDataProfileActions.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Categories } from '../../../../platform/action/common/actionCommonCateg
88
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
99
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
1010
import { IUserDataProfilesService } from '../../../../platform/userDataProfile/common/userDataProfile.js';
11-
import { IUserDataProfileManagementService, PROFILES_CATEGORY, PROFILES_ENABLEMENT_CONTEXT } from '../../../services/userDataProfile/common/userDataProfile.js';
11+
import { IUserDataProfileManagementService, PROFILES_CATEGORY } from '../../../services/userDataProfile/common/userDataProfile.js';
1212

1313
class CreateTransientProfileAction extends Action2 {
1414
static readonly ID = 'workbench.profiles.actions.createTemporaryProfile';
@@ -19,7 +19,6 @@ class CreateTransientProfileAction extends Action2 {
1919
title: CreateTransientProfileAction.TITLE,
2020
category: PROFILES_CATEGORY,
2121
f1: true,
22-
precondition: PROFILES_ENABLEMENT_CONTEXT,
2322
});
2423
}
2524

@@ -39,7 +38,6 @@ registerAction2(class CleanupProfilesAction extends Action2 {
3938
title: localize2('cleanup profile', "Cleanup Profiles"),
4039
category: Categories.Developer,
4140
f1: true,
42-
precondition: PROFILES_ENABLEMENT_CONTEXT,
4341
});
4442
}
4543

@@ -55,7 +53,6 @@ registerAction2(class ResetWorkspacesAction extends Action2 {
5553
title: localize2('reset workspaces', "Reset Workspace Profiles Associations"),
5654
category: Categories.Developer,
5755
f1: true,
58-
precondition: PROFILES_ENABLEMENT_CONTEXT,
5956
});
6057
}
6158

0 commit comments

Comments
 (0)