Skip to content

Commit 1bcb42f

Browse files
authored
Merge pull request microsoft#163640 from microsoft/sandy081/helpless-gerbil
Fix microsoft#163343
2 parents 25bb575 + 2204a16 commit 1bcb42f

File tree

10 files changed

+36
-15
lines changed

10 files changed

+36
-15
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export interface IUserDataProfilesService {
106106

107107
readonly onDidResetWorkspaces: Event<void>;
108108

109+
isEnabled(): boolean;
109110
createNamedProfile(name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile>;
110111
createTransientProfile(workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile>;
111112
createProfile(id: string, name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile>;
@@ -225,6 +226,10 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
225226
}
226227
}
227228

229+
isEnabled(): boolean {
230+
return this.enabled;
231+
}
232+
228233
protected _profilesObject: UserDataProfilesObject | undefined;
229234
protected get profilesObject(): UserDataProfilesObject {
230235
if (!this._profilesObject) {

src/vs/platform/userDataProfile/electron-main/userDataProfile.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
1818

1919
export const IUserDataProfilesMainService = refineServiceDecorator<IUserDataProfilesService, IUserDataProfilesMainService>(IUserDataProfilesService);
2020
export interface IUserDataProfilesMainService extends IUserDataProfilesService {
21-
isEnabled(): boolean;
2221
getOrSetProfileForWorkspace(workspaceIdentifier: WorkspaceIdentifier, profileToSet?: IUserDataProfile): IUserDataProfile;
2322
setProfileForWorkspaceSync(workspaceIdentifier: WorkspaceIdentifier, profileToSet: IUserDataProfile): void;
2423
checkAndCreateProfileFromCli(args: NativeParsedArgs): Promise<IUserDataProfile> | undefined;
@@ -48,10 +47,6 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
4847
}
4948
}
5049

51-
isEnabled(): boolean {
52-
return this.enabled;
53-
}
54-
5550
checkAndCreateProfileFromCli(args: NativeParsedArgs): Promise<IUserDataProfile> | undefined {
5651
if (!this.isEnabled()) {
5752
return undefined;

src/vs/platform/userDataProfile/electron-sandbox/userDataProfile.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export class UserDataProfilesNativeService extends Disposable implements IUserDa
2929

3030
readonly onDidResetWorkspaces: Event<void>;
3131

32+
private enabled: boolean = true;
33+
3234
constructor(
3335
profiles: readonly UriDto<IUserDataProfile>[],
3436
@IMainProcessService mainProcessService: IMainProcessService,
@@ -48,6 +50,14 @@ export class UserDataProfilesNativeService extends Disposable implements IUserDa
4850
this.onDidResetWorkspaces = this.channel.listen<void>('onDidResetWorkspaces');
4951
}
5052

53+
setEnablement(enabled: boolean) {
54+
this.enabled = enabled;
55+
}
56+
57+
isEnabled(): boolean {
58+
return this.enabled;
59+
}
60+
5161
async createNamedProfile(name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile> {
5262
const result = await this.channel.call<UriDto<IUserDataProfile>>('createNamedProfile', [name, options, workspaceIdentifier]);
5363
return reviveProfile(result, this.profilesHome.scheme);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
418418
return isUndefined(result) ? null : result;
419419
}
420420

421+
if (this.userDataProfilesService.isEnabled()) {
422+
return null;
423+
}
424+
421425
if (this.environmentService.isBuilt && (!this.productService.enableSyncingProfiles || isEqual(this.userDataSyncStoreManagementService.userDataSyncStore?.url, this.userDataSyncStoreManagementService.userDataSyncStore?.stableUrl))) {
422426
return null;
423427
}
@@ -543,7 +547,7 @@ class ProfileSynchronizer extends Disposable {
543547
@ITelemetryService private readonly telemetryService: ITelemetryService,
544548
@IUserDataSyncLogService private readonly logService: IUserDataSyncLogService,
545549
@IProductService private readonly productService: IProductService,
546-
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
550+
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
547551
@IConfigurationService private readonly configurationService: IConfigurationService,
548552
@IEnvironmentService private readonly environmentService: IEnvironmentService,
549553
) {
@@ -590,6 +594,9 @@ class ProfileSynchronizer extends Disposable {
590594
if (!this._profile.isDefault) {
591595
return;
592596
}
597+
if (!this.userDataProfilesService.isEnabled()) {
598+
return;
599+
}
593600
if (this.environmentService.isBuilt && (!this.productService.enableSyncingProfiles || isEqual(this.userDataSyncStoreManagementService.userDataSyncStore?.url, this.userDataSyncStoreManagementService.userDataSyncStore?.stableUrl))) {
594601
this.logService.debug('Skipping profiles sync');
595602
return;

src/vs/workbench/browser/parts/activitybar/activitybarPart.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
196196
// Accounts
197197
actions.push(new Separator());
198198
actions.push(toAction({ id: 'toggleAccountsVisibility', label: localize('accounts', "Accounts"), checked: this.accountsVisibilityPreference, run: () => this.accountsVisibilityPreference = !this.accountsVisibilityPreference }));
199-
actions.push(toAction({ id: 'toggleProfilesVisibility', label: PROFILES_TTILE.value, checked: this.profilesVisibilityPreference, run: () => this.profilesVisibilityPreference = !this.profilesVisibilityPreference }));
199+
if (this.userDataProfilesService.isEnabled()) {
200+
actions.push(toAction({ id: 'toggleProfilesVisibility', label: PROFILES_TTILE.value, checked: this.profilesVisibilityPreference, run: () => this.profilesVisibilityPreference = !this.profilesVisibilityPreference }));
201+
}
200202
actions.push(new Separator());
201203

202204
// Toggle Sidebar
@@ -1064,7 +1066,7 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
10641066
}
10651067

10661068
private get profilesVisibilityPreference(): boolean {
1067-
return this.storageService.getBoolean(ProfilesActivityActionViewItem.PROFILES_VISIBILITY_PREFERENCE_KEY, StorageScope.PROFILE, this.userDataProfilesService.profiles.length > 1);
1069+
return this.userDataProfilesService.isEnabled() && this.storageService.getBoolean(ProfilesActivityActionViewItem.PROFILES_VISIBILITY_PREFERENCE_KEY, StorageScope.PROFILE, this.userDataProfilesService.profiles.length > 1);
10681070
}
10691071

10701072
private set profilesVisibilityPreference(value: boolean) {

src/vs/workbench/browser/web.main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export class BrowserMain extends Disposable {
309309
})
310310
]);
311311

312-
userDataProfilesService.setEnablement(productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
312+
userDataProfilesService.setEnablement(!environmentService.remoteAuthority && (productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG)));
313313
this._register(configurationService.onDidChangeConfiguration(e => {
314314
if (e.affectsConfiguration(PROFILES_ENABLEMENT_CONFIG)) {
315315
userDataProfilesService.setEnablement(!!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
4848
this.registerConfiguration();
4949

5050
this.currentProfileContext = CURRENT_PROFILE_CONTEXT.bindTo(contextKeyService);
51+
PROFILES_ENABLEMENT_CONTEXT.bindTo(contextKeyService).set(this.userDataProfilesService.isEnabled());
5152
this.isCurrentProfileTransientContext = IS_CURRENT_PROFILE_TRANSIENT_CONTEXT.bindTo(contextKeyService);
5253

5354
this.currentProfileContext.set(this.userDataProfileService.currentProfile.id);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
609609
id: SyncResource.GlobalState,
610610
label: getSyncAreaLabel(SyncResource.GlobalState),
611611
}];
612-
if (!this.environmentService.isBuilt || this.productService.enableSyncingProfiles) {
612+
if (this.userDataProfilesService.isEnabled() && (!this.environmentService.isBuilt || this.productService.enableSyncingProfiles)) {
613613
result.push({
614614
id: SyncResource.Profiles,
615615
label: getSyncAreaLabel(SyncResource.Profiles),

src/vs/workbench/electron-sandbox/desktop.main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { isCI, isMacintosh } from 'vs/base/common/platform';
4949
import { Schemas } from 'vs/base/common/network';
5050
import { DiskFileSystemProvider } from 'vs/workbench/services/files/electron-sandbox/diskFileSystemProvider';
5151
import { FileUserDataProvider } from 'vs/platform/userData/common/fileUserDataProvider';
52-
import { IUserDataProfilesService, reviveProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
52+
import { IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG, reviveProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
5353
import { UserDataProfilesNativeService } from 'vs/platform/userDataProfile/electron-sandbox/userDataProfile';
5454
import { PolicyChannelClient } from 'vs/platform/policy/common/policyIpc';
5555
import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/policy';
@@ -283,6 +283,8 @@ export class DesktopMain extends Disposable {
283283
})
284284
]);
285285

286+
userDataProfilesService.setEnablement(productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
287+
286288
// Workspace Trust Service
287289
const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService);
288290
serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService);

src/vs/workbench/services/userDataProfile/common/userDataProfile.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import { Event } from 'vs/base/common/event';
88
import { localize } from 'vs/nls';
99
import { MenuId } from 'vs/platform/actions/common/actions';
1010
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
11-
import { IUserDataProfile, IUserDataProfileOptions, IUserDataProfileUpdateOptions, PROFILES_ENABLEMENT_CONFIG } from 'vs/platform/userDataProfile/common/userDataProfile';
12-
import { ContextKeyDefinedExpr, ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
13-
import { ProductQualityContext } from 'vs/platform/contextkey/common/contextkeys';
11+
import { IUserDataProfile, IUserDataProfileOptions, IUserDataProfileUpdateOptions } from 'vs/platform/userDataProfile/common/userDataProfile';
12+
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1413

1514
export interface DidChangeUserDataProfileEvent {
1615
readonly preserveData: boolean;
@@ -78,7 +77,7 @@ export const PROFILES_TTILE = { value: localize('settings profiles', "Settings P
7877
export const PROFILES_CATEGORY = { ...PROFILES_TTILE };
7978
export const PROFILE_EXTENSION = 'code-profile';
8079
export const PROFILE_FILTER = [{ name: localize('profile', "Settings Profile"), extensions: [PROFILE_EXTENSION] }];
81-
export const PROFILES_ENABLEMENT_CONTEXT = ContextKeyExpr.or(ProductQualityContext.notEqualsTo('stable'), ContextKeyDefinedExpr.create(`config.${PROFILES_ENABLEMENT_CONFIG}`));
80+
export const PROFILES_ENABLEMENT_CONTEXT = new RawContextKey<boolean>('profiles.enabled', true);
8281
export const CURRENT_PROFILE_CONTEXT = new RawContextKey<string>('currentSettingsProfile', '');
8382
export const IS_CURRENT_PROFILE_TRANSIENT_CONTEXT = new RawContextKey<boolean>('isCurrentSettingsProfileTransient', false);
8483
export const HAS_PROFILES_CONTEXT = new RawContextKey<boolean>('hasSettingsProfiles', false);

0 commit comments

Comments
 (0)