@@ -24,7 +24,7 @@ import { MenuItemAction, IMenuService, registerAction2, MenuId, IAction2Options,
24
24
import { IAction , ActionRunner , Action , Separator , IActionRunner } from 'vs/base/common/actions' ;
25
25
import { ActionBar , IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar' ;
26
26
import { 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' ;
28
28
import { WorkbenchCompressibleAsyncDataTree , IOpenEvent } from 'vs/platform/list/browser/listService' ;
29
29
import { IConfigurationService , ConfigurationTarget } from 'vs/platform/configuration/common/configuration' ;
30
30
import { disposableTimeout , Sequencer , ThrottledDelayer , Throttler } from 'vs/base/common/async' ;
@@ -761,18 +761,42 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
761
761
}
762
762
}
763
763
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
+
764
776
interface HistoryItemGroupTemplate {
765
777
readonly iconContainer : HTMLElement ;
766
778
readonly label : IconLabel ;
779
+ readonly toolBar : WorkbenchToolBar ;
767
780
readonly count : CountBadge ;
768
- readonly disposables : IDisposable ;
781
+ readonly elementDisposables : DisposableStore ;
782
+ readonly templateDisposables : DisposableStore ;
769
783
}
770
784
771
785
class HistoryItemGroupRenderer implements ICompressibleTreeRenderer < SCMHistoryItemGroupTreeElement , void , HistoryItemGroupTemplate > {
772
786
773
787
static readonly TEMPLATE_ID = 'history-item-group' ;
774
788
get templateId ( ) : string { return HistoryItemGroupRenderer . TEMPLATE_ID ; }
775
789
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
+
776
800
renderTemplate ( container : HTMLElement ) {
777
801
// hack
778
802
( container . parentElement ! . parentElement ! . querySelector ( '.monaco-tl-twistie' ) ! as HTMLElement ) . classList . add ( 'force-twistie' ) ;
@@ -782,10 +806,14 @@ class HistoryItemGroupRenderer implements ICompressibleTreeRenderer<SCMHistoryIt
782
806
const label = new IconLabel ( element , { supportIcons : true } ) ;
783
807
const iconContainer = prepend ( label . element , $ ( '.icon-container' ) ) ;
784
808
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
+
785
813
const countContainer = append ( element , $ ( '.count' ) ) ;
786
814
const count = new CountBadge ( countContainer , { } , defaultCountBadgeStyles ) ;
787
815
788
- return { iconContainer, label, count, disposables : new DisposableStore ( ) } ;
816
+ return { iconContainer, label, toolBar , count, elementDisposables : new DisposableStore ( ) , templateDisposables } ;
789
817
}
790
818
791
819
renderElement ( node : ITreeNode < SCMHistoryItemGroupTreeElement > , index : number , templateData : HistoryItemGroupTemplate , height : number | undefined ) : void {
@@ -798,13 +826,36 @@ class HistoryItemGroupRenderer implements ICompressibleTreeRenderer<SCMHistoryIt
798
826
799
827
templateData . label . setLabel ( historyItemGroup . label , historyItemGroup . description , { title : historyItemGroup . ariaLabel } ) ;
800
828
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
+ }
801
846
}
802
847
803
848
renderCompressedElements ( node : ITreeNode < ICompressedTreeNode < SCMHistoryItemGroupTreeElement > , void > , index : number , templateData : HistoryItemGroupTemplate , height : number | undefined ) : void {
804
849
throw new Error ( 'Should never happen since node is incompressible' ) ;
805
850
}
851
+
852
+ disposeElement ( node : ITreeNode < SCMHistoryItemGroupTreeElement > , index : number , templateData : HistoryItemGroupTemplate , height : number | undefined ) : void {
853
+ templateData . elementDisposables . clear ( ) ;
854
+ }
855
+
806
856
disposeTemplate ( templateData : HistoryItemGroupTemplate ) : void {
807
- templateData . disposables . dispose ( ) ;
857
+ templateData . elementDisposables . dispose ( ) ;
858
+ templateData . templateDisposables . dispose ( ) ;
808
859
}
809
860
}
810
861
@@ -2709,6 +2760,10 @@ export class SCMViewPane extends ViewPane {
2709
2760
resourceActionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
2710
2761
this . disposables . add ( resourceActionRunner ) ;
2711
2762
2763
+ const historyItemGroupActionRunner = new HistoryItemGroupActionRunner ( ) ;
2764
+ historyItemGroupActionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
2765
+ this . disposables . add ( historyItemGroupActionRunner ) ;
2766
+
2712
2767
const historyItemActionRunner = new HistoryItemActionRunner ( ) ;
2713
2768
historyItemActionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
2714
2769
this . disposables . add ( historyItemActionRunner ) ;
@@ -2728,7 +2783,7 @@ export class SCMViewPane extends ViewPane {
2728
2783
this . instantiationService . createInstance ( RepositoryRenderer , MenuId . SCMTitle , getActionViewItemProvider ( this . instantiationService ) ) ,
2729
2784
this . instantiationService . createInstance ( ResourceGroupRenderer , getActionViewItemProvider ( this . instantiationService ) ) ,
2730
2785
this . instantiationService . createInstance ( ResourceRenderer , ( ) => this . viewMode , this . listLabels , getActionViewItemProvider ( this . instantiationService ) , resourceActionRunner ) ,
2731
- this . instantiationService . createInstance ( HistoryItemGroupRenderer ) ,
2786
+ this . instantiationService . createInstance ( HistoryItemGroupRenderer , historyItemGroupActionRunner ) ,
2732
2787
this . instantiationService . createInstance ( HistoryItemRenderer , historyItemActionRunner , getActionViewItemProvider ( this . instantiationService ) ) ,
2733
2788
this . instantiationService . createInstance ( HistoryItemChangeRenderer , ( ) => this . viewMode , this . listLabels ) ,
2734
2789
this . instantiationService . createInstance ( SeparatorRenderer )
0 commit comments