Skip to content

Commit d0564d9

Browse files
committed
Adds avatarUrl handling to the hidden refs popover
1 parent f884fc6 commit d0564d9

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,7 @@ import { GlGraphHover } from './hover/graphHover.react';
9999
import type { GraphMinimapDaySelectedEventDetail } from './minimap/minimap';
100100
import { GlGraphMinimapContainer } from './minimap/minimap-container.react';
101101
import { 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 { RemoteIcon } from './utils/RemoteIcon';
115103

116104
export interface GraphWrapperProps {
117105
nonce?: string;
@@ -1402,7 +1390,7 @@ export function GraphWrapper({
14021390
<MenuLabel>Hidden Branches / Tags</MenuLabel>
14031391
{excludeRefsById &&
14041392
Object.keys(excludeRefsById).length &&
1405-
[...Object.values(excludeRefsById), null].map(ref =>
1393+
[...Object.values(excludeRefsById), null].map((ref, i) =>
14061394
ref ? (
14071395
<MenuItem
14081396
// key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
@@ -1411,7 +1399,7 @@ export function GraphWrapper({
14111399
}}
14121400
className="flex-gap"
14131401
>
1414-
<CodeIcon icon={getRemoteIcon(ref.type)}></CodeIcon>
1402+
<RemoteIcon ref={ref} />
14151403
<span>{ref.name}</span>
14161404
</MenuItem>
14171405
) : (
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { GraphRefOptData } from '@gitkraken/gitkraken-components';
2+
import React from 'react';
3+
import { CodeIcon } from '../../../shared/components/code-icon.react';
4+
5+
// eslint-disable-next-line @typescript-eslint/naming-convention
6+
export function RemoteIcon({ ref }: Readonly<{ ref: GraphRefOptData }>) {
7+
if (ref.avatarUrl) {
8+
return <img alt={ref.name} style={{ width: 14, aspectRatio: 1 }} src={ref.avatarUrl} />;
9+
}
10+
let icon = '';
11+
switch (ref.type) {
12+
case 'head':
13+
icon = 'vm';
14+
break;
15+
case 'remote':
16+
icon = 'cloud';
17+
break;
18+
case 'tag':
19+
icon = 'tag';
20+
break;
21+
default:
22+
break;
23+
}
24+
return <CodeIcon size={14} icon={icon} />;
25+
}

0 commit comments

Comments
 (0)