Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement selection of a single branch or author #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,16 @@
"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,
"description": "Enables the selection of multiple branches from the Branches dropdown."
},
"git-graph.repository.showCommitsOnlyReferencedByTags": {
"type": "boolean",
"default": true,
Expand Down
14 changes: 14 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,20 @@ 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.
*/
get selectMultipleBranches() {
return !!this.config.get('repository.selectMultipleBranches', true);
}

/**
* Get the value of the `git-graph.repository.showCommitsOnlyReferencedByTags` Extension Setting.
*/
Expand Down
8 changes: 6 additions & 2 deletions src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ 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,
showTags: config.showTags
Expand All @@ -717,12 +719,14 @@ export class GitGraphView extends Disposable {
</body>`;
} 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">Branches: </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="branchControl"><span class="unselectable">${branchDropdownLabel}: </span><div id="branchDropdown" 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
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ export interface GitGraphViewConfig {
readonly onRepoLoad: OnRepoLoadConfig;
readonly referenceLabels: ReferenceLabelsConfig;
readonly repoDropdownOrder: RepoDropdownOrder;
readonly selectMultipleAuthors: boolean;
readonly selectMultipleBranches: boolean;
readonly showRemoteBranches: boolean;
readonly showStashes: boolean;
readonly showTags: boolean;
Expand Down
4 changes: 2 additions & 2 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ class GitGraphView {
this.loadRepo(values[0]);
});

this.branchDropdown = new Dropdown('branchDropdown', false, true, 'Branches', (values) => {
this.branchDropdown = new Dropdown('branchDropdown', false, this.config.selectMultipleBranches, 'Branches', (values) => {
this.currentBranches = values;
this.maxCommits = this.config.initialLoadCommits;
this.saveState();
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