Merge pull request #163640 from microsoft/sandy081/helpless-gerbil

Fix #163343
This commit is contained in:
Sandeep Somavarapu 2022-10-14 19:15:54 +02:00 committed by GitHub
commit 1bcb42f40c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 15 deletions

View file

@ -106,6 +106,7 @@ export interface IUserDataProfilesService {
readonly onDidResetWorkspaces: Event<void>;
isEnabled(): boolean;
createNamedProfile(name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile>;
createTransientProfile(workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile>;
createProfile(id: string, name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile>;
@ -225,6 +226,10 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
}
}
isEnabled(): boolean {
return this.enabled;
}
protected _profilesObject: UserDataProfilesObject | undefined;
protected get profilesObject(): UserDataProfilesObject {
if (!this._profilesObject) {

View file

@ -18,7 +18,6 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
export const IUserDataProfilesMainService = refineServiceDecorator<IUserDataProfilesService, IUserDataProfilesMainService>(IUserDataProfilesService);
export interface IUserDataProfilesMainService extends IUserDataProfilesService {
isEnabled(): boolean;
getOrSetProfileForWorkspace(workspaceIdentifier: WorkspaceIdentifier, profileToSet?: IUserDataProfile): IUserDataProfile;
setProfileForWorkspaceSync(workspaceIdentifier: WorkspaceIdentifier, profileToSet: IUserDataProfile): void;
checkAndCreateProfileFromCli(args: NativeParsedArgs): Promise<IUserDataProfile> | undefined;
@ -48,10 +47,6 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
}
}
isEnabled(): boolean {
return this.enabled;
}
checkAndCreateProfileFromCli(args: NativeParsedArgs): Promise<IUserDataProfile> | undefined {
if (!this.isEnabled()) {
return undefined;

View file

@ -29,6 +29,8 @@ export class UserDataProfilesNativeService extends Disposable implements IUserDa
readonly onDidResetWorkspaces: Event<void>;
private enabled: boolean = true;
constructor(
profiles: readonly UriDto<IUserDataProfile>[],
@IMainProcessService mainProcessService: IMainProcessService,
@ -48,6 +50,14 @@ export class UserDataProfilesNativeService extends Disposable implements IUserDa
this.onDidResetWorkspaces = this.channel.listen<void>('onDidResetWorkspaces');
}
setEnablement(enabled: boolean) {
this.enabled = enabled;
}
isEnabled(): boolean {
return this.enabled;
}
async createNamedProfile(name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: WorkspaceIdentifier): Promise<IUserDataProfile> {
const result = await this.channel.call<UriDto<IUserDataProfile>>('createNamedProfile', [name, options, workspaceIdentifier]);
return reviveProfile(result, this.profilesHome.scheme);

View file

@ -418,6 +418,10 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
return isUndefined(result) ? null : result;
}
if (this.userDataProfilesService.isEnabled()) {
return null;
}
if (this.environmentService.isBuilt && (!this.productService.enableSyncingProfiles || isEqual(this.userDataSyncStoreManagementService.userDataSyncStore?.url, this.userDataSyncStoreManagementService.userDataSyncStore?.stableUrl))) {
return null;
}
@ -543,7 +547,7 @@ class ProfileSynchronizer extends Disposable {
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IUserDataSyncLogService private readonly logService: IUserDataSyncLogService,
@IProductService private readonly productService: IProductService,
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
) {
@ -590,6 +594,9 @@ class ProfileSynchronizer extends Disposable {
if (!this._profile.isDefault) {
return;
}
if (!this.userDataProfilesService.isEnabled()) {
return;
}
if (this.environmentService.isBuilt && (!this.productService.enableSyncingProfiles || isEqual(this.userDataSyncStoreManagementService.userDataSyncStore?.url, this.userDataSyncStoreManagementService.userDataSyncStore?.stableUrl))) {
this.logService.debug('Skipping profiles sync');
return;

View file

@ -196,7 +196,9 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
// Accounts
actions.push(new Separator());
actions.push(toAction({ id: 'toggleAccountsVisibility', label: localize('accounts', "Accounts"), checked: this.accountsVisibilityPreference, run: () => this.accountsVisibilityPreference = !this.accountsVisibilityPreference }));
actions.push(toAction({ id: 'toggleProfilesVisibility', label: PROFILES_TTILE.value, checked: this.profilesVisibilityPreference, run: () => this.profilesVisibilityPreference = !this.profilesVisibilityPreference }));
if (this.userDataProfilesService.isEnabled()) {
actions.push(toAction({ id: 'toggleProfilesVisibility', label: PROFILES_TTILE.value, checked: this.profilesVisibilityPreference, run: () => this.profilesVisibilityPreference = !this.profilesVisibilityPreference }));
}
actions.push(new Separator());
// Toggle Sidebar
@ -1064,7 +1066,7 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
}
private get profilesVisibilityPreference(): boolean {
return this.storageService.getBoolean(ProfilesActivityActionViewItem.PROFILES_VISIBILITY_PREFERENCE_KEY, StorageScope.PROFILE, this.userDataProfilesService.profiles.length > 1);
return this.userDataProfilesService.isEnabled() && this.storageService.getBoolean(ProfilesActivityActionViewItem.PROFILES_VISIBILITY_PREFERENCE_KEY, StorageScope.PROFILE, this.userDataProfilesService.profiles.length > 1);
}
private set profilesVisibilityPreference(value: boolean) {

View file

@ -309,7 +309,7 @@ export class BrowserMain extends Disposable {
})
]);
userDataProfilesService.setEnablement(productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
userDataProfilesService.setEnablement(!environmentService.remoteAuthority && (productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG)));
this._register(configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(PROFILES_ENABLEMENT_CONFIG)) {
userDataProfilesService.setEnablement(!!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));

View file

@ -48,6 +48,7 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
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);

View file

@ -609,7 +609,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
id: SyncResource.GlobalState,
label: getSyncAreaLabel(SyncResource.GlobalState),
}];
if (!this.environmentService.isBuilt || this.productService.enableSyncingProfiles) {
if (this.userDataProfilesService.isEnabled() && (!this.environmentService.isBuilt || this.productService.enableSyncingProfiles)) {
result.push({
id: SyncResource.Profiles,
label: getSyncAreaLabel(SyncResource.Profiles),

View file

@ -49,7 +49,7 @@ import { isCI, isMacintosh } from 'vs/base/common/platform';
import { Schemas } from 'vs/base/common/network';
import { DiskFileSystemProvider } from 'vs/workbench/services/files/electron-sandbox/diskFileSystemProvider';
import { FileUserDataProvider } from 'vs/platform/userData/common/fileUserDataProvider';
import { IUserDataProfilesService, reviveProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG, reviveProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
import { UserDataProfilesNativeService } from 'vs/platform/userDataProfile/electron-sandbox/userDataProfile';
import { PolicyChannelClient } from 'vs/platform/policy/common/policyIpc';
import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/policy';
@ -283,6 +283,8 @@ export class DesktopMain extends Disposable {
})
]);
userDataProfilesService.setEnablement(productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
// Workspace Trust Service
const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService);
serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService);

View file

@ -8,9 +8,8 @@ import { Event } from 'vs/base/common/event';
import { localize } from 'vs/nls';
import { MenuId } from 'vs/platform/actions/common/actions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IUserDataProfile, IUserDataProfileOptions, IUserDataProfileUpdateOptions, PROFILES_ENABLEMENT_CONFIG } from 'vs/platform/userDataProfile/common/userDataProfile';
import { ContextKeyDefinedExpr, ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ProductQualityContext } from 'vs/platform/contextkey/common/contextkeys';
import { IUserDataProfile, IUserDataProfileOptions, IUserDataProfileUpdateOptions } from 'vs/platform/userDataProfile/common/userDataProfile';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
export interface DidChangeUserDataProfileEvent {
readonly preserveData: boolean;
@ -78,7 +77,7 @@ export const PROFILES_TTILE = { value: localize('settings profiles', "Settings P
export const PROFILES_CATEGORY = { ...PROFILES_TTILE };
export const PROFILE_EXTENSION = 'code-profile';
export const PROFILE_FILTER = [{ name: localize('profile', "Settings Profile"), extensions: [PROFILE_EXTENSION] }];
export const PROFILES_ENABLEMENT_CONTEXT = ContextKeyExpr.or(ProductQualityContext.notEqualsTo('stable'), ContextKeyDefinedExpr.create(`config.${PROFILES_ENABLEMENT_CONFIG}`));
export const PROFILES_ENABLEMENT_CONTEXT = new RawContextKey<boolean>('profiles.enabled', true);
export const CURRENT_PROFILE_CONTEXT = new RawContextKey<string>('currentSettingsProfile', '');
export const IS_CURRENT_PROFILE_TRANSIENT_CONTEXT = new RawContextKey<boolean>('isCurrentSettingsProfileTransient', false);
export const HAS_PROFILES_CONTEXT = new RawContextKey<boolean>('hasSettingsProfiles', false);