Skip to content

Commit 603babf

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

File tree

3 files changed

+75
-28
lines changed

3 files changed

+75
-28
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: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ import ChannelIcon from './ChannelIcon';
1717
*/
1818
export const ROW_HEIGHT = 60;
1919

20+
const BaseColumn = styled(Column)`
21+
white-space: nowrap;
22+
line-height: ${ROW_HEIGHT}px;
23+
padding-left: 5px;
24+
padding-right: 5px;
25+
`;
26+
2027
const Styled = {
2128
Row: styled(Row)<{ dimmed?: boolean; selectable?: boolean }>`
2229
border-bottom: 0.5px solid ${props => props.theme.colors.darkGray};
@@ -35,43 +42,55 @@ const Styled = {
3542
}
3643
`}
3744
`,
38-
Column: styled(Column)<{ last?: boolean; ellipse?: boolean }>`
39-
white-space: nowrap;
40-
line-height: ${ROW_HEIGHT}px;
41-
padding-left: 5px;
45+
Column: styled(BaseColumn)<{ last?: boolean }>`
4246
padding-right: ${props => (props.last ? '15' : '5')}px;
43-
${props =>
44-
props.ellipse &&
45-
`
46-
overflow: hidden;
47-
text-overflow: ellipsis;
48-
`}
47+
`,
48+
ActionColumn: styled(BaseColumn)`
49+
max-width: 50px;
50+
padding-left: 24px;
51+
`,
52+
WideColumn: styled(BaseColumn)`
53+
overflow: hidden;
54+
text-overflow: ellipsis;
55+
56+
@media (min-width: 1200px) and (max-width: 1300px) {
57+
max-width: 20%;
58+
}
4959
`,
5060
StatusIcon: styled.span`
51-
float: left;
52-
margin-top: -1px;
53-
margin-left: 15px;
5461
color: ${props => props.theme.colors.pink};
5562
`,
5663
Check: styled(Checkbox)`
57-
float: left;
58-
margin-top: 18px;
59-
margin-left: 10px;
64+
margin-top: 17px;
6065
`,
6166
Balance: styled(ChannelBalance)`
6267
margin-top: ${ROW_HEIGHT / 2 - 2}px;
6368
`,
69+
AliasTip: styled.div`
70+
text-align: right;
71+
`,
72+
};
73+
74+
const ChannelAliasTip: React.FC<{ channel: Channel }> = ({ channel }) => {
75+
return (
76+
<Styled.AliasTip>
77+
{channel.aliasDetail.split('\n').map(text => (
78+
<div key={text}>{text}</div>
79+
))}
80+
</Styled.AliasTip>
81+
);
6482
};
6583

6684
export const ChannelRowHeader: React.FC = () => {
6785
const { l } = usePrefixedTranslation('cmps.loop.ChannelRowHeader');
68-
const { Column } = Styled;
86+
const { Column, ActionColumn, WideColumn } = Styled;
6987
return (
7088
<Row>
89+
<ActionColumn></ActionColumn>
7190
<Column right>
7291
<HeaderFour>{l('canReceive')}</HeaderFour>
7392
</Column>
74-
<Column cols={2} colsXl={3}></Column>
93+
<WideColumn cols={2} colsXl={3}></WideColumn>
7594
<Column>
7695
<HeaderFour>{l('canSend')}</HeaderFour>
7796
</Column>
@@ -83,9 +102,9 @@ export const ChannelRowHeader: React.FC = () => {
83102
<Column cols={1}>
84103
<HeaderFour>{l('upTime')}</HeaderFour>
85104
</Column>
86-
<Column cols={2}>
105+
<WideColumn cols={2}>
87106
<HeaderFour>{l('peer')}</HeaderFour>
88-
</Column>
107+
</WideColumn>
89108
<Column right last>
90109
<HeaderFour>{l('capacity')}</HeaderFour>
91110
</Column>
@@ -110,37 +129,43 @@ const ChannelRow: React.FC<Props> = ({ channel, style }) => {
110129
store.buildSwapStore.toggleSelectedChannel(channel.chanId);
111130
};
112131

113-
const { Row, Column, StatusIcon, Check, Balance } = Styled;
132+
const { Row, Column, ActionColumn, WideColumn, StatusIcon, Check, Balance } = Styled;
114133
return (
115134
<Row
116135
dimmed={dimmed}
117136
style={style}
118137
selectable={editable && !disabled}
119138
onClick={editable && !disabled ? handleRowChecked : undefined}
120139
>
121-
<Column right>
140+
<ActionColumn>
122141
{editable ? (
123142
<Check checked={checked} disabled={disabled} />
124143
) : (
125144
<StatusIcon>
126145
<ChannelIcon channel={channel} />
127146
</StatusIcon>
128147
)}
148+
</ActionColumn>
149+
<Column right>
129150
<Unit sats={channel.remoteBalance} suffix={false} />
130151
</Column>
131-
<Column cols={2} colsXl={3}>
152+
<WideColumn cols={2} colsXl={3}>
132153
<Balance channel={channel} />
133-
</Column>
154+
</WideColumn>
134155
<Column>
135156
<Unit sats={channel.localBalance} suffix={false} />
136157
</Column>
137158
<Column cols={1}>{channel.remoteFeeRate}</Column>
138159
<Column cols={1}>{channel.uptimePercent}</Column>
139-
<Column cols={2} ellipse>
140-
<Tip overlay={channel.remotePubkey} placement="left" capitalize={false}>
160+
<WideColumn cols={2}>
161+
<Tip
162+
overlay={<ChannelAliasTip channel={channel} />}
163+
placement="left"
164+
capitalize={false}
165+
>
141166
<span>{channel.aliasLabel}</span>
142167
</Tip>
143-
</Column>
168+
</WideColumn>
144169
<Column right>
145170
<Unit sats={channel.capacity} suffix={false} />
146171
</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)