mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 02:48:30 -05:00
Merge from vscode 0a7364f00514c46c9caceece15e1f82f82e3712f
This commit is contained in:
@@ -140,6 +140,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
this.updateGlobalActivityBadge();
|
||||
}));
|
||||
this._register(userDataSyncService.onDidChangeConflicts(() => this.onDidChangeConflicts(this.userDataSyncService.conflicts)));
|
||||
this._register(userDataAutoSyncService.onDidChangeEnablement(() => this.onDidChangeConflicts(this.userDataSyncService.conflicts)));
|
||||
this._register(userDataSyncService.onSyncErrors(errors => this.onSynchronizerErrors(errors)));
|
||||
this._register(userDataAutoSyncService.onError(error => this.onAutoSyncError(error)));
|
||||
|
||||
@@ -153,6 +154,9 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
|
||||
private readonly conflictsDisposables = new Map<SyncResource, IDisposable>();
|
||||
private onDidChangeConflicts(conflicts: [SyncResource, IResourcePreview[]][]) {
|
||||
if (!this.userDataAutoSyncService.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
this.updateGlobalActivityBadge();
|
||||
if (conflicts.length) {
|
||||
const conflictsSources: SyncResource[] = conflicts.map(([syncResource]) => syncResource);
|
||||
@@ -194,14 +198,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}
|
||||
},
|
||||
{
|
||||
label: localize('accept local', "Accept Local"),
|
||||
label: localize('accept merges', "Accept Merges"),
|
||||
run: () => {
|
||||
this.telemetryService.publicLog2<{ source: string, action: string }, SyncConflictsClassification>('sync/handleConflicts', { source: syncResource, action: 'acceptLocal' });
|
||||
this.acceptLocal(syncResource, conflicts);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: localize('show conflicts', "Show Conflicts"),
|
||||
label: localize('show merges', "Show Merges"),
|
||||
run: () => {
|
||||
this.telemetryService.publicLog2<{ source: string, action?: string }, SyncConflictsClassification>('sync/showConflicts', { source: syncResource });
|
||||
this.handleConflicts([syncResource, conflicts]);
|
||||
@@ -240,7 +244,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
for (const conflict of conflicts) {
|
||||
const modelRef = await this.textModelResolverService.createModelReference(conflict.remoteResource);
|
||||
try {
|
||||
await this.userDataSyncService.acceptPreviewContent(syncResource, conflict.remoteResource, modelRef.object.textEditorModel.getValue());
|
||||
await this.userDataSyncService.accept(syncResource, conflict.remoteResource, modelRef.object.textEditorModel.getValue(), this.userDataAutoSyncService.isEnabled());
|
||||
} finally {
|
||||
modelRef.dispose();
|
||||
}
|
||||
@@ -255,7 +259,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
for (const conflict of conflicts) {
|
||||
const modelRef = await this.textModelResolverService.createModelReference(conflict.previewResource);
|
||||
try {
|
||||
await this.userDataSyncService.acceptPreviewContent(syncResource, conflict.previewResource, modelRef.object.textEditorModel.getValue());
|
||||
await this.userDataSyncService.accept(syncResource, conflict.previewResource, modelRef.object.textEditorModel.getValue(), this.userDataAutoSyncService.isEnabled());
|
||||
} finally {
|
||||
modelRef.dispose();
|
||||
}
|
||||
@@ -305,10 +309,10 @@ 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 in the client. Please reset your data in the cloud before turning on sync."),
|
||||
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."),
|
||||
actions: {
|
||||
primary: [
|
||||
new Action('reset', localize('reset', "Reset Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
|
||||
new Action('reset', localize('reset', "Clear Data in Cloud..."), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
|
||||
new Action('show synced data', localize('show synced data action', "Show Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.showSyncActivity())
|
||||
]
|
||||
}
|
||||
@@ -386,7 +390,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
let clazz: string | undefined;
|
||||
let priority: number | undefined = undefined;
|
||||
|
||||
if (this.userDataSyncService.conflicts.length) {
|
||||
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"));
|
||||
} else if (this.turningOnSync) {
|
||||
badge = new ProgressBadge(() => localize('turning on syncing', "Turning on Preferences Sync..."));
|
||||
@@ -461,10 +465,10 @@ 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 in the client. Please reset your data in the cloud before turning on sync."),
|
||||
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."),
|
||||
actions: {
|
||||
primary: [
|
||||
new Action('reset', localize('reset', "Reset Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
|
||||
new Action('reset', localize('reset', "Clear Data in Cloud..."), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
|
||||
new Action('show synced data', localize('show synced data action', "Show Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.showSyncActivity())
|
||||
]
|
||||
}
|
||||
@@ -483,8 +487,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
Severity.Info,
|
||||
localize('sync preview message', "Synchronizing your preferences is a preview feature, please read the documentation before turning it on."),
|
||||
[
|
||||
localize('open doc', "Open Documentation"),
|
||||
localize('turn on', "Turn On"),
|
||||
localize('open doc', "Open Documentation"),
|
||||
localize('cancel', "Cancel"),
|
||||
],
|
||||
{
|
||||
@@ -492,7 +496,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
}
|
||||
);
|
||||
switch (result.choice) {
|
||||
case 0: this.openerService.open(URI.parse('https://aka.ms/vscode-settings-sync-help')); return false;
|
||||
case 1: this.openerService.open(URI.parse('https://aka.ms/vscode-settings-sync-help')); return false;
|
||||
case 2: return false;
|
||||
}
|
||||
return true;
|
||||
@@ -647,18 +651,12 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
||||
|
||||
private async handleConflicts([syncResource, conflicts]: [SyncResource, IResourcePreview[]]): Promise<void> {
|
||||
for (const conflict of conflicts) {
|
||||
let label: string | undefined = undefined;
|
||||
if (syncResource === SyncResource.Settings) {
|
||||
label = localize('settings conflicts preview', "Settings Conflicts (Remote ↔ Local)");
|
||||
} else if (syncResource === SyncResource.Keybindings) {
|
||||
label = localize('keybindings conflicts preview', "Keybindings Conflicts (Remote ↔ Local)");
|
||||
} else if (syncResource === SyncResource.Snippets) {
|
||||
label = localize('snippets conflicts preview', "User Snippet Conflicts (Remote ↔ Local) - {0}", basename(conflict.previewResource));
|
||||
}
|
||||
const leftResourceName = localize({ key: 'leftResourceName', comment: ['remote as in file in cloud'] }, "{0} (Remote)", basename(conflict.remoteResource));
|
||||
const rightResourceName = localize('merges', "{0} (Merges)", basename(conflict.previewResource));
|
||||
await this.editorService.openEditor({
|
||||
leftResource: conflict.remoteResource,
|
||||
rightResource: conflict.previewResource,
|
||||
label,
|
||||
label: localize('sideBySideLabels', "{0} ↔ {1}", leftResourceName, rightResourceName),
|
||||
options: {
|
||||
preserveFocus: false,
|
||||
pinned: true,
|
||||
@@ -1125,7 +1123,8 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IDialogService private readonly dialogService: IDialogService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@IUserDataAutoSyncService private readonly userDataAutoSyncService: IUserDataAutoSyncService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -1154,6 +1153,10 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
|
||||
return false; // we need a model
|
||||
}
|
||||
|
||||
if (!this.userDataAutoSyncService.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const syncResourceConflicts = this.getSyncResourceConflicts(model.uri);
|
||||
if (!syncResourceConflicts) {
|
||||
return false;
|
||||
@@ -1176,8 +1179,8 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
|
||||
const [syncResource, conflicts] = this.getSyncResourceConflicts(resource)!;
|
||||
const isRemote = conflicts.some(({ remoteResource }) => isEqual(remoteResource, resource));
|
||||
const acceptRemoteLabel = localize('accept remote', "Accept Remote");
|
||||
const acceptLocalLabel = localize('accept local', "Accept Local");
|
||||
this.acceptChangesButton = this.instantiationService.createInstance(FloatingClickWidget, this.editor, isRemote ? acceptRemoteLabel : acceptLocalLabel, null);
|
||||
const acceptMergesLabel = localize('accept merges', "Accept Merges");
|
||||
this.acceptChangesButton = this.instantiationService.createInstance(FloatingClickWidget, this.editor, isRemote ? acceptRemoteLabel : acceptMergesLabel, null);
|
||||
this._register(this.acceptChangesButton.onClick(async () => {
|
||||
const model = this.editor.getModel();
|
||||
if (model) {
|
||||
@@ -1187,15 +1190,15 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
|
||||
type: 'info',
|
||||
title: isRemote
|
||||
? localize('Sync accept remote', "Preferences Sync: {0}", acceptRemoteLabel)
|
||||
: localize('Sync accept local', "Preferences Sync: {0}", acceptLocalLabel),
|
||||
: localize('Sync accept merges', "Preferences Sync: {0}", 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 local {0} and replace remote {1}?", syncAreaLabel.toLowerCase(), syncAreaLabel.toLowerCase()),
|
||||
primaryButton: isRemote ? acceptRemoteLabel : acceptLocalLabel
|
||||
: localize('confirm replace and overwrite remote', "Would you like to accept merges and replace remote {0}?", syncAreaLabel.toLowerCase()),
|
||||
primaryButton: isRemote ? acceptRemoteLabel : acceptMergesLabel
|
||||
});
|
||||
if (result.confirmed) {
|
||||
try {
|
||||
await this.userDataSyncService.acceptPreviewContent(syncResource, model.uri, model.getValue());
|
||||
await this.userDataSyncService.accept(syncResource, model.uri, model.getValue(), true);
|
||||
} catch (e) {
|
||||
if (e instanceof UserDataSyncError && e.code === UserDataSyncErrorCode.LocalPreconditionFailed) {
|
||||
const syncResourceCoflicts = this.userDataSyncService.conflicts.filter(syncResourceCoflicts => syncResourceCoflicts[0] === syncResource)[0];
|
||||
|
||||
Reference in New Issue
Block a user