@@ -100,6 +100,19 @@ import type { GraphMinimapDaySelectedEventDetail } from './minimap/minimap';
100100import { GlGraphMinimapContainer } from './minimap/minimap-container.react' ;
101101import { GlGraphSideBar } from './sidebar/sidebar.react' ;
102102
103+ function getRemoteIcon ( type : string | number ) {
104+ switch ( type ) {
105+ case 'head' :
106+ return 'vm' ;
107+ case 'remote' :
108+ return 'cloud' ;
109+ case 'tag' :
110+ return 'tag' ;
111+ default :
112+ return '' ;
113+ }
114+ }
115+
103116export interface GraphWrapperProps {
104117 nonce ?: string ;
105118 state : State ;
@@ -873,7 +886,25 @@ export function GraphWrapper({
873886 onChangeColumns ?.( graphColumnsConfig ) ;
874887 } ;
875888
889+ // dirty trick to avoid mutations on the GraphContainer side
890+ const fixedExcludeRefsById = useMemo ( ( ) => ( { ...excludeRefsById } ) , [ excludeRefsById ] ) ;
876891 const handleOnToggleRefsVisibilityClick = ( _event : any , refs : GraphRefOptData [ ] , visible : boolean ) => {
892+ if ( ! visible ) {
893+ document . getElementById ( 'test' ) ?. animate (
894+ [
895+ { offset : 0 , background : 'transparent' } ,
896+ {
897+ offset : 0.4 ,
898+ background : 'var(--vscode-statusBarItem-warningBackground)' ,
899+ } ,
900+ { offset : 1 , background : 'transparent' } ,
901+ ] ,
902+ {
903+ duration : 1000 ,
904+ iterations : ! Object . keys ( fixedExcludeRefsById ?? { } ) . length ? 2 : 1 ,
905+ } ,
906+ ) ;
907+ }
877908 onChangeRefsVisibility ?.( refs , visible ) ;
878909 } ;
879910
@@ -1029,6 +1060,8 @@ export function GraphWrapper({
10291060 onChangeSelection ?.( rows ) ;
10301061 } ;
10311062
1063+ const hasExcludedRefs = excludeRefsById && Object . keys ( excludeRefsById ) . length ;
1064+
10321065 return (
10331066 < >
10341067 < header className = "titlebar graph-app__header" >
@@ -1347,6 +1380,59 @@ export function GraphWrapper({
13471380 < SlOption value = "current" > Current Branch</ SlOption >
13481381 </ SlSelect >
13491382 </ GlTooltip >
1383+ < div className = { `shrink ${ ! Object . values ( excludeRefsById ?? { } ) . length && 'hidden' } ` } >
1384+ < GlPopover
1385+ className = "popover"
1386+ placement = "bottom-start"
1387+ trigger = "click focus"
1388+ arrow = { false }
1389+ distance = { 0 }
1390+ >
1391+ < GlTooltip placement = "top" slot = "anchor" >
1392+ < button type = "button" id = "test" className = "action-button" >
1393+ < CodeIcon icon = { `eye` } />
1394+ { Object . values ( excludeRefsById ?? { } ) . length }
1395+ < CodeIcon
1396+ className = "action-button__more"
1397+ icon = "chevron-down"
1398+ aria-hidden = "true"
1399+ />
1400+ </ button >
1401+ < span slot = "content" > Hidden branches</ span >
1402+ </ GlTooltip >
1403+ < div slot = "content" >
1404+ < MenuLabel > Hidden branches</ MenuLabel >
1405+ { hasExcludedRefs &&
1406+ [ ...Object . values ( excludeRefsById ) , null ] . map ( ref =>
1407+ ref ? (
1408+ < MenuItem
1409+ // key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
1410+ onClick = { event => {
1411+ handleOnToggleRefsVisibilityClick ( event , [ ref ] , true ) ;
1412+ } }
1413+ className = "flex-gap"
1414+ >
1415+ < CodeIcon icon = { getRemoteIcon ( ref . type ) } > </ CodeIcon >
1416+ < span > { ref . name } </ span >
1417+ </ MenuItem >
1418+ ) : (
1419+ // One more weird case. If I render it outside the listed items, the dropdown is hidden after click on the last item
1420+ < MenuItem
1421+ onClick = { event => {
1422+ handleOnToggleRefsVisibilityClick (
1423+ event ,
1424+ Object . values ( excludeRefsById ?? { } ) ,
1425+ true ,
1426+ ) ;
1427+ } }
1428+ >
1429+ Show all
1430+ </ MenuItem >
1431+ ) ,
1432+ ) }
1433+ </ div >
1434+ </ GlPopover >
1435+ </ div >
13501436 < GlPopover
13511437 className = "popover"
13521438 placement = "bottom-start"
0 commit comments