Skip to content

Commit 9c6adf8

Browse files
authored
Merge pull request #45 from hansu/3-hide-commit-msg-box-2.0
allow collapsing commit summary
2 parents 7a8003a + 73b8087 commit 9c6adf8

File tree

7 files changed

+125
-19
lines changed

7 files changed

+125
-19
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@
138138
"default": "Inline",
139139
"description": "Specifies where the Commit Details View is rendered in the Git Graph View."
140140
},
141+
"git-graph.commitDetailsView.initiallyHideSummary": {
142+
"type": "boolean",
143+
"default": false,
144+
"description": "Initially hide the commit summary in the Commit Details View."
145+
},
141146
"git-graph.contextMenuActionsVisibility": {
142147
"type": "object",
143148
"default": {},

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class Config {
7272
: FileViewType.Tree,
7373
location: this.getRenamedExtensionSetting<string>('commitDetailsView.location', 'commitDetailsViewLocation', 'Inline') === 'Docked to Bottom'
7474
? CommitDetailsViewLocation.DockedToBottom
75-
: CommitDetailsViewLocation.Inline
75+
: CommitDetailsViewLocation.Inline,
76+
initiallyHideSummary: this.config.get('commitDetailsView.initiallyHideSummary', false)
7677
};
7778
}
7879

src/extensionState.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export const DEFAULT_REPO_STATE: GitRepoState = {
3737
simplifyByDecoration: BooleanOverride.Default,
3838
showStashes: BooleanOverride.Default,
3939
showTags: BooleanOverride.Default,
40-
workspaceFolderIndex: null
40+
workspaceFolderIndex: null,
41+
isCdvSummaryHidden: true
4142
};
4243

4344
const DEFAULT_GIT_GRAPH_VIEW_GLOBAL_STATE: GitGraphViewGlobalState = {

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export interface GitRepoState {
222222
showStashes: BooleanOverride;
223223
showTags: BooleanOverride;
224224
workspaceFolderIndex: number | null;
225+
isCdvSummaryHidden: boolean;
225226
}
226227

227228

@@ -287,6 +288,7 @@ export interface CommitDetailsViewConfig {
287288
readonly fileTreeCompactFolders: boolean;
288289
readonly fileViewType: FileViewType;
289290
readonly location: CommitDetailsViewLocation;
291+
readonly initiallyHideSummary: boolean;
290292
}
291293

292294
export interface GraphConfig {

web/main.ts

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class GitGraphView {
184184
name: this.gitRepos[this.currentRepo].name || getRepoName(this.currentRepo)
185185
}, 'Opening Terminal');
186186
});
187+
this.gitRepos[this.currentRepo].isCdvSummaryHidden = this.config.commitDetailsView.initiallyHideSummary;
187188
}
188189

189190

@@ -838,7 +839,7 @@ class GitGraphView {
838839
}
839840

840841
const colHeadersElem = document.getElementById('tableColHeaders');
841-
const cdvHeight = this.gitRepos[this.currentRepo].cdvHeight;
842+
const cdvHeight = this.gitRepos[this.currentRepo].isCdvSummaryHidden ? 0 : this.gitRepos[this.currentRepo].cdvHeight;
842843
const headerHeight = colHeadersElem !== null ? colHeadersElem.clientHeight + 1 : 0;
843844
const expandedCommit = this.isCdvDocked() ? null : this.expandedCommit;
844845
const expandedCommitElem = expandedCommit !== null ? document.getElementById('cdv') : null;
@@ -2608,7 +2609,7 @@ class GitGraphView {
26082609
}
26092610

