Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring back profile switch menu - fix #227872 #230123

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { IURLService } from '../../../../platform/url/common/url.js';
import { IBrowserWorkbenchEnvironmentService } from '../../../services/environment/browser/environmentService.js';

export const OpenProfileMenu = new MenuId('OpenProfile');
const ProfilesMenu = new MenuId('Profiles');

export class UserDataProfilesWorkbenchContribution extends Disposable implements IWorkbenchContribution {

Expand Down Expand Up @@ -121,6 +122,7 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
}

private registerActions(): void {
this.registerProfileSubMenu();
this._register(this.registerManageProfilesAction());
this._register(this.registerSwitchProfileAction());

Expand All @@ -138,6 +140,30 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
this.registerHelpAction();
}

private registerProfileSubMenu(): void {
const getProfilesTitle = () => {
return localize('profiles', "Profile ({0})", this.userDataProfileService.currentProfile.name);
};
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
get title() {
return getProfilesTitle();
},
submenu: ProfilesMenu,
group: '2_configuration',
order: 1,
when: HAS_PROFILES_CONTEXT
});
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
get title() {
return getProfilesTitle();
},
submenu: ProfilesMenu,
group: '2_configuration',
order: 1,
when: HAS_PROFILES_CONTEXT
});
}

private registerOpenProfileSubMenu(): void {
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
title: localize('New Profile Window', "New Window with Profile"),
Expand All @@ -152,11 +178,37 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
this.profilesDisposable.value = new DisposableStore();
for (const profile of this.userDataProfilesService.profiles) {
if (!profile.isTransient) {
this.profilesDisposable.value.add(this.registerProfileEntryAction(profile));
this.profilesDisposable.value.add(this.registerNewWindowAction(profile));
}
}
}

private registerProfileEntryAction(profile: IUserDataProfile): IDisposable {
const that = this;
return registerAction2(class ProfileEntryAction extends Action2 {
constructor() {
super({
id: `workbench.profiles.actions.profileEntry.${profile.id}`,
title: profile.name,
toggled: ContextKeyExpr.equals(CURRENT_PROFILE_CONTEXT.key, profile.id),
menu: [
{
id: ProfilesMenu,
group: '0_profiles',
when: PROFILES_ENABLEMENT_CONTEXT,
}
]
});
}
async run(accessor: ServicesAccessor) {
if (that.userDataProfileService.currentProfile.id !== profile.id) {
return that.userDataProfileManagementService.switchProfile(profile);
}
}
});
}

private registerNewWindowWithProfileAction(): IDisposable {
return registerAction2(class NewWindowWithProfileAction extends Action2 {
constructor() {
Expand Down Expand Up @@ -276,11 +328,18 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
id: MenuId.GlobalActivity,
group: '2_configuration',
order: 1,
when: HAS_PROFILES_CONTEXT.negate()
},
{
id: MenuId.MenubarPreferencesMenu,
group: '2_configuration',
order: 1,
when: HAS_PROFILES_CONTEXT.negate()
},
{
id: ProfilesMenu,
group: '1_manage',
order: 1,
},
]
});
Expand Down
Loading