Skip to content

Commit 86abd4e

Browse files
committed
Show account identity instead of activity
1 parent a1f61fd commit 86abd4e

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ const getActivityTitle = (label: string, userDataSyncService: IUserDataSyncServi
8686
}
8787
return label;
8888
};
89+
const getIdentityTitle = (label: string, account?: AuthenticationSession): string => {
90+
return account ? `${label} (${account.accountName})` : label;
91+
};
8992
const turnOnSyncCommand = { id: 'workbench.userData.actions.syncStart', title: localize('turn on sync with category', "Sync: Turn on Sync") };
9093
const signInCommand = { id: 'workbench.userData.actions.signin', title: localize('sign in', "Sync: Sign in to sync") };
91-
const stopSyncCommand = { id: 'workbench.userData.actions.stopSync', title: localize('stop sync', "Sync: Turn off Sync") };
94+
const stopSyncCommand = { id: 'workbench.userData.actions.stopSync', title(account?: AuthenticationSession) { return getIdentityTitle(localize('stop sync', "Sync: Turn off Sync"), account); } };
9295
const resolveSettingsConflictsCommand = { id: 'workbench.userData.actions.resolveSettingsConflicts', title: localize('showConflicts', "Sync: Show Settings Conflicts") };
9396
const resolveKeybindingsConflictsCommand = { id: 'workbench.userData.actions.resolveKeybindingsConflicts', title: localize('showKeybindingsConflicts', "Sync: Show Keybindings Conflicts") };
9497
const configureSyncCommand = { id: 'workbench.userData.actions.configureSync', title: localize('configure sync', "Sync: Configure") };
@@ -111,8 +114,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
111114
private readonly signInNotificationDisposable = this._register(new MutableDisposable());
112115
private _activeAccount: AuthenticationSession | undefined;
113116

114-
private readonly syncStatusAction = this._register(new MutableDisposable());
115-
116117
constructor(
117118
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
118119
@IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService,
@@ -233,6 +234,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
233234
}
234235

235236
this.updateBadge();
237+
this.registerSyncStatusAction();
236238
}
237239

238240
private async onDidChangeSessions(providerId: string): Promise<void> {
@@ -778,24 +780,29 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
778780

779781
}
780782

783+
private readonly _syncStatusActionDisposable = this._register(new MutableDisposable());
781784
private registerSyncStatusAction(): void {
782785
const that = this;
783-
const id = 'workbench.userData.actions.syncStatus';
784-
const title = localize('sync is on', "Sync is on");
785786
const when = ContextKeyExpr.and(CONTEXT_SYNC_ENABLEMENT, CONTEXT_AUTH_TOKEN_STATE.isEqualTo(AuthStatus.SignedIn), CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized));
786-
this.syncStatusAction.value = registerAction2(class SyncStatusAction extends Action2 {
787+
this._syncStatusActionDisposable.value = registerAction2(class SyncStatusAction extends Action2 {
787788
constructor() {
788789
super({
789-
id,
790+
id: 'workbench.userData.actions.syncStatus',
790791
get title() {
791-
return getActivityTitle(localize('sync is on', "Sync is on"), that.userDataSyncService);
792+
return getIdentityTitle(localize('sync is on', "Sync is on"), that.activeAccount);
792793
},
793794
menu: [
794795
{
795796
id: MenuId.GlobalActivity,
796797
group: '5_sync',
797798
when,
798799
order: 3
800+
},
801+
{
802+
id: MenuId.MenubarPreferencesMenu,
803+
group: '5_sync',
804+
when,
805+
order: 3,
799806
}
800807
],
801808
});
@@ -823,7 +830,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
823830
items.push({ id: showSyncSettingsCommand.id, label: showSyncSettingsCommand.title });
824831
items.push({ id: showSyncActivityCommand.id, label: showSyncActivityCommand.title(that.userDataSyncService) });
825832
items.push({ type: 'separator' });
826-
items.push({ id: stopSyncCommand.id, label: stopSyncCommand.title });
833+
items.push({ id: stopSyncCommand.id, label: stopSyncCommand.title(that.activeAccount), });
827834
quickPick.items = items;
828835
const disposables = new DisposableStore();
829836
disposables.add(quickPick.onDidAccept(() => {
@@ -840,12 +847,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
840847
});
841848
}
842849
});
843-
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
844-
group: '5_sync',
845-
command: { id, title },
846-
when,
847-
order: 3
848-
});
849850
}
850851

851852
private registerTurnOffSyncAction(): void {
@@ -854,7 +855,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
854855
constructor() {
855856
super({
856857
id: stopSyncCommand.id,
857-
title: stopSyncCommand.title,
858+
title: stopSyncCommand.title(that.activeAccount),
858859
menu: {
859860
id: MenuId.CommandPalette,
860861
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized), CONTEXT_SYNC_ENABLEMENT),
@@ -896,7 +897,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
896897
constructor() {
897898
super({
898899
id: showSyncActivityCommand.id,
899-
title: showSyncActivityCommand.title(that.userDataSyncService),
900+
get title() { return showSyncActivityCommand.title(that.userDataSyncService); },
900901
menu: {
901902
id: MenuId.CommandPalette,
902903
when: ContextKeyExpr.and(CONTEXT_SYNC_STATE.notEqualsTo(SyncStatus.Uninitialized)),

0 commit comments

Comments
 (0)