Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 0f7fb67

Browse files
committed
Update Channel Status Styling
1 parent 9074c0a commit 0f7fb67

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
module.exports = { extends: '@case/eslint-config' }
1+
module.exports = {
2+
extends: '@case/eslint-config',
3+
rules: {
4+
'import/imports-first': 0,
5+
}
6+
}

packages/lightning-core/accounts/ChannelListItem.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const { Menu, MenuItem } = remote
1515
export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
1616
active, status, hover, channelPoint, onShowPopup, onClosePopup, onCloseChannel,
1717
onSuccess, onFetchChannels }) => {
18+
const pending = status === 'pending-open'
19+
|| status === 'pending-closing'
20+
|| status === 'pending-force-closing'
21+
1822
const styles = reactCSS({
1923
'default': {
2024
channel: {
@@ -86,9 +90,9 @@ export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
8690
background: 'light-gray',
8791
},
8892
},
89-
}, { hover, pending: status === 'pending' || status === 'closing' })
93+
}, { hover, pending })
9094

91-
const PROMPT = 'CHANNEL_LIST/PROMPT'
95+
const PROMPT = `CHANNEL_LIST/PROMPT-${ channelPoint }`
9296

9397
// eslint-disable-next-line
9498
const close = ({ channelPoint, force }) => {
@@ -112,13 +116,19 @@ export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
112116
const handleCancel = () => onClosePopup(PROMPT)
113117

114118
const width = `${ (localBalance / capacity) * 100 }%`
119+
const title = {
120+
'open': `CID: ${ id }`,
121+
'pending-open': 'OPENING',
122+
'pending-closing': 'CLOSING',
123+
'pending-force-closing': 'CLOSING',
124+
}[status]
115125

116126
return (
117127
<div style={ styles.channel } onContextMenu={ handleMenu }>
118128
<div style={ styles.split }>
119129
<div style={ styles.id }>
120-
{ status === 'pending' ? 'PENDING' : `CID:${ id }` }
121-
{ status !== 'pending' && status !== 'closing' && (
130+
{ title }
131+
{ !pending && (
122132
<div style={ styles.closeLabel } onClick={ showPopupOrClose }>
123133
<Icon small name="close" />
124134
</div>

packages/lightning-core/accounts/reducer.js

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,55 @@ export const actions = {
114114
[GRPC]: {
115115
method: 'pendingChannels',
116116
types: [null, PENDING_CHANNELS, FETCH_CHANNELS_FAILURE],
117-
schema: data => ({
118-
channels: _.map(data.pending_channels, channel => ({
119-
remotePubkey: channel.identity_key,
120-
id: 'PENDING',
121-
capacity: channel.capacity,
122-
localBalance: channel.local_balance,
123-
remoteBalance: channel.remote_balance,
124-
channelPoint: channel.channel_point,
125-
status: channel.status,
126-
})),
127-
}),
117+
schema: (data) => {
118+
const decorateChannels = (channels, transform) =>
119+
_.map(channels, channel => ({
120+
remotePubkey: channel.remote_node_pub,
121+
capacity: channel.capacity,
122+
localBalance: channel.local_balance,
123+
remoteBalance: channel.remote_balance,
124+
channelPoint: channel.channel_point,
125+
...transform(channel),
126+
}))
127+
128+
return {
129+
channels: [
130+
...decorateChannels(data.pending_open_channels, () => ({ status: 'pending-open' })),
131+
...decorateChannels(data.pending_closing_channels, () => ({ status: 'pending-closing' })),
132+
...decorateChannels(data.pending_force_closing_channels, () => ({ status: 'pending-force-closing' })),
133+
// {
134+
// remotePubkey: '1asd78964b54ad8f8og7a59sfg6s4d7f6g4a538dfs97gsd',
135+
// id: '1925401284578204',
136+
// capacity: '40000',
137+
// localBalance: '4000',
138+
// remoteBalance: '36000',
139+
// channelPoint: '1',
140+
// status: 'open',
141+
// }, {
142+
// remotePubkey: 'asd0fg864a8df79g876adf98g69sd86f7g46s8d68f57gi6',
143+
// capacity: '4000',
144+
// localBalance: '2000',
145+
// remoteBalance: '2000',
146+
// channelPoint: '2',
147+
// status: 'pending-open',
148+
// }, {
149+
// remotePubkey: 'vafgg3zf789s78df97a0s9f867g3s6df5fdgsghafd9hg876ad',
150+
// capacity: '100000',
151+
// localBalance: '90000',
152+
// remoteBalance: '10000',
153+
// channelPoint: '3',
154+
// status: 'pending-closing',
155+
// }, {
156+
// remotePubkey: 'xzcb8976d4bv645z657v6ba6pfdb9s8d7gb537sf6g43b42s3',
157+
// capacity: '4400',
158+
// localBalance: '1900',
159+
// remoteBalance: '2500',
160+
// channelPoint: '4',
161+
// status: 'pending-force-closing',
162+
// },
163+
],
164+
}
165+
},
128166
},
129167
}),
130168
listChannels: () => ({

0 commit comments

Comments
 (0)