@@ -14,7 +14,7 @@ import type {
1414} from '@gitkraken/gitkraken-components' ;
1515import GraphContainer , { CommitDateTimeSources , refZone } from '@gitkraken/gitkraken-components' ;
1616import { VSCodeCheckbox , VSCodeRadio , VSCodeRadioGroup } from '@vscode/webview-ui-toolkit/react' ;
17- import type { FormEvent , ReactElement } from 'react' ;
17+ import type { FormEvent , MouseEvent , ReactElement } from 'react' ;
1818import React , { createElement , useEffect , useMemo , useRef , useState } from 'react' ;
1919import { getPlatform } from '@env/platform' ;
2020import type { DateStyle } from '../../../../config' ;
@@ -62,6 +62,8 @@ import { pluralize } from '../../../../system/string';
6262import { createWebviewCommandLink } from '../../../../system/webview' ;
6363import type { IpcNotification } from '../../../protocol' ;
6464import { DidChangeHostWindowFocusNotification } from '../../../protocol' ;
65+ import { GlButton } from '../../shared/components/button.react' ;
66+ import { CodeIcon } from '../../shared/components/code-icon.react' ;
6567import { MenuDivider , MenuItem , MenuLabel , MenuList } from '../../shared/components/menu/react' ;
6668import { PopMenu } from '../../shared/components/overlays/pop-menu/react' ;
6769import { GlPopover } from '../../shared/components/overlays/popover.react' ;
@@ -86,6 +88,7 @@ export interface GraphWrapperProps {
8688 onDoubleClickRef ?: ( ref : GraphRef , metadata ?: GraphRefMetadataItem ) => void ;
8789 onDoubleClickRow ?: ( row : GraphRow , preserveFocus ?: boolean ) => void ;
8890 onHoverRowPromise ?: ( row : GraphRow ) => Promise < DidGetRowHoverParams | undefined > ;
91+ onJumpToRefPromise ?: ( alt : boolean ) => Promise < { name : string ; sha : string } | undefined > ;
8992 onMissingAvatars ?: ( emails : Record < string , string > ) => void ;
9093 onMissingRefsMetadata ?: ( metadata : GraphMissingRefsMetadata ) => void ;
9194 onMoreRows ?: ( id ?: string ) => void ;
@@ -210,6 +213,7 @@ export function GraphWrapper({
210213 onDoubleClickRow,
211214 onEnsureRowPromise,
212215 onHoverRowPromise,
216+ onJumpToRefPromise,
213217 onMissingAvatars,
214218 onMissingRefsMetadata,
215219 onMoreRows,
@@ -702,6 +706,16 @@ export function GraphWrapper({
702706 onChooseRepository ?.( ) ;
703707 } ;
704708
709+ const handleJumpToRef = async ( e : MouseEvent ) => {
710+ const ref = await onJumpToRefPromise ?.( e . altKey ) ;
711+ if ( ref != null ) {
712+ const sha = await ensureSearchResultRow ( ref . sha ) ;
713+ if ( sha == null ) return ;
714+
715+ queueMicrotask ( ( ) => graphRef . current ?. selectCommits ( [ sha ] , false , true ) ) ;
716+ }
717+ } ;
718+
705719 const handleFilterChange = ( e : Event | FormEvent < HTMLElement > ) => {
706720 const $el = e . target as HTMLInputElement ;
707721
@@ -1202,6 +1216,14 @@ export function GraphWrapper({
12021216 </ span >
12031217 </ div >
12041218 </ GlPopover >
1219+ < GlButton appearance = "toolbar" onClick = { handleJumpToRef } >
1220+ < CodeIcon icon = "target" > </ CodeIcon >
1221+ < span slot = "tooltip" >
1222+ Jump to HEAD
1223+ < br />
1224+ [Alt] Jump to Reference...
1225+ </ span >
1226+ </ GlButton >
12051227 < span >
12061228 < span className = "codicon codicon-chevron-right" > </ span >
12071229 </ span >
0 commit comments