testing: avoid profiles dropdown when there's a single profile (#236509)

Fixes #232767
pull/236513/head
Connor Peet 2024-12-18 11:03:57 -08:00 committed by GitHub
parent 91581cab6f
commit 7f9c7a4187
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 6 deletions

View File

@ -346,6 +346,7 @@ export class TestingExplorerView extends ViewPane {
const profileActions: IAction[] = [];
let participatingGroups = 0;
let participatingProfiles = 0;
let hasConfigurable = false;
const defaults = this.testProfileService.getGroupDefaultProfiles(group);
for (const { profiles, controller } of this.testProfileService.all()) {
@ -363,6 +364,7 @@ export class TestingExplorerView extends ViewPane {
}
hasConfigurable = hasConfigurable || profile.hasConfigurationHandler;
participatingProfiles++;
profileActions.push(new Action(
`${controller.id}.${profile.profileId}`,
defaults.includes(profile) ? localize('defaultTestProfile', '{0} (Default)', profile.label) : profile.label,
@ -402,7 +404,7 @@ export class TestingExplorerView extends ViewPane {
const menuActions = getFlatContextMenuActions(menu);
const postActions: IAction[] = [];
if (profileActions.length > 1) {
if (participatingProfiles > 1) {
postActions.push(new Action(
'selectDefaultTestConfigurations',
localize('selectDefaultConfigs', 'Select Default Profile'),
@ -423,9 +425,12 @@ export class TestingExplorerView extends ViewPane {
}
// show menu actions if there are any otherwise don't
return menuActions.length > 0
? Separator.join(profileActions, menuActions, postActions)
: Separator.join(profileActions, postActions);
return {
numberOfProfiles: participatingProfiles,
actions: menuActions.length > 0
? Separator.join(profileActions, menuActions, postActions)
: Separator.join(profileActions, postActions),
};
}
/**
@ -438,7 +443,7 @@ export class TestingExplorerView extends ViewPane {
private getRunGroupDropdown(group: TestRunProfileBitset, defaultAction: IAction, options: IActionViewItemOptions) {
const dropdownActions = this.getTestConfigGroupActions(group);
if (dropdownActions.length < 2) {
if (dropdownActions.numberOfProfiles < 2) {
return super.getActionViewItem(defaultAction, options);
}
@ -452,7 +457,7 @@ export class TestingExplorerView extends ViewPane {
return this.instantiationService.createInstance(
DropdownWithPrimaryActionViewItem,
primaryAction, this.getDropdownAction(), dropdownActions,
primaryAction, this.getDropdownAction(), dropdownActions.actions,
'',
options
);