@@ -99,19 +99,8 @@ import { GlGraphHover } from './hover/graphHover.react';
9999import type { GraphMinimapDaySelectedEventDetail } from './minimap/minimap' ;
100100import { GlGraphMinimapContainer } from './minimap/minimap-container.react' ;
101101import { GlGraphSideBar } from './sidebar/sidebar.react' ;
102-
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- }
102+ import { compareGraphRefOpts } from './utils/compareGraphRefOpts' ;
103+ import { RemoteIcon } from './utils/RemoteIcon' ;
115104
116105export interface GraphWrapperProps {
117106 nonce ?: string ;
@@ -1402,33 +1391,39 @@ export function GraphWrapper({
14021391 < MenuLabel > Hidden Branches / Tags</ MenuLabel >
14031392 { excludeRefsById &&
14041393 Object . keys ( excludeRefsById ) . length &&
1405- [ ...Object . values ( excludeRefsById ) , null ] . map ( ref =>
1406- ref ? (
1407- < MenuItem
1408- // key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
1409- onClick = { event => {
1410- handleOnToggleRefsVisibilityClick ( event , [ ref ] , true ) ;
1411- } }
1412- className = "flex-gap"
1413- >
1414- < CodeIcon icon = { getRemoteIcon ( ref . type ) } > </ CodeIcon >
1415- < span > { ref . name } </ span >
1416- </ MenuItem >
1417- ) : (
1418- // One more weird case. If I render it outside the listed items, the dropdown is hidden after click on the last item
1419- < MenuItem
1420- onClick = { event => {
1421- handleOnToggleRefsVisibilityClick (
1422- event ,
1423- Object . values ( excludeRefsById ?? { } ) ,
1424- true ,
1425- ) ;
1426- } }
1427- >
1428- Show All
1429- </ MenuItem >
1430- ) ,
1431- ) }
1394+ (
1395+ Object . values ( excludeRefsById )
1396+ . slice ( )
1397+ . sort ( compareGraphRefOpts ) as Array < GraphRefOptData | null >
1398+ )
1399+ . concat ( null )
1400+ . map ( ref =>
1401+ ref ? (
1402+ < MenuItem
1403+ // key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
1404+ onClick = { event => {
1405+ handleOnToggleRefsVisibilityClick ( event , [ ref ] , true ) ;
1406+ } }
1407+ className = "flex-gap"
1408+ >
1409+ < RemoteIcon refOptData = { ref } />
1410+ < span > { ref . name } </ span >
1411+ </ MenuItem >
1412+ ) : (
1413+ // One more weird case. If I render it outside the listed items, the dropdown is hidden after click on the last item
1414+ < MenuItem
1415+ onClick = { event => {
1416+ handleOnToggleRefsVisibilityClick (
1417+ event ,
1418+ Object . values ( excludeRefsById ?? { } ) ,
1419+ true ,
1420+ ) ;
1421+ } }
1422+ >
1423+ Show All
1424+ </ MenuItem >
1425+ ) ,
1426+ ) }
14321427 </ div >
14331428 </ GlPopover >
14341429 </ div >
0 commit comments