1+
12class GitGraphView {
23 private gitRepos : GG . GitRepoSet ;
34 private gitBranches : ReadonlyArray < string > = [ ] ;
@@ -12,6 +13,7 @@ class GitGraphView {
1213 private onlyFollowFirstParent : boolean = false ;
1314 private avatars : AvatarImageCollection = { } ;
1415 private currentBranches : string [ ] | null = null ;
16+ private currentAuthors : string [ ] | null = null ;
1517
1618 private currentRepo ! : string ;
1719 private currentRepoLoading : boolean = true ;
@@ -45,6 +47,7 @@ class GitGraphView {
4547 private readonly settingsWidget : SettingsWidget ;
4648 private readonly repoDropdown : Dropdown ;
4749 private readonly branchDropdown : Dropdown ;
50+ private readonly authorDropdown : Dropdown ;
4851
4952 private readonly viewElem : HTMLElement ;
5053 private readonly controlsElem : HTMLElement ;
@@ -92,7 +95,13 @@ class GitGraphView {
9295 this . clearCommits ( ) ;
9396 this . requestLoadRepoInfoAndCommits ( true , true ) ;
9497 } ) ;
95-
98+ this . authorDropdown = new Dropdown ( 'authorDropdown' , false , true , 'Authors' , ( values ) => {
99+ this . currentAuthors = values ;
100+ this . maxCommits = this . config . initialLoadCommits ;
101+ this . saveState ( ) ;
102+ this . clearCommits ( ) ;
103+ this . requestLoadRepoInfoAndCommits ( true , true ) ;
104+ } ) ;
96105 this . showRemoteBranchesElem = < HTMLInputElement > document . getElementById ( 'showRemoteBranchesCheckbox' ) ! ;
97106 this . showRemoteBranchesElem . addEventListener ( 'change' , ( ) => {
98107 this . saveRepoStateValue ( this . currentRepo , 'showRemoteBranchesV2' , this . showRemoteBranchesElem . checked ? GG . BooleanOverride . Enabled : GG . BooleanOverride . Disabled ) ;
@@ -123,6 +132,7 @@ class GitGraphView {
123132 if ( prevState && ! prevState . currentRepoLoading && typeof this . gitRepos [ prevState . currentRepo ] !== 'undefined' ) {
124133 this . currentRepo = prevState . currentRepo ;
125134 this . currentBranches = prevState . currentBranches ;
135+ this . currentAuthors = prevState . currentAuthors ;
126136 this . maxCommits = prevState . maxCommits ;
127137 this . expandedCommit = prevState . expandedCommit ;
128138 this . avatars = prevState . avatars ;
@@ -207,6 +217,7 @@ class GitGraphView {
207217 }
208218
209219 private loadRepo ( repo : string ) {
220+ console . warn ( 'loadRepro' ) ;
210221 this . currentRepo = repo ;
211222 this . currentRepoLoading = true ;
212223 this . showRemoteBranchesElem . checked = getShowRemoteBranches ( this . gitRepos [ this . currentRepo ] . showRemoteBranchesV2 ) ;
@@ -216,6 +227,7 @@ class GitGraphView {
216227 this . gitStashes = [ ] ;
217228 this . gitTags = [ ] ;
218229 this . currentBranches = null ;
230+ this . currentAuthors = null ;
219231 this . renderFetchButton ( ) ;
220232 this . closeCommitDetails ( false ) ;
221233 this . settingsWidget . close ( ) ;
@@ -270,10 +282,22 @@ class GitGraphView {
270282 }
271283 }
272284
285+ // Configure current branches
286+ if ( this . currentBranches !== null && ! ( this . currentBranches . length === 1 && this . currentBranches [ 0 ] === SHOW_ALL_BRANCHES ) ) {
287+ // Filter any branches that are currently selected, but no longer exist
288+ const globPatterns = this . config . customBranchGlobPatterns . map ( ( pattern ) => pattern . glob ) ;
289+ this . currentBranches = this . currentBranches . filter ( ( branch ) =>
290+ this . gitBranches . includes ( branch ) || globPatterns . includes ( branch )
291+ ) ;
292+ }
273293 this . saveState ( ) ;
294+ this . currentAuthors = [ ] ;
295+ this . currentAuthors . push ( SHOW_ALL_BRANCHES ) ;
274296
275297 // Set up branch dropdown options
276298 this . branchDropdown . setOptions ( this . getBranchOptions ( true ) , this . currentBranches ) ;
299+ console . warn ( 'test2' ) ;
300+ this . authorDropdown . setOptions ( this . getAuthorOptions ( ) , this . currentAuthors ) ;
277301
278302 // Remove hidden remotes that no longer exist
279303 let hiddenRemotes = this . gitRepos [ this . currentRepo ] . hideRemotes ;
@@ -496,6 +520,7 @@ class GitGraphView {
496520 this . renderCdvExternalDiffBtn ( ) ;
497521 }
498522 this . settingsWidget . refresh ( ) ;
523+ this . authorDropdown . setOptions ( this . getAuthorOptions ( ) , this . currentAuthors ) ;
499524 }
500525
501526 private displayLoadDataError ( message : string , reason : string ) {
@@ -539,7 +564,17 @@ class GitGraphView {
539564 }
540565 return options ;
541566 }
542-
567+ public getAuthorOptions ( ) : ReadonlyArray < DialogSelectInputOption > {
568+ const options : DialogSelectInputOption [ ] = [ ] ;
569+ options . push ( { name : 'All' , value : SHOW_ALL_BRANCHES } ) ;
570+ if ( this . gitConfig && this . gitConfig . authors ) {
571+ for ( let i = 0 ; i < this ! . gitConfig ! . authors . length ; i ++ ) {
572+ const author = this ! . gitConfig ! . authors [ i ] ;
573+ options . push ( { name : author . name , value : author . name } ) ;
574+ }
575+ }
576+ return options ;
577+ }
543578 public getCommitId ( hash : string ) {
544579 return typeof this . commitLookup [ hash ] === 'number' ? this . commitLookup [ hash ] : null ;
545580 }
@@ -611,6 +646,7 @@ class GitGraphView {
611646 repo : this . currentRepo ,
612647 refreshId : ++ this . currentRepoRefreshState . loadCommitsRefreshId ,
613648 branches : this . currentBranches === null || ( this . currentBranches . length === 1 && this . currentBranches [ 0 ] === SHOW_ALL_BRANCHES ) ? null : this . currentBranches ,
649+ // authors: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.currentBranches,
614650 maxCommits : this . maxCommits ,
615651 showTags : getShowTags ( repoState . showTags ) ,
616652 showRemoteBranches : getShowRemoteBranches ( repoState . showRemoteBranchesV2 ) ,
@@ -724,6 +760,7 @@ class GitGraphView {
724760 commitHead : this . commitHead ,
725761 avatars : this . avatars ,
726762 currentBranches : this . currentBranches ,
763+ currentAuthors : this . currentAuthors ,
727764 moreCommitsAvailable : this . moreCommitsAvailable ,
728765 maxCommits : this . maxCommits ,
729766 onlyFollowFirstParent : this . onlyFollowFirstParent ,
@@ -979,6 +1016,8 @@ class GitGraphView {
9791016 private getBranchContextMenuActions ( target : DialogTarget & RefTarget ) : ContextMenuActions {
9801017 const refName = target . ref , visibility = this . config . contextMenuActionsVisibility . branch ;
9811018 const isSelectedInBranchesDropdown = this . branchDropdown . isSelected ( refName ) ;
1019+ // const isSelectedInBranchesDropdown = this.authorDropdown.isSelected(refName);
1020+
9821021 return [ [
9831022 {
9841023 title : 'Checkout Branch' ,
@@ -2010,6 +2049,8 @@ class GitGraphView {
20102049 editorFontFamily = eff ;
20112050 this . repoDropdown . refresh ( ) ;
20122051 this . branchDropdown . refresh ( ) ;
2052+ this . authorDropdown . refresh ( ) ;
2053+
20132054 }
20142055 if ( fmc !== findMatchColour ) {
20152056 findMatchColour = fmc ;
@@ -2125,6 +2166,9 @@ class GitGraphView {
21252166 } else if ( this . branchDropdown . isOpen ( ) ) {
21262167 this . branchDropdown . close ( ) ;
21272168 handledEvent ( e ) ;
2169+ } else if ( this . authorDropdown . isOpen ( ) ) {
2170+ this . authorDropdown . close ( ) ;
2171+ handledEvent ( e ) ;
21282172 } else if ( this . settingsWidget . isVisible ( ) ) {
21292173 this . settingsWidget . close ( ) ;
21302174 handledEvent ( e ) ;
0 commit comments