From 7f9c7a41873b88861744d06aed33d2dbcaa3a92e Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Wed, 18 Dec 2024 11:03:57 -0800 Subject: [PATCH] testing: avoid profiles dropdown when there's a single profile (#236509) Fixes #232767 --- .../testing/browser/testingExplorerView.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts b/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts index 5e84db11b6af9..dea0b909d049e 100644 --- a/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts +++ b/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts @@ -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 );