From 87482abcf5397a060bf092899d2c7aa2aa72f645 Mon Sep 17 00:00:00 2001 From: Radoslav Georgiev Date: Tue, 23 Jan 2024 20:32:38 +0200 Subject: [PATCH] Implement a `selectMultipleAuthors` setting which restricts author selection only to a single author when disabled. --- package.json | 5 +++++ src/config.ts | 7 +++++++ src/gitGraphView.ts | 4 +++- src/types.ts | 1 + web/main.ts | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 583e86dc..dd60f46d 100644 --- a/package.json +++ b/package.json @@ -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, diff --git a/src/config.ts b/src/config.ts index 5e064a75..1cecf612 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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. */ diff --git a/src/gitGraphView.ts b/src/gitGraphView.ts index 2e058285..aea8202c 100644 --- a/src/gitGraphView.ts +++ b/src/gitGraphView.ts @@ -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, @@ -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 = `
Repo: ${branchDropdownLabel}: - Authors: + ${authorDropdownLabel}:
diff --git a/src/types.ts b/src/types.ts index b3c581b9..f2e2f05b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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; diff --git a/web/main.ts b/web/main.ts index c63a2281..0881dc37 100644 --- a/web/main.ts +++ b/web/main.ts @@ -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();