From 4f2d202fdc35e3ec80d4f8d5c0783c26638f0174 Mon Sep 17 00:00:00 2001 From: Tim Hutt Date: Thu, 27 Apr 2023 15:01:03 +0100 Subject: [PATCH] Add "show HEAD" button When clicked it jumps to the currently checked out commit. --- src/gitGraphView.ts | 1 + web/main.ts | 16 +++++++++++++++- web/styles/main.css | 16 +++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/gitGraphView.ts b/src/gitGraphView.ts index 1acba6ff..9ca02fb8 100644 --- a/src/gitGraphView.ts +++ b/src/gitGraphView.ts @@ -721,6 +721,7 @@ export class GitGraphView extends Disposable { Repo: Branches: +
diff --git a/web/main.ts b/web/main.ts index 29c23c82..8b191c5b 100644 --- a/web/main.ts +++ b/web/main.ts @@ -145,7 +145,21 @@ class GitGraphView { this.requestLoadRepoInfoAndCommits(false, false); } - const fetchBtn = document.getElementById('fetchBtn')!, findBtn = document.getElementById('findBtn')!, settingsBtn = document.getElementById('settingsBtn')!, terminalBtn = document.getElementById('terminalBtn')!; + const headBtn = document.getElementById('headBtn')!; + const fetchBtn = document.getElementById('fetchBtn')!; + const findBtn = document.getElementById('findBtn')!; + const settingsBtn = document.getElementById('settingsBtn')!; + const terminalBtn = document.getElementById('terminalBtn')!; + + headBtn.innerHTML = SVG_ICONS.eyeOpen; + headBtn.addEventListener('click', () => { + const headDots = document.getElementsByClassName('commitHeadDot'); + if (headDots.length === 1) { + // Scroll its parent (the commit row) into view. If you just + // scroll the dot into view it chops off part of the row. + headDots[0].parentElement?.scrollIntoView(); + } + }); fetchBtn.title = 'Fetch' + (this.config.fetchAndPrune ? ' & Prune' : '') + ' from Remote(s)'; fetchBtn.innerHTML = SVG_ICONS.download; fetchBtn.addEventListener('click', () => this.fetchFromRemotesAction()); diff --git a/web/styles/main.css b/web/styles/main.css index 8c30d495..ce9dd47f 100644 --- a/web/styles/main.css +++ b/web/styles/main.css @@ -812,7 +812,7 @@ body.tagLabelsRightAligned .gitRef.tag{ max-width:40vw; } -#findBtn, #terminalBtn, #settingsBtn, #fetchBtn, #refreshBtn{ +#headBtn, #findBtn, #terminalBtn, #settingsBtn, #fetchBtn, #refreshBtn{ position:absolute; top:50%; width:20px; @@ -822,6 +822,9 @@ body.tagLabelsRightAligned .gitRef.tag{ -webkit-user-select:none; user-select:none; } +#headBtn{ + right:130px; +} #findBtn{ right:100px; } @@ -841,7 +844,7 @@ body.tagLabelsRightAligned .gitRef.tag{ #refreshBtn.refreshing{ cursor:default; } -#findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg, #refreshBtn svg{ +#headBtn svg, #findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg, #refreshBtn svg{ position:absolute; fill:var(--vscode-editor-foreground); opacity:0.8; @@ -852,14 +855,14 @@ body.tagLabelsRightAligned .gitRef.tag{ #findBtn svg, #terminalBtn svg{ stroke-width:0.5px; } -#findBtn:hover svg, #terminalBtn:hover svg, #settingsBtn:hover svg, #fetchBtn:hover svg, #refreshBtn:hover svg{ +#headBtn:hover svg, #findBtn:hover svg, #terminalBtn:hover svg, #settingsBtn:hover svg, #fetchBtn:hover svg, #refreshBtn:hover svg{ opacity:1; stroke-width:0.5px; } #findBtn:hover svg, #terminalBtn:hover svg{ stroke-width:1px; } -#findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg{ +#headBtn svg, #findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg{ left:1px; top:1px; width:18px !important; @@ -882,6 +885,9 @@ body.tagLabelsRightAligned .gitRef.tag{ #controls.fetchSupported{ padding-right:162px; } +#controls.fetchSupported #headBtn{ + right:160px; +} #controls.fetchSupported #findBtn{ right:130px; } @@ -1020,4 +1026,4 @@ label > input[type=radio]:checked ~ .customRadio:after{ #commitGraph, #commitTable th, #commitTable td, .gitRef, #loadingHeader, .unselectable, .roundedBtn, #controls label{ -webkit-user-select:none; user-select:none; -} \ No newline at end of file +}