Skip to content

Commit b399e47

Browse files
committed
channels: add full alias to the pubkey tooltip
1 parent c4b735f commit b399e47

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

app/src/__tests__/components/loop/ChannelRow.spec.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ describe('ChannelRow component', () => {
5555
expect(getByText(channel.aliasLabel)).toBeInTheDocument();
5656
});
5757

58+
it('should display the peer pubkey & alias tooltip', () => {
59+
const { getByText, getAllByText } = render();
60+
channel.alias = 'test-alias';
61+
fireEvent.mouseEnter(getByText(channel.aliasLabel));
62+
expect(getByText(channel.remotePubkey)).toBeInTheDocument();
63+
expect(getAllByText(channel.alias)).toHaveLength(2);
64+
channel.alias = channel.remotePubkey.substring(12);
65+
expect(getByText(channel.remotePubkey)).toBeInTheDocument();
66+
});
67+
5868
it('should display the capacity', () => {
5969
const { getByText } = render();
6070
expect(

app/src/components/loop/ChannelRow.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ const Styled = {
6161
Balance: styled(ChannelBalance)`
6262
margin-top: ${ROW_HEIGHT / 2 - 2}px;
6363
`,
64+
AliasTip: styled.div`
65+
text-align: right;
66+
`,
67+
};
68+
69+
const ChannelAliasTip: React.FC<{ channel: Channel }> = ({ channel }) => {
70+
return (
71+
<Styled.AliasTip>
72+
{channel.aliasDetail.split('\n').map(text => (
73+
<div key={text}>{text}</div>
74+
))}
75+
</Styled.AliasTip>
76+
);
6477
};
6578

6679
export const ChannelRowHeader: React.FC = () => {
@@ -137,7 +150,11 @@ const ChannelRow: React.FC<Props> = ({ channel, style }) => {
137150
<Column cols={1}>{channel.remoteFeeRate}</Column>
138151
<Column cols={1}>{channel.uptimePercent}</Column>
139152
<Column cols={2} ellipse>
140-
<Tip overlay={channel.remotePubkey} placement="left" capitalize={false}>
153+
<Tip
154+
overlay={<ChannelAliasTip channel={channel} />}
155+
placement="left"
156+
capitalize={false}
157+
>
141158
<span>{channel.aliasLabel}</span>
142159
</Tip>
143160
</Column>

app/src/store/models/channel.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,25 @@ export default class Channel {
3737
*/
3838
@computed get aliasLabel() {
3939
// if the node does not specify an alias, it is set to a substring of
40-
// the pubkey. we want to the display the ellipsed pubkey in this case
40+
// the pubkey, we want to the display the ellipsed pubkey in this case
4141
// instead of the substring.
4242
return this.alias && !this.remotePubkey.includes(this.alias as string)
4343
? this.alias
4444
: ellipseInside(this.remotePubkey);
4545
}
4646

47+
/**
48+
* The remotePubkey and alias if one is defined
49+
*/
50+
@computed get aliasDetail() {
51+
// if the node does not specify an alias, it is set to a substring of
52+
// the pubkey, we want to the display just the pubkey. Otherwise,
53+
// display both
54+
return this.alias && !this.remotePubkey.includes(this.alias as string)
55+
? `${this.alias}\n${this.remotePubkey}`
56+
: this.remotePubkey;
57+
}
58+
4759
/**
4860
* The uptime of the channel as a percentage of lifetime
4961
*/

0 commit comments

Comments
 (0)