Merge from vscode 79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2

This commit is contained in:
ADS Merger
2020-05-31 19:47:51 +00:00
parent 84492049e8
commit 28be33cfea
913 changed files with 28242 additions and 15549 deletions

View File

@@ -5,7 +5,7 @@
import { Action } from 'vs/base/common/actions';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { canceled, isPromiseCanceledError } from 'vs/base/common/errors';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { Event } from 'vs/base/common/event';
import { Disposable, DisposableStore, dispose, MutableDisposable, toDisposable, IDisposable } from 'vs/base/common/lifecycle';
import { isEqual, basename } from 'vs/base/common/resources';
@@ -28,8 +28,8 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import {
CONTEXT_SYNC_STATE, IUserDataAutoSyncService, IUserDataSyncService, registerConfiguration,
SyncResource, SyncStatus, UserDataSyncError, UserDataSyncErrorCode, USER_DATA_SYNC_SCHEME, IUserDataSyncEnablementService, CONTEXT_SYNC_ENABLEMENT,
IUserDataAutoSyncService, IUserDataSyncService, registerConfiguration,
SyncResource, SyncStatus, UserDataSyncError, UserDataSyncErrorCode, USER_DATA_SYNC_SCHEME, IUserDataSyncEnablementService,
SyncResourceConflicts, Conflict, getSyncResourceFromLocalPreview
} from 'vs/platform/userDataSync/common/userDataSync';
import { FloatingClickWidget } from 'vs/workbench/browser/parts/editor/editorWidgets';
@@ -48,40 +48,30 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService';
import { UserDataSyncAccounts, AccountStatus } from 'vs/workbench/contrib/userDataSync/browser/userDataSyncAccount';
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { Codicon } from 'vs/base/common/codicons';
import { ViewContainerLocation, IViewContainersRegistry, Extensions, ViewContainer } from 'vs/workbench/common/views';
import { UserDataSyncViewPaneContainer, UserDataSyncDataViews } from 'vs/workbench/contrib/userDataSync/browser/userDataSyncViews';
import { IUserDataSyncWorkbenchService, CONTEXT_ENABLE_VIEWS, getSyncAreaLabel, AccountStatus, CONTEXT_SYNC_STATE, CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE, CONFIGURE_SYNC_COMMAND_ID, ENABLE_SYNC_VIEWS_COMMAND_ID, SHOW_SYNC_LOG_COMMAND_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
const CONTEXT_CONFLICTS_SOURCES = new RawContextKey<string>('conflictsSources', '');
type ConfigureSyncQuickPickItem = { id: SyncResource, label: string, description?: string };
function getSyncAreaLabel(source: SyncResource): string {
switch (source) {
case SyncResource.Settings: return localize('settings', "Settings");
case SyncResource.Keybindings: return localize('keybindings', "Keyboard Shortcuts");
case SyncResource.Snippets: return localize('snippets', "User Snippets");
case SyncResource.Extensions: return localize('extensions', "Extensions");
case SyncResource.GlobalState: return localize('ui state label', "UI State");
}
}
type SyncConflictsClassification = {
source: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
action?: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
};
type FirstTimeSyncClassification = {
action: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
};
const turnOnSyncCommand = { id: 'workbench.userData.actions.syncStart', title: localize('turn on sync with category', "Preferences Sync: Turn On...") };
const stopSyncCommand = { id: 'workbench.userData.actions.stopSync', title: localize('stop sync', "Preferences Sync: Turn Off") };
const resolveSettingsConflictsCommand = { id: 'workbench.userData.actions.resolveSettingsConflicts', title: localize('showConflicts', "Preferences Sync: Show Settings Conflicts") };
const resolveKeybindingsConflictsCommand = { id: 'workbench.userData.actions.resolveKeybindingsConflicts', title: localize('showKeybindingsConflicts', "Preferences Sync: Show Keybindings Conflicts") };
const resolveSnippetsConflictsCommand = { id: 'workbench.userData.actions.resolveSnippetsConflicts', title: localize('showSnippetsConflicts', "Preferences Sync: Show User Snippets Conflicts") };
const configureSyncCommand = { id: 'workbench.userData.actions.configureSync', title: localize('configure sync', "Preferences Sync: Configure...") };
const showSyncActivityCommand = { id: 'workbench.userData.actions.showSyncActivity', title: localize('show sync log', "Preferences Sync: Show Log") };
const turnOnSyncCommand = { id: 'workbench.userDataSync.actions.turnOn', title: localize('turn on sync with category', "Preferences Sync: Turn On...") };
const turnOffSyncCommand = { id: 'workbench.userDataSync.actions.turnOff', title: localize('stop sync', "Preferences Sync: Turn Off") };
const configureSyncCommand = { id: CONFIGURE_SYNC_COMMAND_ID, title: localize('configure sync', "Preferences Sync: Configure...") };
const resolveSettingsConflictsCommand = { id: 'workbench.userDataSync.actions.resolveSettingsConflicts', title: localize('showConflicts', "Preferences Sync: Show Settings Conflicts") };
const resolveKeybindingsConflictsCommand = { id: 'workbench.userDataSync.actions.resolveKeybindingsConflicts', title: localize('showKeybindingsConflicts', "Preferences Sync: Show Keybindings Conflicts") };
const resolveSnippetsConflictsCommand = { id: 'workbench.userDataSync.actions.resolveSnippetsConflicts', title: localize('showSnippetsConflicts', "Preferences Sync: Show User Snippets Conflicts") };
const syncNowCommand = {
id: 'workbench.userData.actions.syncNow',
id: 'workbench.userDataSync.actions.syncNow',
title: localize('sync now', "Preferences Sync: Sync Now"),
description(userDataSyncService: IUserDataSyncService): string | undefined {
if (userDataSyncService.status === SyncStatus.Syncing) {
@@ -93,25 +83,22 @@ const syncNowCommand = {
return undefined;
}
};
const showSyncSettingsCommand = { id: 'workbench.userData.actions.syncSettings', title: localize('sync settings', "Preferences Sync: Show Settings"), };
const showSyncSettingsCommand = { id: 'workbench.userDataSync.actions.settings', title: localize('sync settings', "Preferences Sync: Show Settings"), };
const CONTEXT_TURNING_ON_STATE = new RawContextKey<false>('userDataSyncTurningOn', false);
export const CONTEXT_ACCOUNT_STATE = new RawContextKey<string>('userDataSyncAccountStatus', AccountStatus.Uninitialized);
export class UserDataSyncWorkbenchContribution extends Disposable implements IWorkbenchContribution {
private readonly turningOnSyncContext: IContextKey<boolean>;
private readonly syncEnablementContext: IContextKey<boolean>;
private readonly syncStatusContext: IContextKey<string>;
private readonly accountStatusContext: IContextKey<string>;
private readonly conflictsSources: IContextKey<string>;
private readonly viewsEnablementContext: IContextKey<boolean>;
private readonly userDataSyncAccounts: UserDataSyncAccounts;
private readonly badgeDisposable = this._register(new MutableDisposable());
constructor(
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
@IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService,
@IUserDataSyncWorkbenchService private readonly userDataSyncWorkbenchService: IUserDataSyncWorkbenchService,
@IContextKeyService contextKeyService: IContextKeyService,
@IActivityService private readonly activityService: IActivityService,
@INotificationService private readonly notificationService: INotificationService,
@@ -119,7 +106,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
@IDialogService private readonly dialogService: IDialogService,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@IInstantiationService instantiationService: IInstantiationService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IOutputService private readonly outputService: IOutputService,
@IAuthenticationTokenService readonly authTokenService: IAuthenticationTokenService,
@IUserDataAutoSyncService userDataAutoSyncService: IUserDataAutoSyncService,
@@ -134,45 +121,32 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
super();
this.turningOnSyncContext = CONTEXT_TURNING_ON_STATE.bindTo(contextKeyService);
this.syncEnablementContext = CONTEXT_SYNC_ENABLEMENT.bindTo(contextKeyService);
this.syncStatusContext = CONTEXT_SYNC_STATE.bindTo(contextKeyService);
this.accountStatusContext = CONTEXT_ACCOUNT_STATE.bindTo(contextKeyService);
this.conflictsSources = CONTEXT_CONFLICTS_SOURCES.bindTo(contextKeyService);
this.viewsEnablementContext = CONTEXT_ENABLE_VIEWS.bindTo(contextKeyService);
this.userDataSyncAccounts = instantiationService.createInstance(UserDataSyncAccounts);
if (this.userDataSyncAccounts.authenticationProviders.length) {
if (this.userDataSyncWorkbenchService.authenticationProviders.length) {
registerConfiguration();
this.onDidChangeSyncStatus(this.userDataSyncService.status);
this.updateBadge();
this.onDidChangeConflicts(this.userDataSyncService.conflicts);
this.onDidChangeEnablement(this.userDataSyncEnablementService.isEnabled());
this.onDidChangeAccountStatus(this.userDataSyncAccounts.status);
this._register(Event.debounce(userDataSyncService.onDidChangeStatus, () => undefined, 500)(() => this.onDidChangeSyncStatus(this.userDataSyncService.status)));
this._register(Event.any(
Event.debounce(userDataSyncService.onDidChangeStatus, () => undefined, 500),
this.userDataSyncEnablementService.onDidChangeEnablement,
this.userDataSyncWorkbenchService.onDidChangeAccountStatus
)(() => this.updateBadge()));
this._register(userDataSyncService.onDidChangeConflicts(() => this.onDidChangeConflicts(this.userDataSyncService.conflicts)));
this._register(userDataSyncService.onSyncErrors(errors => this.onSyncErrors(errors)));
this._register(this.userDataSyncEnablementService.onDidChangeEnablement(enabled => this.onDidChangeEnablement(enabled)));
this._register(userDataSyncService.onSyncErrors(errors => this.onSynchronizerErrors(errors)));
this._register(userDataAutoSyncService.onError(error => this.onAutoSyncError(error)));
this._register(this.userDataSyncAccounts.onDidChangeStatus(status => this.onDidChangeAccountStatus(status)));
this._register(this.userDataSyncAccounts.onDidSignOut(() => this.doTurnOff(false)));
this.registerActions();
this.registerViews();
textModelResolverService.registerTextModelContentProvider(USER_DATA_SYNC_SCHEME, instantiationService.createInstance(UserDataRemoteContentProvider));
registerEditorContribution(AcceptChangesContribution.ID, AcceptChangesContribution);
}
}
private onDidChangeAccountStatus(status: AccountStatus): void {
this.accountStatusContext.set(status);
this.updateBadge();
}
private onDidChangeSyncStatus(status: SyncStatus) {
this.syncStatusContext.set(status);
this.updateBadge();
}
private readonly conflictsDisposables = new Map<SyncResource, IDisposable>();
private onDidChangeConflicts(conflicts: SyncResourceConflicts[]) {
this.updateBadge();
@@ -261,8 +235,11 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
try {
for (const conflict of conflicts) {
const modelRef = await this.textModelResolverService.createModelReference(conflict.remote);
await this.userDataSyncService.acceptConflict(conflict.remote, modelRef.object.textEditorModel.getValue());
modelRef.dispose();
try {
await this.userDataSyncService.acceptConflict(conflict.remote, modelRef.object.textEditorModel.getValue());
} finally {
modelRef.dispose();
}
}
} catch (e) {
this.notificationService.error(e);
@@ -273,20 +250,18 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
try {
for (const conflict of conflicts) {
const modelRef = await this.textModelResolverService.createModelReference(conflict.local);
await this.userDataSyncService.acceptConflict(conflict.local, modelRef.object.textEditorModel.getValue());
modelRef.dispose();
try {
await this.userDataSyncService.acceptConflict(conflict.local, modelRef.object.textEditorModel.getValue());
} finally {
modelRef.dispose();
}
}
} catch (e) {
this.notificationService.error(e);
}
}
private onDidChangeEnablement(enabled: boolean) {
this.syncEnablementContext.set(enabled);
this.updateBadge();
}
private onAutoSyncError(error: UserDataSyncError): void {
private onAutoSyncError(error: UserDataSyncError): boolean {
switch (error.code) {
case UserDataSyncErrorCode.TurnedOff:
case UserDataSyncErrorCode.SessionExpired:
@@ -297,7 +272,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
primary: [new Action('turn on sync', localize('turn on sync', "Turn on Preferences Sync..."), undefined, true, () => this.turnOn())]
}
});
return;
return true;
case UserDataSyncErrorCode.TooLarge:
if (error.resource === SyncResource.Keybindings || error.resource === SyncResource.Settings) {
this.disableSync(error.resource);
@@ -311,19 +286,21 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
});
}
return;
return true;
case UserDataSyncErrorCode.Incompatible:
case UserDataSyncErrorCode.UpgradeRequired:
this.disableSync();
this.notificationService.notify({
severity: Severity.Error,
message: localize('error incompatible', "Turned off sync because local data is incompatible with the data in the cloud. Please update {0} and turn on sync to continue syncing.", this.productService.nameLong),
message: localize('error upgrade required', "Turned off sync because the current version ({0}, {1}) of {2} is not compatible with the Preferences Sync Service. Please update and turn on sync to continue syncing.", this.productService.version, this.productService.commit, this.productService.nameLong),
});
return;
return true;
}
return false;
}
private readonly invalidContentErrorDisposables = new Map<SyncResource, IDisposable>();
private onSyncErrors(errors: [SyncResource, UserDataSyncError][]): void {
private onSynchronizerErrors(errors: [SyncResource, UserDataSyncError][]): void {
if (errors.length) {
for (const [source, error] of errors) {
switch (error.code) {
@@ -379,7 +356,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
let clazz: string | undefined;
let priority: number | undefined = undefined;
if (this.userDataSyncService.status !== SyncStatus.Uninitialized && this.userDataSyncEnablementService.isEnabled() && this.userDataSyncAccounts.status === AccountStatus.Unavailable) {
if (this.userDataSyncService.status !== SyncStatus.Uninitialized && this.userDataSyncEnablementService.isEnabled() && this.userDataSyncWorkbenchService.accountStatus === AccountStatus.Unavailable) {
badge = new NumberBadge(1, () => localize('sign in to sync preferences', "Sign in to Sync Preferences"));
} else if (this.userDataSyncService.conflicts.length) {
badge = new NumberBadge(this.userDataSyncService.conflicts.reduce((result, syncResourceConflict) => { return result + syncResourceConflict.conflicts.length; }, 0), () => localize('has conflicts', "Preferences Sync: Conflicts Detected"));
@@ -415,8 +392,16 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
if (!turnOn) {
return;
}
await this.doTurnOn();
await this.userDataSyncWorkbenchService.turnOn();
this.storageService.store('sync.donotAskPreviewConfirmation', true, StorageScope.GLOBAL);
} catch (e) {
if (isPromiseCanceledError(e)) {
return;
}
if (e instanceof UserDataSyncError && this.onAutoSyncError(e)) {
return;
}
this.notificationService.error(localize('turn on failed', "Error while starting Sync: {0}", toErrorMessage(e)));
} finally {
this.turningOnSync = false;
}
@@ -450,13 +435,13 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
quickPick.title = localize('Preferences Sync Title', "Preferences Sync");
quickPick.ok = false;
quickPick.customButton = true;
if (this.userDataSyncAccounts.all.length) {
if (this.userDataSyncWorkbenchService.all.length) {
quickPick.customLabel = localize('turn on', "Turn On");
} else {
const orTerm = localize({ key: 'or', comment: ['Here is the context where it is used - Sign in with your A or B or C account to synchronize your data across devices.'] }, "or");
const displayName = this.userDataSyncAccounts.authenticationProviders.length === 1
? this.authenticationService.getDisplayName(this.userDataSyncAccounts.authenticationProviders[0].id)
: this.userDataSyncAccounts.authenticationProviders.map(({ id }) => this.authenticationService.getDisplayName(id)).join(` ${orTerm} `);
const displayName = this.userDataSyncWorkbenchService.authenticationProviders.length === 1
? this.authenticationService.getDisplayName(this.userDataSyncWorkbenchService.authenticationProviders[0].id)
: this.userDataSyncWorkbenchService.authenticationProviders.map(({ id }) => this.authenticationService.getDisplayName(id)).join(` ${orTerm} `);
quickPick.description = localize('sign in and turn on sync detail', "Sign in with your {0} account to synchronize your data across devices.", displayName);
quickPick.customLabel = localize('sign in and turn on sync', "Sign in & Turn on");
}
@@ -487,22 +472,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
});
}
private async doTurnOn(): Promise<void> {
const picked = await this.userDataSyncAccounts.pick();
if (!picked) {
throw canceled();
}
// User did not pick an account or login failed
if (this.userDataSyncAccounts.status !== AccountStatus.Available) {
throw new Error(localize('no account', "No account available"));
}
await this.handleFirstTimeSync();
this.userDataSyncEnablementService.setEnablement(true);
this.notificationService.info(localize('sync turned on', "Preferences sync is turned on"));
}
private getConfigureSyncQuickPickItems(): ConfigureSyncQuickPickItem[] {
return [{
id: SyncResource.Settings,
@@ -559,38 +528,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
});
}
private async handleFirstTimeSync(): Promise<void> {
const isFirstSyncWithMerge = await this.userDataSyncService.isFirstTimeSyncWithMerge();
if (!isFirstSyncWithMerge) {
return;
}
const result = await this.dialogService.show(
Severity.Info,
localize('firs time sync', "Sync"),
[
localize('merge', "Merge"),
localize('cancel', "Cancel"),
localize('replace', "Replace Local"),
],
{
cancelId: 1,
detail: localize('first time sync detail', "It looks like this is the first time sync is set up.\nWould you like to merge or replace with the data from the cloud?"),
}
);
switch (result.choice) {
case 0:
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'merge' });
break;
case 1:
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'cancelled' });
throw canceled();
case 2:
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'replace-local' });
await this.userDataSyncService.pull();
break;
}
}
private async turnOff(): Promise<void> {
const result = await this.dialogService.confirm({
type: 'info',
@@ -602,26 +539,10 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
});
if (result.confirmed) {
return this.doTurnOff(!!result.checkboxChecked);
return this.userDataSyncWorkbenchService.turnoff(!!result.checkboxChecked);
}
}
private async doTurnOff(turnOffEveryWhere: boolean): Promise<void> {
if (!this.userDataSyncEnablementService.isEnabled()) {
return;
}
if (!this.userDataSyncEnablementService.canToggleEnablement()) {
return;
}
if (turnOffEveryWhere) {
this.telemetryService.publicLog2('sync/turnOffEveryWhere');
await this.userDataSyncService.reset();
} else {
await this.userDataSyncService.resetLocal();
}
this.disableSync();
}
private disableSync(source?: SyncResource): void {
if (source === undefined) {
this.userDataSyncEnablementService.setEnablement(false);
@@ -694,24 +615,18 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
this.registerShowSettingsConflictsAction();
this.registerShowKeybindingsConflictsAction();
this.registerShowSnippetsConflictsAction();
this.registerSyncStatusAction();
this.registerEnableSyncViewsAction();
this.registerManageSyncAction();
this.registerSyncNowAction();
this.registerConfigureSyncAction();
this.registerShowActivityAction();
this.registerShowSettingsAction();
this.registerShowLogAction();
}
private registerTurnOnSyncAction(): void {
const turnOnSyncWhenContext = ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized), CONTEXT_SYNC_ENABLEMENT.toNegated(), CONTEXT_ACCOUNT_STATE.notEqualsTo(AccountStatus.Uninitialized), CONTEXT_TURNING_ON_STATE.negate());
CommandsRegistry.registerCommand(turnOnSyncCommand.id, async () => {
try {
await this.turnOn();
} catch (e) {
if (!isPromiseCanceledError(e)) {
this.notificationService.error(localize('turn on failed', "Error while starting Sync: {0}", toErrorMessage(e)));
}
}
});
CommandsRegistry.registerCommand(turnOnSyncCommand.id, () => this.turnOn());
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
group: '5_sync',
command: {
@@ -786,7 +701,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
async run(): Promise<any> {
try {
await that.userDataSyncAccounts.pick();
await that.userDataSyncWorkbenchService.pickAccount();
} catch (e) {
that.notificationService.error(e);
}
@@ -886,14 +801,13 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}));
}
private registerSyncStatusAction(): void {
private registerManageSyncAction(): void {
const that = this;
const when = ContextKeyExpr.and(CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE.isEqualTo(AccountStatus.Available), CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized));
this.registerSyncNowAction();
this._register(registerAction2(class SyncStatusAction extends Action2 {
constructor() {
super({
id: 'workbench.userData.actions.syncStatus',
id: 'workbench.userDataSync.actions.manage',
title: localize('sync is on', "Preferences Sync is On"),
menu: [
{
@@ -941,13 +855,11 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
items.push({ type: 'separator' });
}
items.push({ id: configureSyncCommand.id, label: configureSyncCommand.title });
items.push({ id: showSyncSettingsCommand.id, label: showSyncSettingsCommand.title });
items.push({ id: showSyncActivityCommand.id, label: showSyncActivityCommand.title });
items.push({ type: 'separator' });
items.push({ id: syncNowCommand.id, label: syncNowCommand.title, description: syncNowCommand.description(that.userDataSyncService) });
if (that.userDataSyncEnablementService.canToggleEnablement()) {
const account = that.userDataSyncAccounts.current;
items.push({ id: stopSyncCommand.id, label: stopSyncCommand.title, description: account ? `${account.accountName} (${that.authenticationService.getDisplayName(account.authenticationProviderId)})` : undefined });
const account = that.userDataSyncWorkbenchService.current;
items.push({ id: turnOffSyncCommand.id, label: turnOffSyncCommand.title, description: account ? `${account.accountName} (${that.authenticationService.getDisplayName(account.authenticationProviderId)})` : undefined });
}
quickPick.items = items;
disposables.add(quickPick.onDidAccept(() => {
@@ -966,6 +878,23 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}));
}
private registerEnableSyncViewsAction(): void {
const that = this;
const when = ContextKeyExpr.and(CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE.isEqualTo(AccountStatus.Available), CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized));
this._register(registerAction2(class SyncStatusAction extends Action2 {
constructor() {
super({
id: ENABLE_SYNC_VIEWS_COMMAND_ID,
title: ENABLE_SYNC_VIEWS_COMMAND_ID,
precondition: when
});
}
run(accessor: ServicesAccessor): any {
that.viewsEnablementContext.set(true);
}
}));
}
private registerSyncNowAction(): void {
const that = this;
this._register(registerAction2(class SyncNowAction extends Action2 {
@@ -973,9 +902,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
super({
id: syncNowCommand.id,
title: syncNowCommand.title,
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE.isEqualTo(AccountStatus.Available), CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized))
}
});
}
run(): Promise<any> {
run(accessor: ServicesAccessor): Promise<any> {
accessor.get(ITelemetryService).publicLog2(`sync/actions/${syncNowCommand.id}`);
return that.userDataSyncService.sync();
}
}));
@@ -986,8 +920,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
this._register(registerAction2(class StopSyncAction extends Action2 {
constructor() {
super({
id: stopSyncCommand.id,
title: stopSyncCommand.title,
id: turnOffSyncCommand.id,
title: turnOffSyncCommand.title,
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized), CONTEXT_SYNC_ENABLEMENT),
@@ -1008,28 +942,29 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
private registerConfigureSyncAction(): void {
const that = this;
this._register(registerAction2(class ShowSyncActivityAction extends Action2 {
const when = ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized), CONTEXT_SYNC_ENABLEMENT);
this._register(registerAction2(class ConfigureSyncAction extends Action2 {
constructor() {
super({
id: configureSyncCommand.id,
title: configureSyncCommand.title,
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized), CONTEXT_SYNC_ENABLEMENT),
},
when
}
});
}
run(): any { return that.configureSyncOptions(); }
}));
}
private registerShowActivityAction(): void {
private registerShowLogAction(): void {
const that = this;
this._register(registerAction2(class ShowSyncActivityAction extends Action2 {
constructor() {
super({
id: showSyncActivityCommand.id,
title: showSyncActivityCommand.title,
id: SHOW_SYNC_LOG_COMMAND_ID,
title: localize('show sync log title', "Preferences Sync: Show Log"),
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized)),
@@ -1058,6 +993,30 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}));
}
private registerViews(): void {
const container = this.registerViewContainer();
this.registerDataViews(container);
}
private registerViewContainer(): ViewContainer {
const viewContainerId = 'workbench.view.sync';
return Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer(
{
id: viewContainerId,
name: localize('sync preferences', "Preferences Sync"),
ctorDescriptor: new SyncDescriptor(
UserDataSyncViewPaneContainer,
[viewContainerId]
),
icon: Codicon.sync.classNames,
hideIfEmpty: true,
}, ViewContainerLocation.Sidebar);
}
private registerDataViews(container: ViewContainer): void {
this._register(this.instantiationService.createInstance(UserDataSyncDataViews, container));
}
}
class UserDataRemoteContentProvider implements ITextModelContentProvider {