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 2 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 TestPythonConfigMenu = new MenuId('TestPythonConfigMenu');
static readonly TestMessageContext = new MenuId('TestMessageContext');
static readonly TestMessageContent = new MenuId('TestMessageContent');
static readonly TestPeekElement = new MenuId('TestPeekElement');
Expand Down
24 changes: 19 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,9 +352,19 @@ 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 key = this.contextKeyService.createOverlay([]);
Copy link
Member

Choose a reason for hiding this comment

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

One key we probably should have in the overlap is the current group (run/debug/coverage) for extensions who want different behavior

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi, sorry could you clarify a bit what you mean here? There should be a context key for the current group and have it only show for some or make that configurable for the extension author?

Copy link
Member

Choose a reason for hiding this comment

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

The menu logic can run for all of them, but an author might want to only have a menu visible in one group, or have different menu entries for each group. So letting them do something like profileKind == "run" would be good.

const menu = this.menuService.createMenu(MenuId.TestPythonConfigMenu, key);
const actions = menu.getActions({ renderShortTitle: true }).flatMap(entry => entry[1]);
if (actions.length > 0) {
// fill if there are any actions
eleanorjboyd marked this conversation as resolved.
Show resolved Hide resolved
try {
createAndFillInContextMenuActions(menu, undefined, menuActions);
} finally {
menu.dispose();
}

}

const postActions: IAction[] = [];
Expand All @@ -377,7 +388,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/pythonConfig',
eleanorjboyd marked this conversation as resolved.
Show resolved Hide resolved
id: MenuId.TestPythonConfigMenu,
description: localize('testing.pythonConfig.title', "The menu for configuring Python tests"),
},
{
key: 'testing/item/result',
id: MenuId.TestPeekElement,
Expand Down
Loading