Skip to content

Commit 34a2e4f

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

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

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

Lines changed: 2 additions & 14 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;
@@ -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)