@@ -24,7 +24,7 @@ import { MenuItemAction, IMenuService, registerAction2, MenuId, IAction2Options,
2424import { IAction , ActionRunner , Action , Separator , IActionRunner } from 'vs/base/common/actions' ;
2525import { ActionBar , IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar' ;
2626import { IThemeService , IFileIconTheme } from 'vs/platform/theme/common/themeService' ;
27- import { isSCMResource , isSCMResourceGroup , connectPrimaryMenuToInlineActionBar , isSCMRepository , isSCMInput , collectContextMenuActions , getActionViewItemProvider , isSCMActionButton , isSCMViewService , isSCMHistoryItemGroupTreeElement , isSCMHistoryItemTreeElement , isSCMHistoryItemChangeTreeElement , toDiffEditorArguments , isSCMResourceNode , isSCMHistoryItemChangeNode , isSCMViewSeparator } from './util' ;
27+ import { isSCMResource , isSCMResourceGroup , connectPrimaryMenuToInlineActionBar , isSCMRepository , isSCMInput , collectContextMenuActions , getActionViewItemProvider , isSCMActionButton , isSCMViewService , isSCMHistoryItemGroupTreeElement , isSCMHistoryItemTreeElement , isSCMHistoryItemChangeTreeElement , toDiffEditorArguments , isSCMResourceNode , isSCMHistoryItemChangeNode , isSCMViewSeparator , connectPrimaryMenu } from './util' ;
2828import { WorkbenchCompressibleAsyncDataTree , IOpenEvent } from 'vs/platform/list/browser/listService' ;
2929import { IConfigurationService , ConfigurationTarget } from 'vs/platform/configuration/common/configuration' ;
3030import { disposableTimeout , Sequencer , ThrottledDelayer , Throttler } from 'vs/base/common/async' ;
@@ -761,18 +761,42 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
761761 }
762762}
763763
764+
765+ class HistoryItemGroupActionRunner extends ActionRunner {
766+
767+ protected override runAction ( action : IAction , context : SCMHistoryItemGroupTreeElement ) : Promise < void > {
768+ if ( ! ( action instanceof MenuItemAction ) ) {
769+ return super . runAction ( action , context ) ;
770+ }
771+
772+ return action . run ( context . repository . provider , context . id ) ;
773+ }
774+ }
775+
764776interface HistoryItemGroupTemplate {
765777 readonly iconContainer : HTMLElement ;
766778 readonly label : IconLabel ;
779+ readonly toolBar : WorkbenchToolBar ;
767780 readonly count : CountBadge ;
768- readonly disposables : IDisposable ;
781+ readonly elementDisposables : DisposableStore ;
782+ readonly templateDisposables : DisposableStore ;
769783}
770784
771785class HistoryItemGroupRenderer implements ICompressibleTreeRenderer < SCMHistoryItemGroupTreeElement , void , HistoryItemGroupTemplate > {
772786
773787 static readonly TEMPLATE_ID = 'history-item-group' ;
774788 get templateId ( ) : string { return HistoryItemGroupRenderer . TEMPLATE_ID ; }
775789
790+ constructor (
791+ readonly actionRunner : ActionRunner ,
792+ @IContextKeyService readonly contextKeyService : IContextKeyService ,
793+ @IContextMenuService readonly contextMenuService : IContextMenuService ,
794+ @IKeybindingService readonly keybindingService : IKeybindingService ,
795+ @IMenuService readonly menuService : IMenuService ,
796+ @ISCMViewService private readonly scmViewService : ISCMViewService ,
797+ @ITelemetryService readonly telemetryService : ITelemetryService
798+ ) { }
799+
776800 renderTemplate ( container : HTMLElement ) {
777801 // hack
778802 ( container . parentElement ! . parentElement ! . querySelector ( '.monaco-tl-twistie' ) ! as HTMLElement ) . classList . add ( 'force-twistie' ) ;
@@ -782,10 +806,14 @@ class HistoryItemGroupRenderer implements ICompressibleTreeRenderer<SCMHistoryIt
782806 const label = new IconLabel ( element , { supportIcons : true } ) ;
783807 const iconContainer = prepend ( label . element , $ ( '.icon-container' ) ) ;
784808
809+ const templateDisposables = new DisposableStore ( ) ;
810+ const toolBar = new WorkbenchToolBar ( append ( element , $ ( '.actions' ) ) , { actionRunner : this . actionRunner , menuOptions : { shouldForwardArgs : true } } , this . menuService , this . contextKeyService , this . contextMenuService , this . keybindingService , this . telemetryService ) ;
811+ templateDisposables . add ( toolBar ) ;
812+
785813 const countContainer = append ( element , $ ( '.count' ) ) ;
786814 const count = new CountBadge ( countContainer , { } , defaultCountBadgeStyles ) ;
787815
788- return { iconContainer, label, count, disposables : new DisposableStore ( ) } ;
816+ return { iconContainer, label, toolBar , count, elementDisposables : new DisposableStore ( ) , templateDisposables } ;
789817 }
790818
791819 renderElement ( node : ITreeNode < SCMHistoryItemGroupTreeElement > , index : number , templateData : HistoryItemGroupTemplate , height : number | undefined ) : void {
@@ -798,13 +826,36 @@ class HistoryItemGroupRenderer implements ICompressibleTreeRenderer<SCMHistoryIt
798826
799827 templateData . label . setLabel ( historyItemGroup . label , historyItemGroup . description , { title : historyItemGroup . ariaLabel } ) ;
800828 templateData . count . setCount ( historyItemGroup . count ?? 0 ) ;
829+
830+ const repositoryMenus = this . scmViewService . menus . getRepositoryMenus ( historyItemGroup . repository . provider ) ;
831+ const historyProviderMenu = repositoryMenus . historyProviderMenu ;
832+
833+ if ( historyProviderMenu ) {
834+ const menuId = historyItemGroup . direction === 'incoming' ? MenuId . SCMIncomingChanges : MenuId . SCMOutgoingChanges ;
835+ const menu = historyItemGroup . direction === 'incoming' ? historyProviderMenu . incomingHistoryItemGroupMenu : historyProviderMenu . outgoingHistoryItemGroupMenu ;
836+
837+ templateData . elementDisposables . add ( connectPrimaryMenu ( menu , ( primary , secondary ) => {
838+ templateData . toolBar . setActions ( primary , secondary , [ menuId ] ) ;
839+ } ) ) ;
840+
841+ templateData . toolBar . context = historyItemGroup ;
842+ } else {
843+ templateData . toolBar . setActions ( [ ] , [ ] ) ;
844+ templateData . toolBar . context = undefined ;
845+ }
801846 }
802847
803848 renderCompressedElements ( node : ITreeNode < ICompressedTreeNode < SCMHistoryItemGroupTreeElement > , void > , index : number , templateData : HistoryItemGroupTemplate , height : number | undefined ) : void {
804849 throw new Error ( 'Should never happen since node is incompressible' ) ;
805850 }
851+
852+ disposeElement ( node : ITreeNode < SCMHistoryItemGroupTreeElement > , index : number , templateData : HistoryItemGroupTemplate , height : number | undefined ) : void {
853+ templateData . elementDisposables . clear ( ) ;
854+ }
855+
806856 disposeTemplate ( templateData : HistoryItemGroupTemplate ) : void {
807- templateData . disposables . dispose ( ) ;
857+ templateData . elementDisposables . dispose ( ) ;
858+ templateData . templateDisposables . dispose ( ) ;
808859 }
809860}
810861
@@ -2709,6 +2760,10 @@ export class SCMViewPane extends ViewPane {
27092760 resourceActionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
27102761 this . disposables . add ( resourceActionRunner ) ;
27112762
2763+ const historyItemGroupActionRunner = new HistoryItemGroupActionRunner ( ) ;
2764+ historyItemGroupActionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
2765+ this . disposables . add ( historyItemGroupActionRunner ) ;
2766+
27122767 const historyItemActionRunner = new HistoryItemActionRunner ( ) ;
27132768 historyItemActionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
27142769 this . disposables . add ( historyItemActionRunner ) ;
@@ -2728,7 +2783,7 @@ export class SCMViewPane extends ViewPane {
27282783 this . instantiationService . createInstance ( RepositoryRenderer , MenuId . SCMTitle , getActionViewItemProvider ( this . instantiationService ) ) ,
27292784 this . instantiationService . createInstance ( ResourceGroupRenderer , getActionViewItemProvider ( this . instantiationService ) ) ,
27302785 this . instantiationService . createInstance ( ResourceRenderer , ( ) => this . viewMode , this . listLabels , getActionViewItemProvider ( this . instantiationService ) , resourceActionRunner ) ,
2731- this . instantiationService . createInstance ( HistoryItemGroupRenderer ) ,
2786+ this . instantiationService . createInstance ( HistoryItemGroupRenderer , historyItemGroupActionRunner ) ,
27322787 this . instantiationService . createInstance ( HistoryItemRenderer , historyItemActionRunner , getActionViewItemProvider ( this . instantiationService ) ) ,
27332788 this . instantiationService . createInstance ( HistoryItemChangeRenderer , ( ) => this . viewMode , this . listLabels ) ,
27342789 this . instantiationService . createInstance ( SeparatorRenderer )
0 commit comments