@@ -98,21 +98,10 @@ import { GitActionsButtons } from './actions/gitActionsButtons';
98
98
import { GlGraphHover } from './hover/graphHover.react' ;
99
99
import type { GraphMinimapDaySelectedEventDetail } from './minimap/minimap' ;
100
100
import { GlGraphMinimapContainer } from './minimap/minimap-container.react' ;
101
+ import { compareGraphRefOpts } from './refHelpers/compareGraphRefOpts' ;
102
+ import { RemoteIcon } from './refHelpers/RemoteIcon' ;
101
103
import { GlGraphSideBar } from './sidebar/sidebar.react' ;
102
104
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
-
116
105
export interface GraphWrapperProps {
117
106
nonce ?: string ;
118
107
state : State ;
@@ -1406,33 +1395,39 @@ export function GraphWrapper({
1406
1395
< MenuLabel > Hidden Branches / Tags</ MenuLabel >
1407
1396
{ excludeRefsById &&
1408
1397
Object . keys ( excludeRefsById ) . length &&
1409
- [ ...Object . values ( excludeRefsById ) , null ] . map ( ref =>
1410
- ref ? (
1411
- < MenuItem
1412
- // key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
1413
- onClick = { event => {
1414
- handleOnToggleRefsVisibilityClick ( event , [ ref ] , true ) ;
1415
- } }
1416
- className = "flex-gap"
1417
- >
1418
- < CodeIcon icon = { getRemoteIcon ( ref . type ) } > </ CodeIcon >
1419
- < span > { ref . name } </ span >
1420
- </ MenuItem >
1421
- ) : (
1422
- // One more weird case. If I render it outside the listed items, the dropdown is hidden after click on the last item
1423
- < MenuItem
1424
- onClick = { event => {
1425
- handleOnToggleRefsVisibilityClick (
1426
- event ,
1427
- Object . values ( excludeRefsById ?? { } ) ,
1428
- true ,
1429
- ) ;
1430
- } }
1431
- >
1432
- Show All
1433
- </ MenuItem >
1434
- ) ,
1435
- ) }
1398
+ (
1399
+ Object . values ( excludeRefsById )
1400
+ . slice ( )
1401
+ . sort ( compareGraphRefOpts ) as Array < GraphRefOptData | null >
1402
+ )
1403
+ . concat ( null )
1404
+ . map ( ref =>
1405
+ ref ? (
1406
+ < MenuItem
1407
+ // key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
1408
+ onClick = { event => {
1409
+ handleOnToggleRefsVisibilityClick ( event , [ ref ] , true ) ;
1410
+ } }
1411
+ className = "flex-gap"
1412
+ >
1413
+ < RemoteIcon refOptData = { ref } />
1414
+ < span > { ref . name } </ span >
1415
+ </ MenuItem >
1416
+ ) : (
1417
+ // One more weird case. If I render it outside the listed items, the dropdown is hidden after click on the last item
1418
+ < MenuItem
1419
+ onClick = { event => {
1420
+ handleOnToggleRefsVisibilityClick (
1421
+ event ,
1422
+ Object . values ( excludeRefsById ?? { } ) ,
1423
+ true ,
1424
+ ) ;
1425
+ } }
1426
+ >
1427
+ Show All
1428
+ </ MenuItem >
1429
+ ) ,
1430
+ ) }
1436
1431
</ div >
1437
1432
</ GlPopover >
1438
1433
</ div >
0 commit comments