@@ -47,7 +47,7 @@ import { INotificationService } from '../../../../../platform/notification/commo
4747import { getErrorMessage } from '../../../../../base/common/errors.js' ;
4848import { getPluginInclusionLabel } from './aiCustomizationPresentation.js' ;
4949import { status } from '../../../../../base/browser/ui/aria/aria.js' ;
50- import { createCustomizationCardPrimaryAction , CustomizationCardListController , layoutVirtualizedSectionList , layoutVirtualizedSections , renderVirtualizedSectionLoadingPlaceholder , setVirtualizedRowActionsTabbable , setupCollapsibleSection } from './customizationCardList.js' ;
50+ import { createCustomizationCardPrimaryAction , CustomizationCardListController , getVirtualizedSectionMinimumHeight , layoutVirtualizedSectionList , layoutVirtualizedSections , renderVirtualizedSectionLoadingPlaceholder , setVirtualizedRowActionsTabbable , setupCollapsibleSection } from './customizationCardList.js' ;
5151import { DomScrollableElement } from '../../../../../base/browser/ui/scrollbar/scrollableElement.js' ;
5252import { ScrollbarVisibility } from '../../../../../base/common/scrollable.js' ;
5353
@@ -1464,28 +1464,26 @@ export class PluginListWidget extends Disposable {
14641464
14651465 private renderInstalledListActions ( item : IInstalledPluginItem , row : HTMLElement , actions : HTMLElement , disposables : DisposableStore ) : void {
14661466 let renderedState = item . plugin . enablement . get ( ) ;
1467- const switchElement = DOM . append ( actions , $ ( 'button.plugin-enable-switch' ) ) as HTMLButtonElement ;
1468- switchElement . type = 'button' ;
1469- switchElement . setAttribute ( 'role' , 'switch' ) ;
1470- DOM . append ( switchElement , $ ( '.plugin-enable-switch-thumb' ) ) ;
1471- disposables . add ( DOM . addDisposableGenericMouseDownListener ( switchElement , event => DOM . EventHelper . stop ( event , true ) ) ) ;
1467+ const toggle = disposables . add ( new Switch ( { ariaLabel : item . name , checked : isContributionEnabled ( renderedState ) } ) ) ;
1468+ DOM . append ( actions , toggle . domNode ) ;
1469+ disposables . add ( DOM . addDisposableGenericMouseDownListener ( toggle . domNode , event => DOM . EventHelper . stop ( event , true ) ) ) ;
14721470 const update = ( state : ContributionEnablementState , blocked : boolean ) => {
14731471 renderedState = state ;
14741472 const checked = isContributionEnabled ( state ) ;
14751473 const workspaceScope = state === ContributionEnablementState . EnabledWorkspace || state === ContributionEnablementState . DisabledWorkspace ;
14761474 const toggleLabel = checked
14771475 ? ( workspaceScope ? localize ( 'excludePluginWorkspaceAria' , "Exclude {0} from Workspace" , item . name ) : localize ( 'excludePluginProfileAria' , "Exclude {0} from Profile" , item . name ) )
14781476 : ( workspaceScope ? localize ( 'includePluginWorkspaceAria' , "Include {0} in Workspace" , item . name ) : localize ( 'includePluginProfileAria' , "Include {0} for Profile" , item . name ) ) ;
1479- switchElement . disabled = blocked ;
1480- switchElement . setAttribute ( 'aria-checked' , String ( checked ) ) ;
1481- switchElement . setAttribute ( 'aria-label' , blocked ? localize ( 'pluginManagedByOrganizationAria' , "{0} is managed by your organization" , item . name ) : toggleLabel ) ;
1482- switchElement . classList . toggle ( 'checked' , checked ) ;
1483- switchElement . title = blocked ? localize ( 'pluginPolicyBlockedSwitch' , "This plugin is managed by your organization." ) : toggleLabel ;
1477+ toggle . disabled = blocked ;
1478+ toggle . checked = checked ;
1479+ toggle . setAriaLabel (
1480+ blocked ? localize ( 'pluginManagedByOrganizationAria' , "{0} is managed by your organization" , item . name ) : toggleLabel ,
1481+ blocked ? localize ( 'pluginPolicyBlockedSwitch' , "This plugin is managed by your organization." ) : toggleLabel ,
1482+ ) ;
14841483 row . classList . toggle ( 'disabled' , ! checked || blocked ) ;
14851484 } ;
14861485 disposables . add ( autorun ( reader => update ( item . plugin . enablement . read ( reader ) , item . plugin . policyBlocked ?. read ( reader ) === true ) ) ) ;
1487- disposables . add ( DOM . addDisposableListener ( switchElement , 'click' , event => {
1488- DOM . EventHelper . stop ( event , true ) ;
1486+ disposables . add ( toggle . onChange ( ( ) => {
14891487 const nextState = getToggledPluginEnablementState ( renderedState ) ;
14901488 update ( nextState , isPluginPolicyBlocked ( item . plugin ) ) ;
14911489 this . agentPluginService . enablementModel . setEnabled ( item . plugin . uri . toString ( ) , nextState ) ;
@@ -1537,7 +1535,7 @@ export class PluginListWidget extends Disposable {
15371535 const heights = layoutVirtualizedSections ( content , this . sectionLists . map ( section => ( {
15381536 container : section . container ,
15391537 contentHeight : section . entries . reduce ( ( height , entry ) => height + delegate . getHeight ( entry ) , 0 ) ,
1540- minimumHeight : section . entries . length > 0 ? delegate . getHeight ( section . entries [ 0 ] ) : 0 ,
1538+ minimumHeight : getVirtualizedSectionMinimumHeight ( section . entries , entry => delegate . getHeight ( entry ) ) ,
15411539 } ) ) ) ;
15421540 for ( let index = 0 ; index < this . sectionLists . length ; index ++ ) {
15431541 const section = this . sectionLists [ index ] ;
0 commit comments