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

add menu contribution for python manage config #216018

Merged
merged 7 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export class MenuId {
static readonly StickyScrollContext = new MenuId('StickyScrollContext');
static readonly TestItem = new MenuId('TestItem');
static readonly TestItemGutter = new MenuId('TestItemGutter');
static readonly TestProfilesContext = new MenuId('TestProfilesContext');
static readonly TestMessageContext = new MenuId('TestMessageContext');
static readonly TestMessageContent = new MenuId('TestMessageContent');
static readonly TestPeekElement = new MenuId('TestPeekElement');
Expand Down
33 changes: 28 additions & 5 deletions src/vs/workbench/contrib/testing/browser/testingExplorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import 'vs/css!./media/testing';
import { MarkdownRenderer } from 'vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
import { localize } from 'vs/nls';
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
import { MenuEntryActionViewItem, createActionViewItem, createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { MenuEntryActionViewItem, createActionViewItem, createAndFillInActionBarActions, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
Expand Down Expand Up @@ -117,6 +117,7 @@ export class TestingExplorerView extends ViewPane {
@IHoverService hoverService: IHoverService,
@ITestProfileService private readonly testProfileService: ITestProfileService,
@ICommandService private readonly commandService: ICommandService,
@IMenuService private readonly menuService: IMenuService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);

Expand Down Expand Up @@ -351,10 +352,29 @@ export class TestingExplorerView extends ViewPane {
}
}

// If there's only one group, don't add a heading for it in the dropdown.
if (participatingGroups === 1) {
profileActions.shift();
const menuActions: IAction[] = [];
const contextKeys: [string, unknown][] = [];
// allow extension author to define context for when to show the test menu actions for run or debug menus
if (group === TestRunProfileBitset.Run) {
contextKeys.push(['testing.profile.context.group', 'run']);
}
if (group === TestRunProfileBitset.Debug) {
contextKeys.push(['testing.profile.context.group', 'debug']);
}
if (group === TestRunProfileBitset.Coverage) {
contextKeys.push(['testing.profile.context.group', 'coverage']);
}
Comment on lines +358 to 366
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you register the key in testingContextKeys.ts? That way it'll be automatically picked up for our docs :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

const key = this.contextKeyService.createOverlay(contextKeys);
const menu = this.menuService.createMenu(MenuId.TestProfilesContext, key);

// fill if there are any actions
try {
createAndFillInContextMenuActions(menu, undefined, menuActions);
} finally {
menu.dispose();
}



const postActions: IAction[] = [];
if (profileActions.length > 1) {
Expand All @@ -377,7 +397,10 @@ export class TestingExplorerView extends ViewPane {
));
}

return Separator.join(profileActions, postActions);
// show menu actions if there are any otherwise don't
return menuActions.length > 0
? Separator.join(profileActions, menuActions, postActions)
: Separator.join(profileActions, postActions);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ const apiMenus: IAPIMenu[] = [
id: MenuId.TestItemGutter,
description: localize('testing.item.gutter.title', "The menu for a gutter decoration for a test item"),
},
{
key: 'testing/profiles/context',
id: MenuId.TestProfilesContext,
description: localize('testing.profiles.context.title', "The menu for configuring testing profiles."),
},
{
key: 'testing/item/result',
id: MenuId.TestPeekElement,
Expand Down
Loading