26102611
if (expandedCommit.loading) {
2611-
html += '<div id="cdvLoading">' + SVG_ICONS.loading + ' Loading ' + (expandedCommit.compareWithHash === null ? expandedCommit.commitHash !== UNCOMMITTED ? 'Commit Details' : 'Uncommitted Changes' : 'Commit Comparison') + ' ...</div>';
2612+
html += '<div id="cdvFiles"></div><div id="cdvLoading">' + SVG_ICONS.loading + ' Loading ' + (expandedCommit.compareWithHash === null ? expandedCommit.commitHash !== UNCOMMITTED ? 'Commit Details' : 'Uncommitted Changes' : 'Commit Comparison') + ' ...</div>';
26122613
} else {
26132614
html += '<div id="cdvSummary">';
26142615
if (expandedCommit.compareWithHash === null) {
@@ -2648,16 +2649,17 @@ class GitGraphView {
26482649
// Commit comparison should be shown
26492650
html += 'Displaying all changes from <b>' + commitOrder.from + '</b> to <b>' + (commitOrder.to !== UNCOMMITTED ? commitOrder.to : 'Uncommitted Changes') + '</b>.';
26502651
}
2651-
html += '</div><div id="cdvFiles">' + generateFileViewHtml(expandedCommit.fileTree!, expandedCommit.fileChanges!, expandedCommit.lastViewedFile, expandedCommit.contextMenuOpen.fileView, this.getFileViewType(), commitOrder.to === UNCOMMITTED) + '</div><div id="cdvDivider"></div>';
2652+
html += '</div><div id="cdvFiles">' + (!isDocked ? '<div id="cdvSummaryToggleBtn">' + SVG_ICONS.collapse + '</div>' : '') + '<div id="cdvFilesViewWrapper"><div id="cdvFilesView">' + generateFileViewHtml(expandedCommit.fileTree!, expandedCommit.fileChanges!, expandedCommit.lastViewedFile, expandedCommit.contextMenuOpen.fileView, this.getFileViewType(), commitOrder.to === UNCOMMITTED) + '</div></div></div><div id="cdvDivider"></div>';
26522653
}
26532654
html += '</div><div id="cdvControls"><div id="cdvClose" class="cdvControlBtn" title="Close">' + SVG_ICONS.close + '</div>' +
26542655
(codeReviewPossible ? '<div id="cdvCodeReview" class="cdvControlBtn">' + SVG_ICONS.review + '</div>' : '') +
26552656
(!expandedCommit.loading ? '<div id="cdvFileViewTypeList" class="cdvControlBtn cdvFileViewTypeBtn" title="File List View">' + SVG_ICONS.fileList + '</div><div id="cdvFileViewTypeTree" class="cdvControlBtn cdvFileViewTypeBtn" title="File Tree View">' + SVG_ICONS.fileTree + '</div><div id="cdvCollapse" class="cdvControlBtn cdvFolderBtn" title="Collapse/Expand Folders">' + SVG_ICONS.collapseAll + '</div><div id="cdvExpand" class="cdvControlBtn cdvFolderBtn" title="Expand Folders">' + SVG_ICONS.expandAll + '</div>' : '') +
26562657
(externalDiffPossible ? '<div id="cdvExternalDiff" class="cdvControlBtn">' + SVG_ICONS.linkExternal + '</div>' : '') +
26572658
'</div><div class="cdvHeightResize"></div>';
26582659

2659-
elem.innerHTML = isDocked ? html : '<td><div class="cdvHeightResize"></div></td><td colspan="' + (this.getNumColumns() - 1) + '">' + html + '</td>';
2660-
if (!expandedCommit.loading) this.setCdvDivider();
2660+
elem.innerHTML = isDocked ? html : '<td><div class="cdvHeightResize"></div></td><td colspan="' + (this.getNumColumns() - 1) + '"><div id="cdvContentWrapper">' + html + '</div></td>';
2661+
this.setCdvDivider();
2662+
this.setCdvHeight(elem, isDocked);
26612663
if (!isDocked) this.renderGraph();
26622664

26632665
if (!refresh) {
@@ -2730,6 +2732,12 @@ class GitGraphView {
27302732
document.getElementById('cdvExpand')!.addEventListener('click', () => {
27312733
this.openFolders(true);
27322734
});
2735+
let cdvSummaryToggleBtn = document.getElementById('cdvSummaryToggleBtn');
2736+
if (cdvSummaryToggleBtn !== null) cdvSummaryToggleBtn.addEventListener('click', () => {
2737+
this.gitRepos[this.currentRepo].isCdvSummaryHidden = !(this.gitRepos[this.currentRepo].isCdvSummaryHidden);
2738+
this.hideCdvSummary(this.gitRepos[this.currentRepo].isCdvSummaryHidden);
2739+
});
2740+
this.hideCdvSummary(this.gitRepos[this.currentRepo].isCdvSummaryHidden);
27332741

27342742
if (codeReviewPossible) {
27352743
this.renderCodeReviewBtn();
@@ -2773,6 +2781,20 @@ class GitGraphView {
27732781
}
27742782
}
27752783

2784+
private hideCdvSummary(hide: boolean) {
2785+
let btnIcon = document.getElementById('cdvSummaryToggleBtn')?.getElementsByTagName('svg')?.[0] ?? null;
2786+
let cdvSummary = document.getElementById('cdvSummary');
2787+
if (hide && !this.isCdvDocked()) {
2788+
if (btnIcon) btnIcon.style.transform = 'rotate(90deg)';
2789+
cdvSummary!.classList.add('hidden');
2790+
} else {
2791+
if (btnIcon) btnIcon.style.transform = 'rotate(-90deg)';
2792+
cdvSummary!.classList.remove('hidden');
2793+
}
2794+
let elem = document.getElementById('cdv');
2795+
if (elem !== null) this.setCdvHeight(elem, this.isCdvDocked());
2796+
}
2797+
27762798
private setCdvHeight(elem: HTMLElement, isDocked: boolean) {
27772799
let height = this.gitRepos[this.currentRepo].cdvHeight, windowHeight = window.innerHeight;
27782800
if (height > windowHeight - 40) {
@@ -2784,8 +2806,24 @@ class GitGraphView {
27842806
}
27852807

27862808
let heightPx = height + 'px';
2787-
elem.style.height = heightPx;
2788-
if (isDocked) this.viewElem.style.bottom = heightPx;
2809+
if (isDocked) {
2810+
this.viewElem.style.bottom = heightPx;
2811+
elem.style.height = heightPx;
2812+
return;
2813+
}
2814+
let inlineElem = document.getElementById('cdvContentWrapper');
2815+
if (!inlineElem) {
2816+
elem.style.height = heightPx;
2817+
return;
2818+
}
2819+
if (this.gitRepos[this.currentRepo].isCdvSummaryHidden) {
2820+
inlineElem.style.height = heightPx;
2821+
elem.style.height = '0px';
2822+
} else {
2823+
inlineElem.style.removeProperty('height');
2824+
elem.style.height = heightPx;
2825+
}
2826+
this.renderGraph();
27892827
}
27902828

27912829
private setCdvDivider() {

web/styles/main.css

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ table { border-collapse: collapse; }
311311
font-size:13px;
312312
line-height:18px;
313313
white-space:normal;
314+
overflow: visible;
314315
}
315316
#cdv.docked{
316317
display:block;
@@ -334,6 +335,7 @@ table { border-collapse: collapse; }
334335
position:absolute;
335336
right:0;
336337
width:32px;
338+
overflow: hidden;
337339
}
338340

339341
.cdvControlBtn{
@@ -397,10 +399,15 @@ table { border-collapse: collapse; }
397399
top:0;
398400
bottom:0;
399401
box-sizing:border-box;
400-
border-right:1px solid rgba(128,128,128,0.2);
401402
overflow-x:hidden;
402403
overflow-y:auto;
403404
}
405+
#cdvSummary, #cdvFiles, #cdvLoading, #cdvControls {
406+
background-color: color-mix(in srgb, var(--vscode-editor-background) 90%, rgba(128, 128, 128,1));
407+
border-left:1px solid rgba(128,128,128,0.2);
408+
border-bottom:2px solid rgba(128,128,128,0.2);
409+
}
410+
404411
#cdvDivider{
405412
position:absolute;
406413
left:50%;
@@ -411,6 +418,7 @@ table { border-collapse: collapse; }
411418
left:0;
412419
width:50%;
413420
padding:10px;
421+
padding-right:16px;
414422
text-overflow:ellipsis;
415423
-webkit-user-select:text;
416424
user-select:text;
@@ -464,15 +472,57 @@ table { border-collapse: collapse; }
464472
fill:#e00000;
465473
opacity:0.8;
466474
}
475+
#cdvSummaryToggleBtn{
476+
position: absolute;
477+
top:0;
478+
margin:0;
479+
left:-21px;
480+
z-index:100;
481+
overflow:visible;
482+
cursor:pointer;
483+
padding:2px;
484+
width:16px;
485+
height:16px;
486+
background-color: color-mix(in srgb, var(--vscode-editor-background) 90%, rgba(128, 128, 128,1));
487+
border-left: 1px solid var(--vscode-editor-background);
488+
}
489+
490+
#cdvSummaryToggleBtn svg{
491+
fill:var(--vscode-editor-foreground);
492+
fill-opacity:0.6;
493+
}
494+
.hidden{
495+
display: none;
496+
}
497+
#cdvContentWrapper {
498+
position: absolute;
499+
left: 0;
500+
right: 0;
501+
top:0;
502+
bottom:0;
503+
z-index: 11;
504+
pointer-events: none;
467505

