Skip to content

Commit

Permalink
testing: avoid profiles dropdown when there's a single profile (#236509)
Browse files Browse the repository at this point in the history
Fixes #232767
  • Loading branch information
connor4312 authored Dec 18, 2024
1 parent 91581ca commit 7f9c7a4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/vs/workbench/contrib/testing/browser/testingExplorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand 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,
Expand Down Expand Up @@ -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'),
Expand All @@ -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),
};
}

/**
Expand All @@ -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);
}

Expand All @@ -452,7 +457,7 @@ export class TestingExplorerView extends ViewPane {

return this.instantiationService.createInstance(
DropdownWithPrimaryActionViewItem,
primaryAction, this.getDropdownAction(), dropdownActions,
primaryAction, this.getDropdownAction(), dropdownActions.actions,
'',
options
);
Expand Down

0 comments on commit 7f9c7a4

Please sign in to comment.