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:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataSyncService, IUserDataSyncLogService, IUserDataSyncResourceEnablementService, IUserDataSyncStoreService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { IUserDataSyncService, IUserDataSyncLogService, IUserDataSyncResourceEnablementService, IUserDataSyncStoreService, IUserDataSyncStoreManagementService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { UserDataAutoSyncService as BaseUserDataAutoSyncService } from 'vs/platform/userDataSync/common/userDataAutoSyncService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -18,6 +18,7 @@ import { IUserDataSyncMachinesService } from 'vs/platform/userDataSync/common/us
|
||||
export class UserDataAutoSyncService extends BaseUserDataAutoSyncService {
|
||||
|
||||
constructor(
|
||||
@IUserDataSyncStoreManagementService userDataSyncStoreManagementService: IUserDataSyncStoreManagementService,
|
||||
@IUserDataSyncStoreService userDataSyncStoreService: IUserDataSyncStoreService,
|
||||
@IUserDataSyncResourceEnablementService userDataSyncResourceEnablementService: IUserDataSyncResourceEnablementService,
|
||||
@IUserDataSyncService userDataSyncService: IUserDataSyncService,
|
||||
@@ -30,7 +31,7 @@ export class UserDataAutoSyncService extends BaseUserDataAutoSyncService {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
) {
|
||||
super(userDataSyncStoreService, userDataSyncResourceEnablementService, userDataSyncService, logService, authTokenService, telemetryService, userDataSyncMachinesService, storageService, environmentService);
|
||||
super(userDataSyncStoreManagementService, userDataSyncStoreService, userDataSyncResourceEnablementService, userDataSyncService, logService, authTokenService, telemetryService, userDataSyncMachinesService, storageService, environmentService);
|
||||
|
||||
this._register(Event.debounce<string, string[]>(Event.any<string>(
|
||||
Event.map(hostService.onDidChangeFocus, () => 'windowFocus'),
|
||||
|
||||
@@ -12,6 +12,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
import { isWeb } from 'vs/base/common/platform';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
class UserDataSyncReportIssueContribution extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
@@ -28,7 +29,7 @@ class UserDataSyncReportIssueContribution extends Disposable implements IWorkben
|
||||
case UserDataSyncErrorCode.LocalTooManyRequests:
|
||||
case UserDataSyncErrorCode.TooManyRequests:
|
||||
const operationId = error.operationId ? localize('operationId', "Operation Id: {0}", error.operationId) : undefined;
|
||||
const message = localize('too many requests', "Turned off syncing preferences on this device because it is making too many requests.");
|
||||
const message = localize('too many requests', "Turned off syncing settings on this device because it is making too many requests.");
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: operationId ? `${message} ${operationId}` : message,
|
||||
@@ -38,8 +39,34 @@ class UserDataSyncReportIssueContribution extends Disposable implements IWorkben
|
||||
}
|
||||
}
|
||||
|
||||
export class UserDataSyncSettingsMigrationContribution implements IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
this.migrateSettings();
|
||||
}
|
||||
|
||||
private async migrateSettings(): Promise<void> {
|
||||
await this.migrateSetting('sync.keybindingsPerPlatform', 'settingsSync.keybindingsPerPlatform');
|
||||
await this.migrateSetting('sync.ignoredExtensions', 'settingsSync.ignoredExtensions');
|
||||
await this.migrateSetting('sync.ignoredSettings', 'settingsSync.ignoredSettings');
|
||||
}
|
||||
|
||||
private async migrateSetting(oldSetting: string, newSetting: string): Promise<void> {
|
||||
const userValue = this.configurationService.inspect(oldSetting).userValue;
|
||||
if (userValue !== undefined) {
|
||||
// remove the old setting
|
||||
await this.configurationService.updateValue(oldSetting, undefined, ConfigurationTarget.USER);
|
||||
// add the new setting
|
||||
await this.configurationService.updateValue(newSetting, userValue, ConfigurationTarget.USER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
workbenchRegistry.registerWorkbenchContribution(UserDataSyncWorkbenchContribution, LifecyclePhase.Ready);
|
||||
workbenchRegistry.registerWorkbenchContribution(UserDataSyncSettingsMigrationContribution, LifecyclePhase.Eventually);
|
||||
|
||||
if (isWeb) {
|
||||
workbenchRegistry.registerWorkbenchContribution(UserDataSyncReportIssueContribution, LifecyclePhase.Ready);
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -54,7 +54,6 @@ export class UserDataSyncMergesViewPane extends TreeViewPane {
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IDialogService private readonly dialogService: IDialogService,
|
||||
@IProgressService private readonly progressService: IProgressService,
|
||||
@IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService,
|
||||
@IUserDataSyncWorkbenchService userDataSyncWorkbenchService: IUserDataSyncWorkbenchService,
|
||||
@IDecorationsService decorationsService: IDecorationsService,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@@ -72,7 +71,7 @@ export class UserDataSyncMergesViewPane extends TreeViewPane {
|
||||
|
||||
this._register(this.userDataSyncPreview.onDidChangeResources(() => this.updateSyncButtonEnablement()));
|
||||
this._register(this.userDataSyncPreview.onDidChangeResources(() => this.treeView.refresh()));
|
||||
this._register(this.userDataSyncPreview.onDidChangeResources(() => this.closeConflictEditors()));
|
||||
this._register(this.userDataSyncPreview.onDidChangeResources(() => this.closeDiffEditors()));
|
||||
this._register(decorationsService.registerDecorationsProvider(this._register(new UserDataSyncResourcesDecorationProvider(this.userDataSyncPreview))));
|
||||
|
||||
this.registerActions();
|
||||
@@ -91,7 +90,7 @@ export class UserDataSyncMergesViewPane extends TreeViewPane {
|
||||
this.buttonsContainer = DOM.append(container, DOM.$('.manual-sync-buttons-container'));
|
||||
|
||||
this.syncButton = this._register(new Button(this.buttonsContainer));
|
||||
this.syncButton.label = localize('turn on sync', "Turn on Preferences Sync");
|
||||
this.syncButton.label = localize('turn on sync', "Turn on Settings Sync");
|
||||
this.updateSyncButtonEnablement();
|
||||
this._register(attachButtonStyler(this.syncButton, this.themeService));
|
||||
this._register(this.syncButton.onDidClick(() => this.apply()));
|
||||
@@ -251,16 +250,14 @@ export class UserDataSyncMergesViewPane extends TreeViewPane {
|
||||
|
||||
private async acceptLocal(userDataSyncResource: IUserDataSyncResource): Promise<void> {
|
||||
await this.withProgress(async () => {
|
||||
const content = await this.userDataSyncService.resolveContent(userDataSyncResource.local);
|
||||
await this.userDataSyncPreview.accept(userDataSyncResource.syncResource, userDataSyncResource.local, content);
|
||||
await this.userDataSyncPreview.accept(userDataSyncResource.syncResource, userDataSyncResource.local);
|
||||
});
|
||||
await this.reopen(userDataSyncResource);
|
||||
}
|
||||
|
||||
private async acceptRemote(userDataSyncResource: IUserDataSyncResource): Promise<void> {
|
||||
await this.withProgress(async () => {
|
||||
const content = await this.userDataSyncService.resolveContent(userDataSyncResource.remote);
|
||||
await this.userDataSyncPreview.accept(userDataSyncResource.syncResource, userDataSyncResource.remote, content);
|
||||
await this.userDataSyncPreview.accept(userDataSyncResource.syncResource, userDataSyncResource.remote);
|
||||
});
|
||||
await this.reopen(userDataSyncResource);
|
||||
}
|
||||
@@ -352,12 +349,13 @@ export class UserDataSyncMergesViewPane extends TreeViewPane {
|
||||
}
|
||||
}
|
||||
|
||||
private closeConflictEditors() {
|
||||
private closeDiffEditors() {
|
||||
for (const previewResource of this.userDataSyncPreview.resources) {
|
||||
if (previewResource.mergeState !== MergeState.Conflict) {
|
||||
if (previewResource.mergeState === MergeState.Accepted) {
|
||||
for (const input of this.editorService.editors) {
|
||||
if (input instanceof DiffEditorInput) {
|
||||
if (isEqual(previewResource.remote, input.secondary.resource) && isEqual(previewResource.merged, input.primary.resource)) {
|
||||
if (isEqual(previewResource.remote, input.secondary.resource) &&
|
||||
(isEqual(previewResource.merged, input.primary.resource) || isEqual(previewResource.local, input.primary.resource))) {
|
||||
input.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,14 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { IUserDataSyncWorkbenchService, CONTEXT_SYNC_STATE, getSyncAreaLabel, CONTEXT_ACCOUNT_STATE, AccountStatus, CONTEXT_ENABLE_ACTIVITY_VIEWS, SHOW_SYNC_LOG_COMMAND_ID, CONFIGURE_SYNC_COMMAND_ID, SYNC_MERGES_VIEW_ID, CONTEXT_ENABLE_SYNC_MERGES_VIEW } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { IUserDataSyncWorkbenchService, CONTEXT_SYNC_STATE, getSyncAreaLabel, CONTEXT_ACCOUNT_STATE, AccountStatus, CONTEXT_ENABLE_ACTIVITY_VIEWS, SHOW_SYNC_LOG_COMMAND_ID, CONFIGURE_SYNC_COMMAND_ID, SYNC_MERGES_VIEW_ID, CONTEXT_ENABLE_SYNC_MERGES_VIEW, SYNC_TITLE } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { IUserDataSyncMachinesService, IUserDataSyncMachine } from 'vs/platform/userDataSync/common/userDataSyncMachines';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { TreeView } from 'vs/workbench/contrib/views/browser/treeView';
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { UserDataSyncMergesViewPane } from 'vs/workbench/contrib/userDataSync/browser/userDataSyncMergesView';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
|
||||
export class UserDataSyncViewPaneContainer extends ViewPaneContainer {
|
||||
|
||||
@@ -80,6 +81,8 @@ export class UserDataSyncDataViews extends Disposable {
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IUserDataAutoSyncService private readonly userDataAutoSyncService: IUserDataAutoSyncService,
|
||||
@IUserDataSyncResourceEnablementService private readonly userDataSyncResourceEnablementService: IUserDataSyncResourceEnablementService,
|
||||
@IUserDataSyncMachinesService private readonly userDataSyncMachinesService: IUserDataSyncMachinesService,
|
||||
@IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService,
|
||||
) {
|
||||
super();
|
||||
this.registerViews(container);
|
||||
@@ -122,7 +125,7 @@ export class UserDataSyncDataViews extends Disposable {
|
||||
treeView.dataProvider = dataProvider;
|
||||
}
|
||||
});
|
||||
this._register(Event.any(this.userDataSyncResourceEnablementService.onDidChangeResourceEnablement, this.userDataAutoSyncService.onDidChangeEnablement)(() => treeView.refresh()));
|
||||
this._register(Event.any(this.userDataSyncMachinesService.onDidChange, this.userDataSyncService.onDidResetRemote)(() => treeView.refresh()));
|
||||
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
|
||||
viewsRegistry.registerViews([<ITreeViewDescriptor>{
|
||||
id,
|
||||
@@ -161,7 +164,7 @@ export class UserDataSyncDataViews extends Disposable {
|
||||
constructor() {
|
||||
super({
|
||||
id: `workbench.actions.sync.turnOffSyncOnMachine`,
|
||||
title: localize('workbench.actions.sync.turnOffSyncOnMachine', "Turn off Preferences Sync"),
|
||||
title: localize('workbench.actions.sync.turnOffSyncOnMachine', "Turn off Settings Sync"),
|
||||
menu: {
|
||||
id: MenuId.ViewItemContext,
|
||||
when: ContextKeyExpr.and(ContextKeyEqualsExpr.create('view', id), ContextKeyEqualsExpr.create('viewItem', 'sync-machine')),
|
||||
@@ -190,7 +193,10 @@ export class UserDataSyncDataViews extends Disposable {
|
||||
: this.instantiationService.createInstance(LocalUserDataSyncActivityViewDataProvider);
|
||||
}
|
||||
});
|
||||
this._register(Event.any(this.userDataSyncResourceEnablementService.onDidChangeResourceEnablement, this.userDataAutoSyncService.onDidChangeEnablement)(() => treeView.refresh()));
|
||||
this._register(Event.any(this.userDataSyncResourceEnablementService.onDidChangeResourceEnablement,
|
||||
this.userDataAutoSyncService.onDidChangeEnablement,
|
||||
this.userDataSyncService.onDidResetLocal,
|
||||
this.userDataSyncService.onDidResetRemote)(() => treeView.refresh()));
|
||||
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
|
||||
viewsRegistry.registerViews([<ITreeViewDescriptor>{
|
||||
id,
|
||||
@@ -247,7 +253,7 @@ export class UserDataSyncDataViews extends Disposable {
|
||||
const result = await dialogService.confirm({
|
||||
message: localize({ key: 'confirm replace', comment: ['A confirmation message to replace current user data (settings, extensions, keybindings, snippets) with selected version'] }, "Would you like to replace your current {0} with selected?", getSyncAreaLabel(syncResource)),
|
||||
type: 'info',
|
||||
title: localize('preferences sync', "Preferences Sync")
|
||||
title: SYNC_TITLE
|
||||
});
|
||||
if (result.confirmed) {
|
||||
return userDataSyncService.replace(URI.parse(resource));
|
||||
@@ -264,19 +270,20 @@ export class UserDataSyncDataViews extends Disposable {
|
||||
}
|
||||
async run(accessor: ServicesAccessor, handle: TreeViewItemHandleArg): Promise<void> {
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const { resource, comparableResource } = <{ resource: string, comparableResource?: string }>JSON.parse(handle.$treeItemHandle);
|
||||
if (comparableResource) {
|
||||
await editorService.openEditor({
|
||||
leftResource: URI.parse(resource),
|
||||
rightResource: URI.parse(comparableResource),
|
||||
options: {
|
||||
preserveFocus: true,
|
||||
revealIfVisible: true,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await editorService.openEditor({ resource: URI.parse(resource) });
|
||||
}
|
||||
const { resource, comparableResource } = <{ resource: string, comparableResource: string }>JSON.parse(handle.$treeItemHandle);
|
||||
const leftResource = URI.parse(resource);
|
||||
const leftResourceName = localize({ key: 'leftResourceName', comment: ['remote as in file in cloud'] }, "{0} (Remote)", basename(leftResource));
|
||||
const rightResource = URI.parse(comparableResource);
|
||||
const rightResourceName = localize({ key: 'rightResourceName', comment: ['local as in file in disk'] }, "{0} (Local)", basename(rightResource));
|
||||
await editorService.openEditor({
|
||||
leftResource,
|
||||
rightResource,
|
||||
label: localize('sideBySideLabels', "{0} ↔ {1}", leftResourceName, rightResourceName),
|
||||
options: {
|
||||
preserveFocus: true,
|
||||
revealIfVisible: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -354,7 +361,7 @@ abstract class UserDataSyncActivityViewDataProvider implements ITreeViewDataProv
|
||||
protected async getChildrenForSyncResourceTreeItem(element: SyncResourceHandleTreeItem): Promise<ITreeItem[]> {
|
||||
const associatedResources = await this.userDataSyncService.getAssociatedResources((<SyncResourceHandleTreeItem>element).syncResourceHandle.syncResource, (<SyncResourceHandleTreeItem>element).syncResourceHandle);
|
||||
return associatedResources.map(({ resource, comparableResource }) => {
|
||||
const handle = JSON.stringify({ resource: resource.toString(), comparableResource: comparableResource?.toString() });
|
||||
const handle = JSON.stringify({ resource: resource.toString(), comparableResource: comparableResource.toString() });
|
||||
return {
|
||||
handle,
|
||||
collapsibleState: TreeItemCollapsibleState.None,
|
||||
@@ -419,11 +426,13 @@ class RemoteUserDataSyncActivityViewDataProvider extends UserDataSyncActivityVie
|
||||
|
||||
protected async getChildrenForSyncResourceTreeItem(element: SyncResourceHandleTreeItem): Promise<ITreeItem[]> {
|
||||
const children = await super.getChildrenForSyncResourceTreeItem(element);
|
||||
const machineId = await this.userDataSyncService.getMachineId(element.syncResourceHandle.syncResource, element.syncResourceHandle);
|
||||
if (machineId) {
|
||||
const machines = await this.getMachines();
|
||||
const machine = machines.find(({ id }) => id === machineId);
|
||||
children[0].description = machine?.isCurrent ? localize({ key: 'current', comment: ['Represents current machine'] }, "Current") : machine?.name;
|
||||
if (children.length) {
|
||||
const machineId = await this.userDataSyncService.getMachineId(element.syncResourceHandle.syncResource, element.syncResourceHandle);
|
||||
if (machineId) {
|
||||
const machines = await this.getMachines();
|
||||
const machine = machines.find(({ id }) => id === machineId);
|
||||
children[0].description = machine?.isCurrent ? localize({ key: 'current', comment: ['Represents current machine'] }, "Current") : machine?.name;
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataAutoSyncService, UserDataSyncError } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { IUserDataAutoSyncService, UserDataSyncError, IUserDataSyncStoreManagementService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
@@ -23,10 +23,11 @@ export class UserDataAutoSyncService extends UserDataAutoSyncEnablementService i
|
||||
constructor(
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IUserDataSyncStoreManagementService userDataSyncStoreManagementService: IUserDataSyncStoreManagementService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
||||
) {
|
||||
super(storageService, environmentService);
|
||||
super(storageService, environmentService, userDataSyncStoreManagementService);
|
||||
this.channel = sharedProcessService.getChannel('userDataAutoSync');
|
||||
this._register(instantiationService.createInstance(UserDataSyncTrigger).onDidTriggerSync(source => this.triggerSync([source], true)));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Action } from 'vs/base/common/actions';
|
||||
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-browser/issue';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { CONTEXT_SYNC_STATE, SHOW_SYNC_LOG_COMMAND_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { CONTEXT_SYNC_STATE, SHOW_SYNC_LOG_COMMAND_ID, SYNC_TITLE } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
|
||||
class UserDataSyncServicesContribution implements IWorkbenchContribution {
|
||||
|
||||
@@ -49,11 +49,11 @@ class UserDataSyncReportIssueContribution extends Disposable implements IWorkben
|
||||
case UserDataSyncErrorCode.LocalTooManyRequests:
|
||||
case UserDataSyncErrorCode.TooManyRequests:
|
||||
const operationId = error.operationId ? localize('operationId', "Operation Id: {0}", error.operationId) : undefined;
|
||||
const message = localize({ key: 'too many requests', comment: ['Preferences Sync is the name of the feature'] }, "Preferences sync is disabled because the current device is making too many requests. Please report an issue by providing the sync logs.");
|
||||
const message = localize({ key: 'too many requests', comment: ['Settings Sync is the name of the feature'] }, "Settings sync is disabled because the current device is making too many requests. Please report an issue by providing the sync logs.");
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: operationId ? `${message} ${operationId}` : message,
|
||||
source: error.operationId ? localize('preferences sync', "Preferences Sync. Operation Id: {0}", error.operationId) : undefined,
|
||||
source: error.operationId ? localize('settings sync', "Settings Sync. Operation Id: {0}", error.operationId) : undefined,
|
||||
actions: {
|
||||
primary: [
|
||||
new Action('Show Sync Logs', localize('show sync logs', "Show Log"), undefined, true, () => this.commandService.executeCommand(SHOW_SYNC_LOG_COMMAND_ID)),
|
||||
@@ -75,7 +75,7 @@ registerAction2(class OpenSyncBackupsFolder extends Action2 {
|
||||
super({
|
||||
id: 'workbench.userData.actions.openSyncBackupsFolder',
|
||||
title: { value: localize('Open Backup folder', "Open Local Backups Folder"), original: 'Open Local Backups Folder' },
|
||||
category: { value: localize('sync preferences', "Preferences Sync"), original: `Preferences Sync` },
|
||||
category: { value: SYNC_TITLE, original: `Settings Sync` },
|
||||
menu: {
|
||||
id: MenuId.CommandPalette,
|
||||
when: CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized),
|
||||
@@ -85,8 +85,14 @@ registerAction2(class OpenSyncBackupsFolder extends Action2 {
|
||||
async run(accessor: ServicesAccessor): Promise<void> {
|
||||
const syncHome = accessor.get(IEnvironmentService).userDataSyncHome;
|
||||
const electronService = accessor.get(IElectronService);
|
||||
const folderStat = await accessor.get(IFileService).resolve(syncHome);
|
||||
const item = folderStat.children && folderStat.children[0] ? folderStat.children[0].resource : syncHome;
|
||||
return electronService.showItemInFolder(item.fsPath);
|
||||
const fileService = accessor.get(IFileService);
|
||||
const notificationService = accessor.get(INotificationService);
|
||||
if (await fileService.exists(syncHome)) {
|
||||
const folderStat = await fileService.resolve(syncHome);
|
||||
const item = folderStat.children && folderStat.children[0] ? folderStat.children[0].resource : syncHome;
|
||||
return electronService.showItemInFolder(item.fsPath);
|
||||
} else {
|
||||
notificationService.info(localize('no backups', "Local backups folder does not exist"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataSyncStoreManagementService, UserDataSyncStoreType, IUserDataSyncStore } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { AbstractUserDataSyncStoreManagementService } from 'vs/platform/userDataSync/common/userDataSyncStoreService';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export class UserDataSyncStoreManagementService extends AbstractUserDataSyncStoreManagementService implements IUserDataSyncStoreManagementService {
|
||||
|
||||
private readonly channel: IChannel;
|
||||
|
||||
constructor(
|
||||
@IProductService productService: IProductService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
||||
) {
|
||||
super(productService, configurationService, storageService);
|
||||
this.channel = sharedProcessService.getChannel('userDataSyncStoreManagement');
|
||||
}
|
||||
|
||||
async switch(type: UserDataSyncStoreType): Promise<void> {
|
||||
return this.channel.call('switch', [type]);
|
||||
}
|
||||
|
||||
async getPreviousUserDataSyncStore(): Promise<IUserDataSyncStore> {
|
||||
const userDataSyncStore = await this.channel.call<IUserDataSyncStore>('getPreviousUserDataSyncStore');
|
||||
return this.revive(userDataSyncStore);
|
||||
}
|
||||
|
||||
private revive(userDataSyncStore: IUserDataSyncStore): IUserDataSyncStore {
|
||||
return {
|
||||
url: URI.revive(userDataSyncStore.url),
|
||||
defaultUrl: URI.revive(userDataSyncStore.defaultUrl),
|
||||
insidersUrl: URI.revive(userDataSyncStore.insidersUrl),
|
||||
stableUrl: URI.revive(userDataSyncStore.stableUrl),
|
||||
authenticationProviders: userDataSyncStore.authenticationProviders,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user