Merge from vscode e5834d3280fcd04898efeac32b9cf1b893f9b127 (#9385)

* Merge from vscode e5834d3280fcd04898efeac32b9cf1b893f9b127

* distro
This commit is contained in:
Anthony Dresser
2020-02-28 00:37:06 -08:00
committed by GitHub
parent 70851716f7
commit 5d13ebf0d2
143 changed files with 1711 additions and 934 deletions

View File

@@ -88,18 +88,18 @@ const getActivityTitle = (label: string, userDataSyncService: IUserDataSyncServi
}
return label;
};
const getIdentityTitle = (label: string, account?: AuthenticationSession): string => {
return account ? `${label} (${account.accountName})` : label;
const getIdentityTitle = (label: string, authenticationProviderId: string, account: AuthenticationSession | undefined, authenticationService: IAuthenticationService): string => {
return account ? `${label} (${authenticationService.getDisplayName(authenticationProviderId)}:${account.accountName})` : label;
};
const turnOnSyncCommand = { id: 'workbench.userData.actions.syncStart', title: localize('turn on sync with category', "Sync: Turn on Sync") };
const signInCommand = { id: 'workbench.userData.actions.signin', title: localize('sign in', "Sync: Sign in to sync") };
const stopSyncCommand = { id: 'workbench.userData.actions.stopSync', title(account?: AuthenticationSession) { return getIdentityTitle(localize('stop sync', "Sync: Turn off Sync"), account); } };
const stopSyncCommand = { id: 'workbench.userData.actions.stopSync', title(authenticationProviderId: string, account: AuthenticationSession | undefined, authenticationService: IAuthenticationService) { return getIdentityTitle(localize('stop sync', "Sync: Turn off Sync"), authenticationProviderId, account, authenticationService); } };
const resolveSettingsConflictsCommand = { id: 'workbench.userData.actions.resolveSettingsConflicts', title: localize('showConflicts', "Sync: Show Settings Conflicts") };
const resolveKeybindingsConflictsCommand = { id: 'workbench.userData.actions.resolveKeybindingsConflicts', title: localize('showKeybindingsConflicts', "Sync: Show Keybindings Conflicts") };
const configureSyncCommand = { id: 'workbench.userData.actions.configureSync', title: localize('configure sync', "Sync: Configure") };
const showSyncActivityCommand = {
id: 'workbench.userData.actions.showSyncActivity', title(userDataSyncService: IUserDataSyncService): string {
return getActivityTitle(localize('show sync log', "Sync: Show Activity"), userDataSyncService);
return getActivityTitle(localize('show sync log', "Sync: Show Log"), userDataSyncService);
}
};
const showSyncSettingsCommand = { id: 'workbench.userData.actions.syncSettings', title: localize('sync settings', "Sync: Settings"), };
@@ -163,7 +163,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
this.registerActions();
this.initializeActiveAccount().then(_ => {
if (!isWeb) {
this._register(instantiationService.createInstance(UserDataSyncTrigger).onDidTriggerSync(() => userDataAutoSyncService.triggerAutoSync()));
this._register(instantiationService.createInstance(UserDataSyncTrigger).onDidTriggerSync(source => userDataAutoSyncService.triggerAutoSync([source])));
}
});
@@ -226,7 +226,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
if (account) {
try {
const token = await account.accessToken();
const token = await account.getAccessToken();
this.authTokenService.setToken(token);
this.authenticationState.set(AuthStatus.SignedIn);
} catch (e) {
@@ -290,7 +290,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
const conflictsEditorInput = this.getConflictsEditorInput(conflictsSource);
if (!conflictsEditorInput && !this.conflictsDisposables.has(conflictsSource)) {
const conflictsArea = getSyncAreaLabel(conflictsSource);
const handle = this.notificationService.prompt(Severity.Warning, localize('conflicts detected', "Unable to sync due to conflicts in {0}. Please resolve them to continue.", conflictsArea),
const handle = this.notificationService.prompt(Severity.Warning, localize('conflicts detected', "Unable to sync due to conflicts in {0}. Please resolve them to continue.", conflictsArea.toLowerCase()),
[
{
label: localize('accept remote', "Accept Remote"),
@@ -409,9 +409,9 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
const sourceArea = getSyncAreaLabel(error.source);
this.notificationService.notify({
severity: Severity.Error,
message: localize('too large', "Disabled syncing {0} because size of the {1} file to sync is larger than {2}. Please open the file and reduce the size and enable sync", sourceArea, sourceArea, '100kb'),
message: localize('too large', "Disabled syncing {0} because size of the {1} file to sync is larger than {2}. Please open the file and reduce the size and enable sync", sourceArea.toLowerCase(), sourceArea.toLowerCase(), '100kb'),
actions: {
primary: [new Action('open sync file', localize('open file', "Open {0} file", sourceArea), undefined, true,
primary: [new Action('open sync file', localize('open file', "Open {0} File", sourceArea), undefined, true,
() => error.source === SyncSource.Settings ? this.preferencesService.openGlobalSettings(true) : this.preferencesService.openGlobalKeybindingSettings(true))]
}
});
@@ -450,22 +450,31 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
private handleInvalidContentError(source: SyncSource): void {
if (!this.invalidContentErrorDisposables.has(source)) {
const errorArea = getSyncAreaLabel(source);
const handle = this.notificationService.notify({
severity: Severity.Error,
message: localize('errorInvalidConfiguration', "Unable to sync {0} because there are some errors/warnings in the file. Please open the file to correct errors/warnings in it.", errorArea),
actions: {
primary: [new Action('open sync file', localize('open file', "Open {0} file", errorArea), undefined, true,
() => source === SyncSource.Settings ? this.preferencesService.openGlobalSettings(true) : this.preferencesService.openGlobalKeybindingSettings(true))]
}
});
this.invalidContentErrorDisposables.set(source, toDisposable(() => {
// close the error warning notification
handle.close();
this.invalidContentErrorDisposables.delete(source);
}));
if (this.invalidContentErrorDisposables.has(source)) {
return;
}
if (source !== SyncSource.Settings && source !== SyncSource.Keybindings) {
return;
}
const resource = source === SyncSource.Settings ? this.workbenchEnvironmentService.settingsResource : this.workbenchEnvironmentService.keybindingsResource;
if (isEqual(resource, this.editorService.activeEditor?.resource)) {
// Do not show notification if the file in error is active
return;
}
const errorArea = getSyncAreaLabel(source);
const handle = this.notificationService.notify({
severity: Severity.Error,
message: localize('errorInvalidConfiguration', "Unable to sync {0} because there are some errors/warnings in the file. Please open the file to correct errors/warnings in it.", errorArea.toLowerCase()),
actions: {
primary: [new Action('open sync file', localize('open file', "Open {0} File", errorArea), undefined, true,
() => source === SyncSource.Settings ? this.preferencesService.openGlobalSettings(true) : this.preferencesService.openGlobalKeybindingSettings(true))]
}
});
this.invalidContentErrorDisposables.set(source, toDisposable(() => {
// close the error warning notification
handle.close();
this.invalidContentErrorDisposables.delete(source);
}));
}
private async updateBadge(): Promise<void> {
@@ -493,7 +502,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
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('confirm', "Continue"),
localize('turn on sync', "Turn on Sync"),
localize('cancel', "Cancel"),
],
{
@@ -509,11 +518,11 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
const disposables: DisposableStore = new DisposableStore();
const quickPick = this.quickInputService.createQuickPick<ConfigureSyncQuickPickItem>();
disposables.add(quickPick);
quickPick.title = localize('turn on sync', "Turn on Sync");
quickPick.title = localize('turn on title', "Sync: Turn On");
quickPick.ok = false;
quickPick.customButton = true;
if (this.authenticationState.get() === AuthStatus.SignedIn) {
quickPick.customLabel = localize('turn on', "Turn on");
quickPick.customLabel = localize('turn on', "Turn On");
} else {
const displayName = this.authenticationService.getDisplayName(this.userDataSyncStore!.authenticationProviderId);
quickPick.description = localize('sign in and turn on sync detail', "Sign in with your {0} account to synchronize your data across devices.", displayName);
@@ -538,6 +547,39 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
private async doTurnOn(): Promise<void> {
if (this.authenticationState.get() === AuthStatus.SignedIn) {
await new Promise((c, e) => {
const disposables: DisposableStore = new DisposableStore();
const displayName = this.authenticationService.getDisplayName(this.userDataSyncStore!.authenticationProviderId);
const quickPick = this.quickInputService.createQuickPick<{ id: string, label: string, description?: string, detail?: string }>();
disposables.add(quickPick);
const chooseAnotherItemId = 'chooseAnother';
quickPick.title = localize('pick account', "{0}: Pick an account", displayName);
quickPick.ok = false;
quickPick.placeholder = localize('choose account placeholder', "Pick an account for syncing");
quickPick.ignoreFocusOut = true;
quickPick.items = [{
id: 'existing',
label: localize('existing', "{0}", this.activeAccount!.accountName),
detail: localize('signed in', "Signed in"),
}, {
id: chooseAnotherItemId,
label: localize('choose another', "Use another account")
}];
disposables.add(quickPick.onDidAccept(async () => {
if (quickPick.selectedItems.length) {
if (quickPick.selectedItems[0].id === chooseAnotherItemId) {
await this.authenticationService.logout(this.userDataSyncStore!.authenticationProviderId, this.activeAccount!.id);
await this.setActiveAccount(undefined);
}
quickPick.hide();
c();
}
}));
disposables.add(quickPick.onDidHide(() => disposables.dispose()));
quickPick.show();
});
}
if (this.authenticationState.get() === AuthStatus.SignedOut) {
await this.signIn();
}
@@ -608,7 +650,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
const result = await this.dialogService.show(
Severity.Info,
localize('firs time sync', "First time Sync"),
localize('firs time sync', "Sync"),
[
localize('merge', "Merge"),
localize('cancel', "Cancel"),
@@ -616,7 +658,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
],
{
cancelId: 1,
detail: localize('first time sync detail', "Synchronizing from this device for the first time.\nWould you like to merge or replace with the data from the cloud?"),
detail: localize('first time sync detail', "It looks like this is the first time sync is set up.\nWould you like to merge or replace with the data from the cloud?"),
}
);
switch (result.choice) {
@@ -638,7 +680,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
type: 'info',
message: localize('turn off sync confirmation', "Turn off Sync"),
detail: localize('turn off sync detail', "Your settings, keybindings, extensions and UI State will no longer be synced."),
primaryButton: localize('turn off', "Turn off"),
primaryButton: localize('turn off', "Turn Off"),
checkbox: {
label: localize('turn off sync everywhere', "Turn off sync on all your devices and clear the data from the cloud.")
}
@@ -874,7 +916,9 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
return new Promise((c, e) => {
const quickInputService = accessor.get(IQuickInputService);
const commandService = accessor.get(ICommandService);
const disposables = new DisposableStore();
const quickPick = quickInputService.createQuickPick();
disposables.add(quickPick);
const items: Array<IQuickPickItem | IQuickPickSeparator> = [];
if (that.userDataSyncService.conflictsSources.length) {
for (const source of that.userDataSyncService.conflictsSources) {
@@ -893,9 +937,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
items.push({ id: showSyncSettingsCommand.id, label: showSyncSettingsCommand.title });
items.push({ id: showSyncActivityCommand.id, label: showSyncActivityCommand.title(that.userDataSyncService) });
items.push({ type: 'separator' });
items.push({ id: stopSyncCommand.id, label: stopSyncCommand.title(that.activeAccount), });
items.push({ id: stopSyncCommand.id, label: stopSyncCommand.title(that.userDataSyncStore!.authenticationProviderId, that.activeAccount, that.authenticationService) });
quickPick.items = items;
const disposables = new DisposableStore();
disposables.add(quickPick.onDidAccept(() => {
if (quickPick.selectedItems[0] && quickPick.selectedItems[0].id) {
commandService.executeCommand(quickPick.selectedItems[0].id);
@@ -918,7 +961,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
constructor() {
super({
id: stopSyncCommand.id,
title: stopSyncCommand.title(that.activeAccount),
title: stopSyncCommand.title(that.userDataSyncStore!.authenticationProviderId, that.activeAccount, that.authenticationService),
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized), CONTEXT_SYNC_ENABLEMENT),
@@ -1091,8 +1134,8 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
? localize('Sync accept remote', "Sync: {0}", acceptRemoteLabel)
: localize('Sync accept local', "Sync: {0}", acceptLocalLabel),
message: isRemote
? localize('confirm replace and overwrite local', "Would you like to accept Remote {0} and replace Local {1}?", syncAreaLabel, syncAreaLabel)
: localize('confirm replace and overwrite remote', "Would you like to accept Local {0} and replace Remote {1}?", syncAreaLabel, syncAreaLabel),
? 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
});
if (result.confirmed) {