506+
}
507+
#cdvContent *, #cdvControls, .cdvHeightResize {
508+
pointer-events: auto;
509+
}
468510
#cdvFiles{
469511
left:50%;
470512
right:0;
471-
padding:4px 8px 8px 0;
472513
-webkit-user-select:none;
473514
user-select:none;
515+
overflow: visible;
516+
}
517+
#cdvFilesViewWrapper{
518+
overflow-x:hidden;
519+
overflow-y:auto;
520+
height: 100%;
521+
}
522+
#cdvFilesView{
523+
padding:4px 8px 8px 0;
474524
}
475-
#cdvFiles ul{
525+
#cdvFilesView ul{
476526
list-style-type:none;
477527
-webkit-margin-before:0;
478528
-webkit-margin-after:0;
@@ -482,11 +532,11 @@ table { border-collapse: collapse; }
482532
margin:0;
483533
padding:0 0 0 25px;
484534
}
485-
#cdvFiles > ul{
535+
#cdvFilesView > ul{
486536
-webkit-padding-start:10px;
487537
padding:0 0 0 10px;
488538
}
489-
#cdvFiles li{
539+
#cdvFilesView li{
490540
margin-top:4px;
491541
white-space:nowrap;
492542
text-overflow:ellipsis;
@@ -502,7 +552,18 @@ table { border-collapse: collapse; }
502552
text-align:center;
503553
line-height:24px;
504554
text-overflow:ellipsis;
555+
opacity: 0;
556+
animation: fadeIn 0.25s ease-in-out 1s forwards;
505557
}
558+
@keyframes fadeIn {
559+
0% {
560+
opacity: 0;
561+
}
562+
100% {
563+
opacity: 1;
564+
}
565+
}
566+
506567
#cdvLoading svg{
507568
display:inline-block;
508569
width:15px !important;
@@ -526,16 +587,13 @@ table { border-collapse: collapse; }
526587
top:0;
527588
bottom:2px;
528589
}
529-
#cdv.inline #cdvContent{
530-
border-left:1px solid rgba(128,128,128,0.2);
531-
}
590+
532591
#cdv.inline #cdvDivider{
533592
top:0;
534593
bottom:6px;
535594
}
536595
#cdv.inline .cdvHeightResize{
537596
bottom:0;
538-
border-bottom:2px solid rgba(128,128,128,0.2);
539597
}
540598

