-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change agent/model pickers to proper dropdowns (#240014)
* Use DropdownMenuActionViewItem for toggle agent action * Fix model picker * Reorder * Fix * Add aria attributes
- Loading branch information
1 parent
f44ea9d
commit 1816f95
Showing
5 changed files
with
140 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/vs/platform/actions/browser/dropdownActionViewItemWithKeybinding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { IContextMenuProvider } from '../../../base/browser/contextmenu.js'; | ||
import { IActionProvider } from '../../../base/browser/ui/dropdown/dropdown.js'; | ||
import { DropdownMenuActionViewItem, IDropdownMenuActionViewItemOptions } from '../../../base/browser/ui/dropdown/dropdownActionViewItem.js'; | ||
import { IAction } from '../../../base/common/actions.js'; | ||
import * as nls from '../../../nls.js'; | ||
import { IContextKeyService } from '../../contextkey/common/contextkey.js'; | ||
import { IKeybindingService } from '../../keybinding/common/keybinding.js'; | ||
|
||
export class DropdownMenuActionViewItemWithKeybinding extends DropdownMenuActionViewItem { | ||
constructor( | ||
action: IAction, | ||
menuActionsOrProvider: readonly IAction[] | IActionProvider, | ||
contextMenuProvider: IContextMenuProvider, | ||
options: IDropdownMenuActionViewItemOptions = Object.create(null), | ||
@IKeybindingService private readonly keybindingService: IKeybindingService, | ||
@IContextKeyService private readonly contextKeyService: IContextKeyService, | ||
) { | ||
super(action, menuActionsOrProvider, contextMenuProvider, options); | ||
} | ||
|
||
protected override getTooltip() { | ||
const keybinding = this.keybindingService.lookupKeybinding(this.action.id, this.contextKeyService); | ||
const keybindingLabel = keybinding && keybinding.getLabel(); | ||
|
||
const tooltip = this.action.tooltip ?? this.action.label; | ||
return keybindingLabel | ||
? nls.localize('titleAndKb', "{0} ({1})", tooltip, keybindingLabel) | ||
: tooltip; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.