Skip to content

Commit acd0884

Browse files
committed
Add setting to hide "Remotes" and "Simplify" from the toolbar
1 parent 3dfffdb commit acd0884

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,24 @@
542542
},
543543
"description": "An object specifying the default visibility of the Date, Author & Commit columns. Example: {\"Date\": true, \"Author\": true, \"Commit\": true}"
544544
},
545+
"git-graph.toolbarButtonVisibility": {
546+
"type": "object",
547+
"properties": {
548+
"Remotes": {
549+
"type": "boolean",
550+
"title": "Visibility of the Remotes checkbox"
551+
},
552+
"Simplify": {
553+
"type": "boolean",
554+
"title": "Visibility of the Simplify checkbox"
555+
}
556+
},
557+
"default": {
558+
"Remotes": true,
559+
"Simplify": true
560+
},
561+
"description": "An object specifying the default visibility of the items of the tool bar. Example: {\"Remotes\": true\", Simplify\": true}"
562+
},
545563
"git-graph.dialog.addTag.pushToRemote": {
546564
"type": "boolean",
547565
"default": false,

src/config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import {
2525
RepoDropdownOrder,
2626
SquashMessageFormat,
2727
TabIconColourTheme,
28-
TagType
28+
TagType,
29+
ToolbarButtonVisibility
2930
} from './types';
3031

3132
const VIEW_COLUMN_MAPPING: { [column: string]: vscode.ViewColumn } = {
@@ -168,6 +169,18 @@ class Config {
168169
}
169170
}
170171

172+
/**
173+
* Get the value of the `git-graph.toolbarButtonVisibility` Extension Setting.
174+
*/
175+
get toolbarButtonVisibility(): ToolbarButtonVisibility {
176+
let obj: any = this.config.get('toolbarButtonVisibility', {});
177+
if (typeof obj === 'object' && obj !== null && typeof obj['Remotes'] === 'boolean' && typeof obj['Simplify'] === 'boolean') {
178+
return { remotes: obj['Remotes'], simplify: obj['Simplify'] };
179+
} else {
180+
return { remotes: true, simplify: true };
181+
}
182+
}
183+
171184
/**
172185
* Get the value of the `git-graph.dialog.*` Extension Settings.
173186
*/

src/gitGraphView.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,8 @@ export class GitGraphView extends Disposable {
694694
showRemoteBranches: config.showRemoteBranches,
695695
simplifyByDecoration: config.simplifyByDecoration,
696696
showStashes: config.showStashes,
697-
showTags: config.showTags
697+
showTags: config.showTags,
698+
toolbarButtonVisibility: config.toolbarButtonVisibility
698699
},
699700
lastActiveRepo: this.extensionState.getLastActiveRepo(),
700701
loadViewTo: this.loadViewTo,
@@ -718,15 +719,17 @@ export class GitGraphView extends Disposable {
718719
</body>`;
719720
} else if (numRepos > 0) {
720721
const stickyClassAttr = initialState.config.stickyHeader ? ' class="sticky"' : '';
722+
let hideRemotes = '', hideSimplify = '';
723+
if (!config.toolbarButtonVisibility.remotes) { hideRemotes = 'style="display: none"'; }
724+
if (!config.toolbarButtonVisibility.simplify) { hideSimplify = 'style="display: none"'; }
721725
body = `<body>
722726
<div id="view" tabindex="-1">
723727
<div id="controls"${stickyClassAttr}>
724728
<span id="repoControl"><span class="unselectable">Repo: </span><div id="repoDropdown" class="dropdown"></div></span>
725729
<span id="branchControl"><span class="unselectable">Branches: </span><div id="branchDropdown" class="dropdown"></div></span>
726730
<span id="authorControl"><span class="unselectable">Authors: </span><div id="authorDropdown" class="dropdown"></div></span>
727-
728-
<label id="showRemoteBranchesControl" title="Show Remote Branches"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Remotes</label>
729-
<label id="simplifyByDecorationControl" title="Simplify By Decoration"><input type="checkbox" id="simplifyByDecorationCheckbox" tabindex="-1"><span class="customCheckbox"></span>Simplify</label>
731+
<label ${hideRemotes} id="showRemoteBranchesControl" title="Show Remote Branches"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Remotes</label>
732+
<label ${hideSimplify} id="simplifyByDecorationControl" title="Simplify By Decoration"><input type="checkbox" id="simplifyByDecorationCheckbox" tabindex="-1"><span class="customCheckbox"></span>Simplify</label>
730733
<div id="currentBtn" title="Current"></div>
731734
<div id="findBtn" title="Find"></div>
732735
<div id="terminalBtn" title="Open a Terminal for this Repository"></div>

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export interface GitGraphViewConfig {
267267
readonly showStashes: boolean;
268268
readonly showTags: boolean;
269269
readonly stickyHeader: boolean;
270+
readonly toolbarButtonVisibility: ToolbarButtonVisibility;
270271
}
271272

272273
export interface GitGraphViewGlobalState {
@@ -460,6 +461,11 @@ export interface DefaultColumnVisibility {
460461
readonly commit: boolean;
461462
}
462463

464+
export interface ToolbarButtonVisibility {
465+
readonly remotes: boolean;
466+
readonly simplify: boolean;
467+
}
468+
463469
export interface DialogDefaults {
464470
readonly addTag: {
465471
readonly pushToRemote: boolean,

0 commit comments

Comments
 (0)