Skip to content

Commit

Permalink
Implement a selectMultipleAuthors setting which restricts author se…
Browse files Browse the repository at this point in the history
…lection only to a single author when disabled.
  • Loading branch information
rgeorgiev583 committed Jan 23, 2024
1 parent 15efc67 commit 87482ab
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,11 @@
"default": false,
"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."
},
"git-graph.repository.selectMultipleAuthors": {
"type": "boolean",
"default": true,
"description": "Enables the selection of multiple authors from the Authors dropdown."
},
"git-graph.repository.selectMultipleBranches": {
"type": "boolean",
"default": true,
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ class Config {
return !!this.getRenamedExtensionSetting('repository.onlyFollowFirstParent', 'onlyFollowFirstParent', false);
}

/**
* Get the value of the `git-graph.repository.selectMultipleAuthors` Extension Setting.
*/
get selectMultipleAuthors() {
return !!this.config.get('repository.selectMultipleAuthors', true);
}

/**
* Get the value of the `git-graph.repository.selectMultipleBranches` Extension Setting.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ export class GitGraphView extends Disposable {
onRepoLoad: config.onRepoLoad,
referenceLabels: config.referenceLabels,
repoDropdownOrder: config.repoDropdownOrder,
selectMultipleAuthors: config.selectMultipleAuthors,
selectMultipleBranches: config.selectMultipleBranches,
showRemoteBranches: config.showRemoteBranches,
showStashes: config.showStashes,
Expand Down Expand Up @@ -719,12 +720,13 @@ export class GitGraphView extends Disposable {
} else if (numRepos > 0) {
const stickyClassAttr = initialState.config.stickyHeader ? ' class="sticky"' : '';
const branchDropdownLabel = initialState.config.selectMultipleBranches ? 'Branches' : 'Branch';
const authorDropdownLabel = initialState.config.selectMultipleAuthors ? 'Authors' : 'Author';
body = `<body>
<div id="view" tabindex="-1">
<div id="controls"${stickyClassAttr}>
<span id="repoControl"><span class="unselectable">Repo: </span><div id="repoDropdown" class="dropdown"></div></span>
<span id="branchControl"><span class="unselectable">${branchDropdownLabel}: </span><div id="branchDropdown" class="dropdown"></div></span>
<span id="authorControl"><span class="unselectable">Authors: </span><div id="authorDropdown" class="dropdown"></div></span>
<span id="authorControl"><span class="unselectable">${authorDropdownLabel}: </span><div id="authorDropdown" class="dropdown"></div></span>
<label id="showRemoteBranchesControl"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Show Remote Branches</label>
<div id="currentBtn" title="Current"></div>
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export interface GitGraphViewConfig {
readonly onRepoLoad: OnRepoLoadConfig;
readonly referenceLabels: ReferenceLabelsConfig;
readonly repoDropdownOrder: RepoDropdownOrder;
readonly selectMultipleAuthors: boolean;
readonly selectMultipleBranches: boolean;
readonly showRemoteBranches: boolean;
readonly showStashes: boolean;
Expand Down
2 changes: 1 addition & 1 deletion web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class GitGraphView {
this.clearCommits();
this.requestLoadRepoInfoAndCommits(true, true);
});
this.authorDropdown = new Dropdown('authorDropdown', false, true, 'Authors', (values) => {
this.authorDropdown = new Dropdown('authorDropdown', false, this.config.selectMultipleAuthors, 'Authors', (values) => {
this.currentAuthors = values;
this.maxCommits = this.config.initialLoadCommits;
this.saveState();
Expand Down

0 comments on commit 87482ab

Please sign in to comment.