Skip to content

Commit 40d1877

Browse files
authored
Merge pull request #30 from rgeorgiev583/implement-selection-of-a-single-branch-or-author
Implement selection of a single branch or author
2 parents dfc3887 + e72baa1 commit 40d1877

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,16 @@
10901090
"default": false,
10911091
"markdownDescription": "Only follow the first parent of commits when discovering the commits to load in the Git Graph View. See [--first-parent](https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent) to find out more about this setting. This can be overridden per repository in the Git Graph View's Repository Settings Widget."
10921092
},
1093+
"git-graph.repository.selectMultipleAuthors": {
1094+
"type": "boolean",
1095+
"default": true,
1096+
"description": "Enables the selection of multiple authors from the Authors dropdown."
1097+
},
1098+
"git-graph.repository.selectMultipleBranches": {
1099+
"type": "boolean",
1100+
"default": true,
1101+
"description": "Enables the selection of multiple branches from the Branches dropdown."
1102+
},
10931103
"git-graph.repository.showCommitsOnlyReferencedByTags": {
10941104
"type": "boolean",
10951105
"default": true,

src/config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,20 @@ class Config {
464464
return !!this.getRenamedExtensionSetting('repository.onlyFollowFirstParent', 'onlyFollowFirstParent', false);
465465
}
466466

467+
/**
468+
* Get the value of the `git-graph.repository.selectMultipleAuthors` Extension Setting.
469+
*/
470+
get selectMultipleAuthors() {
471+
return !!this.config.get('repository.selectMultipleAuthors', true);
472+
}
473+
474+
/**
475+
* Get the value of the `git-graph.repository.selectMultipleBranches` Extension Setting.
476+
*/
477+
get selectMultipleBranches() {
478+
return !!this.config.get('repository.selectMultipleBranches', true);
479+
}
480+
467481
/**
468482
* Get the value of the `git-graph.repository.showCommitsOnlyReferencedByTags` Extension Setting.
469483
*/

src/gitGraphView.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ export class GitGraphView extends Disposable {
691691
onRepoLoad: config.onRepoLoad,
692692
referenceLabels: config.referenceLabels,
693693
repoDropdownOrder: config.repoDropdownOrder,
694+
selectMultipleAuthors: config.selectMultipleAuthors,
695+
selectMultipleBranches: config.selectMultipleBranches,
694696
showRemoteBranches: config.showRemoteBranches,
695697
simplifyByDecoration: config.simplifyByDecoration,
696698
showStashes: config.showStashes,
@@ -719,15 +721,17 @@ export class GitGraphView extends Disposable {
719721
</body>`;
720722
} else if (numRepos > 0) {
721723
const stickyClassAttr = initialState.config.stickyHeader ? ' class="sticky"' : '';
724+
const branchDropdownLabel = initialState.config.selectMultipleBranches ? 'Branches' : 'Branch';
725+
const authorDropdownLabel = initialState.config.selectMultipleAuthors ? 'Authors' : 'Author';
722726
let hideRemotes = '', hideSimplify = '';
723727
if (!config.toolbarButtonVisibility.remotes) { hideRemotes = 'style="display: none"'; }
724728
if (!config.toolbarButtonVisibility.simplify) { hideSimplify = 'style="display: none"'; }
725729
body = `<body>
726730
<div id="view" tabindex="-1">
727731
<div id="controls"${stickyClassAttr}>
728732
<span id="repoControl"><span class="unselectable">Repo: </span><div id="repoDropdown" class="dropdown"></div></span>
729-
<span id="branchControl"><span class="unselectable">Branches: </span><div id="branchDropdown" class="dropdown"></div></span>
730-
<span id="authorControl"><span class="unselectable">Authors: </span><div id="authorDropdown" class="dropdown"></div></span>
733+
<span id="branchControl"><span class="unselectable">${branchDropdownLabel}: </span><div id="branchDropdown" class="dropdown"></div></span>
734+
<span id="authorControl"><span class="unselectable">${authorDropdownLabel}: </span><div id="authorDropdown" class="dropdown"></div></span>
731735
<label ${hideRemotes} id="showRemoteBranchesControl" title="Show Remote Branches"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Remotes</label>
732736
<label ${hideSimplify} id="simplifyByDecorationControl" title="Simplify By Decoration"><input type="checkbox" id="simplifyByDecorationCheckbox" tabindex="-1"><span class="customCheckbox"></span>Simplify</label>
733737
<div id="currentBtn" title="Current"></div>

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ export interface GitGraphViewConfig {
263263
readonly onRepoLoad: OnRepoLoadConfig;
264264
readonly referenceLabels: ReferenceLabelsConfig;
265265
readonly repoDropdownOrder: RepoDropdownOrder;
266+
readonly selectMultipleAuthors: boolean;
267+
readonly selectMultipleBranches: boolean;
266268
readonly showRemoteBranches: boolean;
267269
readonly simplifyByDecoration: boolean;
268270
readonly showStashes: boolean;

web/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ class GitGraphView {
8686
this.loadRepo(values[0]);
8787
});
8888

89-
this.branchDropdown = new Dropdown('branchDropdown', false, true, 'Branches', (values) => {
89+
this.branchDropdown = new Dropdown('branchDropdown', false, this.config.selectMultipleBranches, 'Branches', (values) => {
9090
this.currentBranches = values;
9191
this.maxCommits = this.config.initialLoadCommits;
9292
this.saveState();
9393
this.clearCommits();
9494
this.requestLoadRepoInfoAndCommits(true, true);
9595
});
96-
this.authorDropdown = new Dropdown('authorDropdown', false, true, 'Authors', (values) => {
96+
this.authorDropdown = new Dropdown('authorDropdown', false, this.config.selectMultipleAuthors, 'Authors', (values) => {
9797
this.currentAuthors = values;
9898
this.maxCommits = this.config.initialLoadCommits;
9999
this.saveState();

0 commit comments

Comments
 (0)