mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829
This commit is contained in:
@@ -30,7 +30,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import {
|
||||
IUserDataAutoSyncService, IUserDataSyncService, registerConfiguration,
|
||||
SyncResource, SyncStatus, UserDataSyncError, UserDataSyncErrorCode, USER_DATA_SYNC_SCHEME, IUserDataSyncResourceEnablementService,
|
||||
getSyncResourceFromLocalPreview, IResourcePreview
|
||||
getSyncResourceFromLocalPreview, IResourcePreview, IUserDataSyncStoreManagementService, UserDataSyncStoreType
|
||||
} from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { FloatingClickWidget } from 'vs/workbench/browser/parts/editor/editorWidgets';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
@@ -53,7 +53,8 @@ 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, getSyncAreaLabel, AccountStatus, CONTEXT_SYNC_STATE, CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE, CONFIGURE_SYNC_COMMAND_ID, SHOW_SYNC_LOG_COMMAND_ID, SYNC_VIEW_CONTAINER_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { IUserDataSyncWorkbenchService, getSyncAreaLabel, AccountStatus, CONTEXT_SYNC_STATE, CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE, CONFIGURE_SYNC_COMMAND_ID, SHOW_SYNC_LOG_COMMAND_ID, SYNC_VIEW_CONTAINER_ID, SYNC_TITLE } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { isNative } from 'vs/base/common/platform';
|
||||
|
||||
const CONTEXT_CONFLICTS_SOURCES = new RawContextKey<string>('conflictsSources', '');
|
||||
|
||||
@@ -64,15 +65,15 @@ type SyncConflictsClassification = {
|
||||
action?: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
};
|
||||
|
||||
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 turnOnSyncCommand = { id: 'workbench.userDataSync.actions.turnOn', title: localize('turn on sync with category', "{0}: Turn On...", SYNC_TITLE) };
|
||||
const turnOffSyncCommand = { id: 'workbench.userDataSync.actions.turnOff', title: localize('stop sync', "{0}: Turn Off", SYNC_TITLE) };
|
||||
const configureSyncCommand = { id: CONFIGURE_SYNC_COMMAND_ID, title: localize('configure sync', "{0}: Configure...", SYNC_TITLE) };
|
||||
const resolveSettingsConflictsCommand = { id: 'workbench.userDataSync.actions.resolveSettingsConflicts', title: localize('showConflicts', "{0}: Show Settings Conflicts", SYNC_TITLE) };
|
||||
const resolveKeybindingsConflictsCommand = { id: 'workbench.userDataSync.actions.resolveKeybindingsConflicts', title: localize('showKeybindingsConflicts', "{0}: Show Keybindings Conflicts", SYNC_TITLE) };
|
||||
const resolveSnippetsConflictsCommand = { id: 'workbench.userDataSync.actions.resolveSnippetsConflicts', title: localize('showSnippetsConflicts', "{0}: Show User Snippets Conflicts", SYNC_TITLE) };
|
||||
const syncNowCommand = {
|
||||
id: 'workbench.userDataSync.actions.syncNow',
|
||||
title: localize('sync now', "Preferences Sync: Sync Now"),
|
||||
title: localize('sync now', "{0}: Sync Now", SYNC_TITLE),
|
||||
description(userDataSyncService: IUserDataSyncService): string | undefined {
|
||||
if (userDataSyncService.status === SyncStatus.Syncing) {
|
||||
return localize('syncing', "syncing");
|
||||
@@ -83,8 +84,8 @@ const syncNowCommand = {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
const showSyncSettingsCommand = { id: 'workbench.userDataSync.actions.settings', title: localize('sync settings', "Preferences Sync: Show Settings"), };
|
||||
const showSyncedDataCommand = { id: 'workbench.userDataSync.actions.showSyncedData', title: localize('show synced data', "Preferences Sync: Show Synced Data"), };
|
||||
const showSyncSettingsCommand = { id: 'workbench.userDataSync.actions.settings', title: localize('sync settings', "{0}: Show Settings", SYNC_TITLE), };
|
||||
const showSyncedDataCommand = { id: 'workbench.userDataSync.actions.showSyncedData', title: localize('show synced data', "{0}: Show Synced Data", SYNC_TITLE), };
|
||||
|
||||
const CONTEXT_TURNING_ON_STATE = new RawContextKey<false>('userDataSyncTurningOn', false);
|
||||
|
||||
@@ -111,20 +112,22 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
@IOutputService private readonly outputService: IOutputService,
|
||||
@IUserDataSyncAccountService readonly authTokenService: IUserDataSyncAccountService,
|
||||
@IUserDataAutoSyncService private readonly userDataAutoSyncService: IUserDataAutoSyncService,
|
||||
@ITextModelService private readonly textModelResolverService: ITextModelService,
|
||||
@ITextModelService textModelResolverService: ITextModelService,
|
||||
@IPreferencesService private readonly preferencesService: IPreferencesService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IAuthenticationService private readonly authenticationService: IAuthenticationService,
|
||||
@IUserDataSyncStoreManagementService private readonly userDataSyncStoreManagementService: IUserDataSyncStoreManagementService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this.turningOnSyncContext = CONTEXT_TURNING_ON_STATE.bindTo(contextKeyService);
|
||||
this.conflictsSources = CONTEXT_CONFLICTS_SOURCES.bindTo(contextKeyService);
|
||||
|
||||
if (this.userDataSyncWorkbenchService.authenticationProviders.length) {
|
||||
if (userDataSyncWorkbenchService.enabled) {
|
||||
registerConfiguration();
|
||||
|
||||
this.updateAccountBadge();
|
||||
@@ -149,9 +152,20 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
|
||||
textModelResolverService.registerTextModelContentProvider(USER_DATA_SYNC_SCHEME, instantiationService.createInstance(UserDataRemoteContentProvider));
|
||||
registerEditorContribution(AcceptChangesContribution.ID, AcceptChangesContribution);
|
||||
|
||||
this._register(Event.any(userDataSyncService.onDidChangeStatus, userDataAutoSyncService.onDidChangeEnablement)(() => this.turningOnSync = !userDataAutoSyncService.isEnabled() && userDataSyncService.status !== SyncStatus.Idle));
|
||||
}
|
||||
}
|
||||
|
||||
private get turningOnSync(): boolean {
|
||||
return !!this.turningOnSyncContext.get();
|
||||
}
|
||||
|
||||
private set turningOnSync(turningOn: boolean) {
|
||||
this.turningOnSyncContext.set(turningOn);
|
||||
this.updateGlobalActivityBadge();
|
||||
}
|
||||
|
||||
private readonly conflictsDisposables = new Map<SyncResource, IDisposable>();
|
||||
private onDidChangeConflicts(conflicts: [SyncResource, IResourcePreview[]][]) {
|
||||
if (!this.userDataAutoSyncService.isEnabled()) {
|
||||
@@ -198,14 +212,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}
|
||||
},
|
||||
{
|
||||
label: localize('accept merges', "Accept Merges"),
|
||||
label: localize('accept local', "Accept Local"),
|
||||
run: () => {
|
||||
this.telemetryService.publicLog2<{ source: string, action: string }, SyncConflictsClassification>('sync/handleConflicts', { source: syncResource, action: 'acceptLocal' });
|
||||
this.acceptLocal(syncResource, conflicts);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: localize('show merges', "Show Merges"),
|
||||
label: localize('show conflicts', "Show Conflicts"),
|
||||
run: () => {
|
||||
this.telemetryService.publicLog2<{ source: string, action?: string }, SyncConflictsClassification>('sync/showConflicts', { source: syncResource });
|
||||
this.handleConflicts([syncResource, conflicts]);
|
||||
@@ -242,12 +256,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
private async acceptRemote(syncResource: SyncResource, conflicts: IResourcePreview[]) {
|
||||
try {
|
||||
for (const conflict of conflicts) {
|
||||
const modelRef = await this.textModelResolverService.createModelReference(conflict.remoteResource);
|
||||
try {
|
||||
await this.userDataSyncService.accept(syncResource, conflict.remoteResource, modelRef.object.textEditorModel.getValue(), this.userDataAutoSyncService.isEnabled());
|
||||
} finally {
|
||||
modelRef.dispose();
|
||||
}
|
||||
await this.userDataSyncService.accept(syncResource, conflict.remoteResource, undefined, this.userDataAutoSyncService.isEnabled());
|
||||
}
|
||||
} catch (e) {
|
||||
this.notificationService.error(e);
|
||||
@@ -257,12 +266,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
private async acceptLocal(syncResource: SyncResource, conflicts: IResourcePreview[]): Promise<void> {
|
||||
try {
|
||||
for (const conflict of conflicts) {
|
||||
const modelRef = await this.textModelResolverService.createModelReference(conflict.previewResource);
|
||||
try {
|
||||
await this.userDataSyncService.accept(syncResource, conflict.previewResource, modelRef.object.textEditorModel.getValue(), this.userDataAutoSyncService.isEnabled());
|
||||
} finally {
|
||||
modelRef.dispose();
|
||||
}
|
||||
await this.userDataSyncService.accept(syncResource, conflict.localResource, undefined, this.userDataAutoSyncService.isEnabled());
|
||||
}
|
||||
} catch (e) {
|
||||
this.notificationService.error(e);
|
||||
@@ -274,18 +278,18 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
case UserDataSyncErrorCode.SessionExpired:
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Info,
|
||||
message: localize('session expired', "Preferences sync was turned off because current session is expired, please sign in again to turn on sync."),
|
||||
message: localize('session expired', "Settings sync was turned off because current session is expired, please sign in again to turn on sync."),
|
||||
actions: {
|
||||
primary: [new Action('turn on sync', localize('turn on sync', "Turn on Preferences Sync..."), undefined, true, () => this.turnOn())]
|
||||
primary: [new Action('turn on sync', localize('turn on sync', "Turn on Settings Sync..."), undefined, true, () => this.turnOn())]
|
||||
}
|
||||
});
|
||||
break;
|
||||
case UserDataSyncErrorCode.TurnedOff:
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Info,
|
||||
message: localize('turned off', "Preferences sync was turned off from another device, please sign in again to turn on sync."),
|
||||
message: localize('turned off', "Settings sync was turned off from another device, please sign in again to turn on sync."),
|
||||
actions: {
|
||||
primary: [new Action('turn on sync', localize('turn on sync', "Turn on Preferences Sync..."), undefined, true, () => this.turnOn())]
|
||||
primary: [new Action('turn on sync', localize('turn on sync', "Turn on Settings Sync..."), undefined, true, () => this.turnOn())]
|
||||
}
|
||||
});
|
||||
break;
|
||||
@@ -299,7 +303,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
case UserDataSyncErrorCode.IncompatibleLocalContent:
|
||||
case UserDataSyncErrorCode.Gone:
|
||||
case UserDataSyncErrorCode.UpgradeRequired:
|
||||
const message = localize('error upgrade required', "Preferences sync is disabled because the current version ({0}, {1}) is not compatible with the sync service. Please update before turning on sync.", this.productService.version, this.productService.commit);
|
||||
const message = localize('error upgrade required', "Settings sync is disabled because the current version ({0}, {1}) is not compatible with the sync service. Please update before turning on sync.", this.productService.version, this.productService.commit);
|
||||
const operationId = error.operationId ? localize('operationId', "Operation Id: {0}", error.operationId) : undefined;
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
@@ -309,7 +313,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
case UserDataSyncErrorCode.IncompatibleRemoteContent:
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: localize('error reset required', "Preferences sync is disabled because your data in the cloud is older than that of the client. Please clear your data in the cloud before turning on sync."),
|
||||
message: localize('error reset required', "Settings sync is disabled because your data in the cloud is older than that of the client. Please clear your data in the cloud before turning on sync."),
|
||||
actions: {
|
||||
primary: [
|
||||
new Action('reset', localize('reset', "Clear Data in Cloud..."), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
|
||||
@@ -318,6 +322,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}
|
||||
});
|
||||
return;
|
||||
case UserDataSyncErrorCode.DefaultServiceChanged:
|
||||
if (isEqual(this.userDataSyncStoreManagementService.userDataSyncStore?.url, this.userDataSyncStoreManagementService.userDataSyncStore?.insidersUrl)) {
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Info,
|
||||
message: localize('switched to insiders', "Settings sync now uses a separate service, more information is available in the [release notes](command:update.showCurrentReleaseNotes)."),
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,9 +403,9 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
let priority: number | undefined = undefined;
|
||||
|
||||
if (this.userDataSyncService.conflicts.length && this.userDataAutoSyncService.isEnabled()) {
|
||||
badge = new NumberBadge(this.userDataSyncService.conflicts.reduce((result, [, conflicts]) => { return result + conflicts.length; }, 0), () => localize('has conflicts', "Preferences Sync: Conflicts Detected"));
|
||||
badge = new NumberBadge(this.userDataSyncService.conflicts.reduce((result, [, conflicts]) => { return result + conflicts.length; }, 0), () => localize('has conflicts', "{0}: Conflicts Detected", SYNC_TITLE));
|
||||
} else if (this.turningOnSync) {
|
||||
badge = new ProgressBadge(() => localize('turning on syncing', "Turning on Preferences Sync..."));
|
||||
badge = new ProgressBadge(() => localize('turning on syncing', "Turning on Settings Sync..."));
|
||||
clazz = 'progress-badge';
|
||||
priority = 1;
|
||||
}
|
||||
@@ -409,7 +421,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
let badge: IBadge | undefined = undefined;
|
||||
|
||||
if (this.userDataSyncService.status !== SyncStatus.Uninitialized && this.userDataAutoSyncService.isEnabled() && this.userDataSyncWorkbenchService.accountStatus === AccountStatus.Unavailable) {
|
||||
badge = new NumberBadge(1, () => localize('sign in to sync preferences', "Sign in to Sync Preferences"));
|
||||
badge = new NumberBadge(1, () => localize('sign in to sync', "Sign in to Sync Settings"));
|
||||
}
|
||||
|
||||
if (badge) {
|
||||
@@ -417,17 +429,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}
|
||||
}
|
||||
|
||||
private get turningOnSync(): boolean {
|
||||
return !!this.turningOnSyncContext.get();
|
||||
}
|
||||
|
||||
private set turningOnSync(turningOn: boolean) {
|
||||
this.turningOnSyncContext.set(turningOn);
|
||||
this.updateGlobalActivityBadge();
|
||||
}
|
||||
|
||||
private async turnOn(): Promise<void> {
|
||||
this.turningOnSync = true;
|
||||
try {
|
||||
if (!this.storageService.getBoolean('sync.donotAskPreviewConfirmation', StorageScope.GLOBAL, false)) {
|
||||
if (!await this.askForConfirmation()) {
|
||||
@@ -448,14 +450,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
switch (e.code) {
|
||||
case UserDataSyncErrorCode.TooLarge:
|
||||
if (e.resource === SyncResource.Keybindings || e.resource === SyncResource.Settings) {
|
||||
this.handleTooLargeError(e.resource, localize('too large while starting sync', "Preferences sync cannot be turned on because size of the {0} file to sync is larger than {1}. Please open the file and reduce the size and turn on sync", getSyncAreaLabel(e.resource).toLowerCase(), '100kb'), e);
|
||||
this.handleTooLargeError(e.resource, localize('too large while starting sync', "Settings sync cannot be turned on because size of the {0} file to sync is larger than {1}. Please open the file and reduce the size and turn on sync", getSyncAreaLabel(e.resource).toLowerCase(), '100kb'), e);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case UserDataSyncErrorCode.IncompatibleLocalContent:
|
||||
case UserDataSyncErrorCode.Gone:
|
||||
case UserDataSyncErrorCode.UpgradeRequired:
|
||||
const message = localize('error upgrade required while starting sync', "Preferences sync cannot be turned on because the current version ({0}, {1}) is not compatible with the sync service. Please update before turning on sync.", this.productService.version, this.productService.commit);
|
||||
const message = localize('error upgrade required while starting sync', "Settings sync cannot be turned on because the current version ({0}, {1}) is not compatible with the sync service. Please update before turning on sync.", this.productService.version, this.productService.commit);
|
||||
const operationId = e.operationId ? localize('operationId', "Operation Id: {0}", e.operationId) : undefined;
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
@@ -465,7 +467,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
case UserDataSyncErrorCode.IncompatibleRemoteContent:
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: localize('error reset required while starting sync', "Preferences sync cannot be turned on because your data in the cloud is older than that of the client. Please clear your data in the cloud before turning on sync."),
|
||||
message: localize('error reset required while starting sync', "Settings sync cannot be turned on because your data in the cloud is older than that of the client. Please clear your data in the cloud before turning on sync."),
|
||||
actions: {
|
||||
primary: [
|
||||
new Action('reset', localize('reset', "Clear Data in Cloud..."), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
|
||||
@@ -477,15 +479,13 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}
|
||||
}
|
||||
this.notificationService.error(localize('turn on failed', "Error while starting Sync: {0}", toErrorMessage(e)));
|
||||
} finally {
|
||||
this.turningOnSync = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async askForConfirmation(): Promise<boolean> {
|
||||
const result = await this.dialogService.show(
|
||||
Severity.Info,
|
||||
localize('sync preview message', "Synchronizing your preferences is a preview feature, please read the documentation before turning it on."),
|
||||
localize('sync preview message', "Synchronizing your settings is a preview feature, please read the documentation before turning it on."),
|
||||
[
|
||||
localize('turn on', "Turn On"),
|
||||
localize('open doc', "Open Documentation"),
|
||||
@@ -507,7 +507,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
const disposables: DisposableStore = new DisposableStore();
|
||||
const quickPick = this.quickInputService.createQuickPick<ConfigureSyncQuickPickItem>();
|
||||
disposables.add(quickPick);
|
||||
quickPick.title = localize('Preferences Sync Title', "Preferences Sync");
|
||||
quickPick.title = SYNC_TITLE;
|
||||
quickPick.ok = false;
|
||||
quickPick.customButton = true;
|
||||
if (this.userDataSyncWorkbenchService.all.length) {
|
||||
@@ -553,7 +553,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
label: getSyncAreaLabel(SyncResource.Settings)
|
||||
}, {
|
||||
id: SyncResource.Keybindings,
|
||||
label: getSyncAreaLabel(SyncResource.Keybindings)
|
||||
label: getSyncAreaLabel(SyncResource.Keybindings),
|
||||
description: this.configurationService.getValue('settingsSync.keybindingsPerPlatform') ? localize('per platform', "for each platform") : undefined
|
||||
}, {
|
||||
id: SyncResource.Snippets,
|
||||
label: getSyncAreaLabel(SyncResource.Snippets)
|
||||
@@ -581,7 +582,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
const disposables: DisposableStore = new DisposableStore();
|
||||
const quickPick = this.quickInputService.createQuickPick<ConfigureSyncQuickPickItem>();
|
||||
disposables.add(quickPick);
|
||||
quickPick.title = localize('configure sync', "Preferences Sync: Configure...");
|
||||
quickPick.title = localize('configure sync', "{0}: Configure...", SYNC_TITLE);
|
||||
quickPick.placeholder = localize('configure sync placeholder', "Choose what to sync");
|
||||
quickPick.canSelectMany = true;
|
||||
quickPick.ignoreFocusOut = true;
|
||||
@@ -607,7 +608,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
const result = await this.dialogService.confirm({
|
||||
type: 'info',
|
||||
message: localize('turn off sync confirmation', "Do you want to turn off sync?"),
|
||||
detail: localize('turn off sync detail', "Your settings, keybindings, extensions and UI State will no longer be synced."),
|
||||
detail: localize('turn off sync detail', "Your settings, keybindings, extensions, snippets and UI State will no longer be synced."),
|
||||
primaryButton: localize('turn off', "Turn Off"),
|
||||
checkbox: this.userDataSyncWorkbenchService.accountStatus === AccountStatus.Available ? {
|
||||
label: localize('turn off sync everywhere', "Turn off sync on all your devices and clear the data from the cloud.")
|
||||
@@ -670,6 +671,54 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
return this.outputService.showChannel(Constants.userDataSyncLogChannelId);
|
||||
}
|
||||
|
||||
private async switchSyncService(): Promise<void> {
|
||||
const userDataSyncStore = this.userDataSyncStoreManagementService.userDataSyncStore;
|
||||
if (userDataSyncStore?.insidersUrl && userDataSyncStore?.stableUrl && ![userDataSyncStore.insidersUrl, userDataSyncStore.stableUrl].includes(userDataSyncStore.url)) {
|
||||
return new Promise<void>((c, e) => {
|
||||
const disposables: DisposableStore = new DisposableStore();
|
||||
const quickPick = disposables.add(this.quickInputService.createQuickPick<{ id: UserDataSyncStoreType, label: string, description?: string }>());
|
||||
quickPick.title = localize('switchSyncService.title', "Select Settings Sync Service...");
|
||||
quickPick.placeholder = localize('choose sync service', "Choose settings sync Service to use");
|
||||
quickPick.description = isNative ?
|
||||
localize('choose sync service description', "Switching settings sync service requires restarting {0}", this.productService.nameLong) :
|
||||
localize('choose sync service description web', "Switching settings sync service requires reloading {0}", this.productService.nameLong);
|
||||
quickPick.hideInput = true;
|
||||
const getDescription = (url: URI): string | undefined => {
|
||||
const isCurrent = isEqual(url, userDataSyncStore.url);
|
||||
const isDefault = isEqual(url, userDataSyncStore.defaultUrl);
|
||||
if (isCurrent && isDefault) {
|
||||
return localize('default and current', "Default & Current");
|
||||
}
|
||||
if (isDefault) {
|
||||
return localize('default', "Default");
|
||||
}
|
||||
if (isCurrent) {
|
||||
return localize('current', "Current");
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
quickPick.items = [
|
||||
{
|
||||
id: 'insiders',
|
||||
label: localize('insiders', "Insiders"),
|
||||
description: getDescription(userDataSyncStore.insidersUrl!)
|
||||
},
|
||||
{
|
||||
id: 'stable',
|
||||
label: localize('stable', "Stable"),
|
||||
description: getDescription(userDataSyncStore.stableUrl!)
|
||||
}
|
||||
];
|
||||
disposables.add(quickPick.onDidAccept(() => {
|
||||
this.userDataSyncWorkbenchService.switchSyncService(quickPick.selectedItems[0].id);
|
||||
quickPick.hide();
|
||||
}));
|
||||
disposables.add(quickPick.onDidHide(() => disposables.dispose()));
|
||||
quickPick.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private registerActions(): void {
|
||||
if (this.userDataAutoSyncService.canToggleEnablement()) {
|
||||
this.registerTurnOnSyncAction();
|
||||
@@ -686,6 +735,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
this.registerSyncNowAction();
|
||||
this.registerConfigureSyncAction();
|
||||
this.registerShowSettingsAction();
|
||||
this.registerSwitchSyncServiceAction();
|
||||
this.registerShowLogAction();
|
||||
}
|
||||
|
||||
@@ -696,7 +746,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: turnOnSyncCommand.id,
|
||||
title: localize('global activity turn on sync', "Turn on Preferences Sync...")
|
||||
title: localize('global activity turn on sync', "Turn on Settings Sync...")
|
||||
},
|
||||
when: turnOnSyncWhenContext,
|
||||
order: 1
|
||||
@@ -709,7 +759,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: turnOnSyncCommand.id,
|
||||
title: localize('global activity turn on sync', "Turn on Preferences Sync...")
|
||||
title: localize('global activity turn on sync', "Turn on Settings Sync...")
|
||||
},
|
||||
when: turnOnSyncWhenContext,
|
||||
});
|
||||
@@ -717,7 +767,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '1_sync',
|
||||
command: {
|
||||
id: turnOnSyncCommand.id,
|
||||
title: localize('global activity turn on sync', "Turn on Preferences Sync...")
|
||||
title: localize('global activity turn on sync', "Turn on Settings Sync...")
|
||||
},
|
||||
when: turnOnSyncWhenContext
|
||||
});
|
||||
@@ -729,7 +779,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
constructor() {
|
||||
super({
|
||||
id: 'workbench.userData.actions.turningOn',
|
||||
title: localize('turnin on sync', "Turning on Preferences Sync..."),
|
||||
title: localize('turnin on sync', "Turning on Settings Sync..."),
|
||||
precondition: ContextKeyExpr.false(),
|
||||
menu: [{
|
||||
group: '5_sync',
|
||||
@@ -755,7 +805,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
constructor() {
|
||||
super({
|
||||
id: 'workbench.userData.actions.signin',
|
||||
title: localize('sign in global', "Sign in to Sync Preferences"),
|
||||
title: localize('sign in global', "Sign in to Sync Settings"),
|
||||
menu: {
|
||||
group: '5_sync',
|
||||
id: MenuId.GlobalActivity,
|
||||
@@ -776,7 +826,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '1_sync',
|
||||
command: {
|
||||
id,
|
||||
title: localize('sign in accounts', "Sign in to Sync Preferences (1)"),
|
||||
title: localize('sign in accounts', "Sign in to Sync Settings (1)"),
|
||||
},
|
||||
when
|
||||
}));
|
||||
@@ -789,7 +839,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: resolveSettingsConflictsCommand.id,
|
||||
title: localize('resolveConflicts_global', "Preferences Sync: Show Settings Conflicts (1)"),
|
||||
title: localize('resolveConflicts_global', "{0}: Show Settings Conflicts (1)", SYNC_TITLE),
|
||||
},
|
||||
when: resolveSettingsConflictsWhenContext,
|
||||
order: 2
|
||||
@@ -798,7 +848,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: resolveSettingsConflictsCommand.id,
|
||||
title: localize('resolveConflicts_global', "Preferences Sync: Show Settings Conflicts (1)"),
|
||||
title: localize('resolveConflicts_global', "{0}: Show Settings Conflicts (1)", SYNC_TITLE),
|
||||
},
|
||||
when: resolveSettingsConflictsWhenContext,
|
||||
order: 2
|
||||
@@ -816,7 +866,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: resolveKeybindingsConflictsCommand.id,
|
||||
title: localize('resolveKeybindingsConflicts_global', "Preferences Sync: Show Keybindings Conflicts (1)"),
|
||||
title: localize('resolveKeybindingsConflicts_global', "{0}: Show Keybindings Conflicts (1)", SYNC_TITLE),
|
||||
},
|
||||
when: resolveKeybindingsConflictsWhenContext,
|
||||
order: 2
|
||||
@@ -825,7 +875,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: resolveKeybindingsConflictsCommand.id,
|
||||
title: localize('resolveKeybindingsConflicts_global', "Preferences Sync: Show Keybindings Conflicts (1)"),
|
||||
title: localize('resolveKeybindingsConflicts_global', "{0}: Show Keybindings Conflicts (1)", SYNC_TITLE),
|
||||
},
|
||||
when: resolveKeybindingsConflictsWhenContext,
|
||||
order: 2
|
||||
@@ -846,7 +896,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: resolveSnippetsConflictsCommand.id,
|
||||
title: localize('resolveSnippetsConflicts_global', "Preferences Sync: Show User Snippets Conflicts ({0})", conflicts?.length || 1),
|
||||
title: localize('resolveSnippetsConflicts_global', "{0}: Show User Snippets Conflicts ({1})", SYNC_TITLE, conflicts?.length || 1),
|
||||
},
|
||||
when: resolveSnippetsConflictsWhenContext,
|
||||
order: 2
|
||||
@@ -855,7 +905,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
group: '5_sync',
|
||||
command: {
|
||||
id: resolveSnippetsConflictsCommand.id,
|
||||
title: localize('resolveSnippetsConflicts_global', "Preferences Sync: Show User Snippets Conflicts ({0})", conflicts?.length || 1),
|
||||
title: localize('resolveSnippetsConflicts_global', "{0}: Show User Snippets Conflicts ({1})", SYNC_TITLE, conflicts?.length || 1),
|
||||
},
|
||||
when: resolveSnippetsConflictsWhenContext,
|
||||
order: 2
|
||||
@@ -873,7 +923,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
constructor() {
|
||||
super({
|
||||
id: 'workbench.userDataSync.actions.manage',
|
||||
title: localize('sync is on', "Preferences Sync is On"),
|
||||
title: localize('sync is on', "Settings Sync is On"),
|
||||
menu: [
|
||||
{
|
||||
id: MenuId.GlobalActivity,
|
||||
@@ -953,7 +1003,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
super({
|
||||
id: showSyncedDataCommand.id,
|
||||
title: { value: localize('workbench.action.showSyncRemoteBackup', "Show Synced Data"), original: `Show Synced Data` },
|
||||
category: { value: localize('sync preferences', "Preferences Sync"), original: `Preferences Sync` },
|
||||
category: { value: SYNC_TITLE, original: `Settings Sync` },
|
||||
precondition: when,
|
||||
menu: {
|
||||
id: MenuId.CommandPalette,
|
||||
@@ -1035,7 +1085,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
constructor() {
|
||||
super({
|
||||
id: SHOW_SYNC_LOG_COMMAND_ID,
|
||||
title: localize('show sync log title', "Preferences Sync: Show Log"),
|
||||
title: localize('show sync log title', "{0}: Show Log", SYNC_TITLE),
|
||||
menu: {
|
||||
id: MenuId.CommandPalette,
|
||||
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized)),
|
||||
@@ -1064,6 +1114,28 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}));
|
||||
}
|
||||
|
||||
private registerSwitchSyncServiceAction(): void {
|
||||
const that = this;
|
||||
const userDataSyncStore = this.userDataSyncStoreManagementService.userDataSyncStore;
|
||||
if (userDataSyncStore?.insidersUrl && userDataSyncStore?.stableUrl && ![userDataSyncStore.insidersUrl, userDataSyncStore.stableUrl].includes(userDataSyncStore.url)) {
|
||||
this._register(registerAction2(class ShowSyncSettingsAction extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: 'workbench.userDataSync.actions.switchSyncService',
|
||||
title: { value: localize('workbench.userDataSync.actions.switchSyncService', "{0}: Select Service...", SYNC_TITLE), original: 'Settings Sync: Select Service...' },
|
||||
menu: {
|
||||
id: MenuId.CommandPalette,
|
||||
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized)),
|
||||
},
|
||||
});
|
||||
}
|
||||
run(accessor: ServicesAccessor): any {
|
||||
return that.switchSyncService();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private registerViews(): void {
|
||||
const container = this.registerViewContainer();
|
||||
this.registerDataViews(container);
|
||||
@@ -1073,7 +1145,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
return Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer(
|
||||
{
|
||||
id: SYNC_VIEW_CONTAINER_ID,
|
||||
name: localize('sync preferences', "Preferences Sync"),
|
||||
name: SYNC_TITLE,
|
||||
ctorDescriptor: new SyncDescriptor(
|
||||
UserDataSyncViewPaneContainer,
|
||||
[SYNC_VIEW_CONTAINER_ID]
|
||||
@@ -1189,8 +1261,8 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
|
||||
const result = await this.dialogService.confirm({
|
||||
type: 'info',
|
||||
title: isRemote
|
||||
? localize('Sync accept remote', "Preferences Sync: {0}", acceptRemoteLabel)
|
||||
: localize('Sync accept merges', "Preferences Sync: {0}", acceptMergesLabel),
|
||||
? localize('Sync accept remote', "{0}: {1}", SYNC_TITLE, acceptRemoteLabel)
|
||||
: localize('Sync accept merges', "{0}: {1}", SYNC_TITLE, acceptMergesLabel),
|
||||
message: isRemote
|
||||
? localize('confirm replace and overwrite local', "Would you like to accept remote {0} and replace local {1}?", syncAreaLabel.toLowerCase(), syncAreaLabel.toLowerCase())
|
||||
: localize('confirm replace and overwrite remote', "Would you like to accept merges and replace remote {0}?", syncAreaLabel.toLowerCase()),
|
||||
|
||||
Reference in New Issue
Block a user