Skip to content

Commit a84d194

Browse files
committed
show accounts picker for sign in action
1 parent 1c3c071 commit a84d194

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,12 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
425425
quickPick.title = localize('Preferences Sync Title', "Preferences Sync");
426426
quickPick.ok = false;
427427
quickPick.customButton = true;
428-
const requiresLogin = this.userDataSyncAccounts.all.length === 0;
429-
if (requiresLogin) {
428+
if (this.userDataSyncAccounts.all.length) {
429+
quickPick.customLabel = localize('turn on', "Turn On");
430+
} else {
430431
const displayName = this.authenticationService.getDisplayName(this.userDataSyncAccounts.accountProviderId!);
431432
quickPick.description = localize('sign in and turn on sync detail', "Sign in with your {0} account to synchronize your data across devices.", displayName);
432433
quickPick.customLabel = localize('sign in and turn on sync', "Sign in & Turn on");
433-
} else {
434-
quickPick.customLabel = localize('turn on', "Turn On");
435434
}
436435
quickPick.placeholder = localize('configure sync placeholder', "Choose what to sync");
437436
quickPick.canSelectMany = true;
@@ -442,7 +441,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
442441
disposables.add(Event.any(quickPick.onDidAccept, quickPick.onDidCustom)(async () => {
443442
if (quickPick.selectedItems.length) {
444443
this.updateConfiguration(items, quickPick.selectedItems);
445-
this.doTurnOn(requiresLogin).then(c, e);
444+
this.doTurnOn().then(c, e);
446445
quickPick.hide();
447446
}
448447
}));
@@ -451,12 +450,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
451450
});
452451
}
453452

454-
private async doTurnOn(requiresLogin: boolean): Promise<void> {
455-
if (requiresLogin) {
456-
await this.userDataSyncAccounts.login();
457-
} else {
458-
await this.userDataSyncAccounts.select();
459-
}
453+
private async doTurnOn(): Promise<void> {
454+
await this.login();
460455

461456
// User did not pick an account or login failed
462457
if (this.userDataSyncAccounts.status !== AccountStatus.Available) {
@@ -469,6 +464,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
469464
this.storageService.store('sync.donotAskPreviewConfirmation', true, StorageScope.GLOBAL);
470465
}
471466

467+
private async login(): Promise<void> {
468+
if (this.userDataSyncAccounts.all.length) {
469+
await this.userDataSyncAccounts.select();
470+
} else {
471+
await this.userDataSyncAccounts.login();
472+
}
473+
}
474+
472475
private getConfigureSyncQuickPickItems(): ConfigureSyncQuickPickItem[] {
473476
return [{
474477
id: SyncResource.Settings,
@@ -727,7 +730,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
727730
}
728731
async run(): Promise<any> {
729732
try {
730-
await that.userDataSyncAccounts.login();
733+
await that.login();
731734
} catch (e) {
732735
that.notificationService.error(e);
733736
}

0 commit comments

Comments
 (0)