541599
#cdv.docked #cdvContent, #cdv.docked #cdvControls{

web/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const SVG_ICONS = {
4545

4646
// The SVG icons below are from https://github.com/microsoft/vscode-icons
4747
collapseAll: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 9H4V10H9V9Z" fill="#C5C5C5"/><path fill-rule="evenodd" clip-rule="evenodd" d="M5 3L6 2H13L14 3V10L13 11H11V13L10 14H3L2 13V6L3 5H5V3ZM6 5H10L11 6V10H13V3H6V5ZM10 6H3V13H10V6Z" fill="#C5C5C5"/></svg>',
48-
expandAll: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 9H4V10H9V9Z" fill="#C5C5C5"/><path d="M7 12L7 7L6 7L6 12L7 12Z" fill="#C5C5C5"/><path fill-rule="evenodd" clip-rule="evenodd" d="M5 3L6 2H13L14 3V10L13 11H11V13L10 14H3L2 13V6L3 5H5V3ZM6 5H10L11 6V10H13V3H6V5ZM10 6H3V13H10V6Z" fill="#C5C5C5"/></svg>'
48+
expandAll: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 9H4V10H9V9Z" fill="#C5C5C5"/><path d="M7 12L7 7L6 7L6 12L7 12Z" fill="#C5C5C5"/><path fill-rule="evenodd" clip-rule="evenodd" d="M5 3L6 2H13L14 3V10L13 11H11V13L10 14H3L2 13V6L3 5H5V3ZM6 5H10L11 6V10H13V3H6V5ZM10 6H3V13H10V6Z" fill="#C5C5C5"/></svg>',
49+
collapse: '<svg style="transform: rotate(-90deg);" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M14.207 1.707L13.5 1L7.49997 7L1.49997 1L0.792969 1.707L7.14597 8.061H7.85397L14.207 1.707ZM14.207 7.70688L13.5 6.99988L7.49997 12.9999L1.49997 6.99988L0.792969 7.70688L7.14597 14.0609H7.85397L14.207 7.70688Z"/></svg>'
4950
};
5051

5152
const GIT_FILE_CHANGE_TYPES = { 'A': 'Added', 'M': 'Modified', 'D': 'Deleted', 'R': 'Renamed', 'U': 'Untracked' };

0 commit comments

Comments
 (0)