Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PerfectScrollbar from 'react-perfect-scrollbar';
import { Spinner, Card, Row, Col, ProgressBar, OverlayTrigger, Tooltip } from 'react-bootstrap';

import { copyTextToClipboard, formatCurrency, titleCase } from '../../../utilities/data-formatters';
import { CallStatus, CLEAR_STATUS_ALERT_DELAY, Units } from '../../../utilities/constants';
import { CallStatus, channelStateMap, CLEAR_STATUS_ALERT_DELAY, Units } from '../../../utilities/constants';
import { ActionSVG } from '../../../svgs/Action';
import { CloseSVG } from '../../../svgs/Close';
import StatusAlert from '../../shared/StatusAlert/StatusAlert';
Expand Down Expand Up @@ -119,7 +119,7 @@ const ChannelDetails = (props) => {
<OverlayTrigger
placement='auto'
delay={{ show: 250, hide: 250 }}
overlay={<Tooltip>{titleCase(props.selChannel.current_state)}</Tooltip>}
overlay={<Tooltip>{titleCase(props.selChannel.current_state) + ' - ' + (channelStateMap[props.selChannel.state] ?? titleCase(props.selChannel.state?.replaceAll('_', ' ')))}</Tooltip>}
>
<span className='d-flex align-items-center justify-content-start fw-bold'>
<div className={'d-inline-block mx-1 dot ' + (props.selChannel.current_state?.toLowerCase() === 'active' ? 'bg-success' : props.selChannel.current_state?.toLowerCase() === 'pending' ? 'bg-warning' : 'bg-danger')}></div>
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/components/cln/Channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Spinner, Card, Row, Col, ListGroup, Alert, ProgressBar, OverlayTrigger,

import { titleCase } from '../../../utilities/data-formatters';
import { ActionSVG } from '../../../svgs/Action';
import { STAGERRED_SPRING_VARIANTS_3 } from '../../../utilities/constants';
import { channelStateMap, STAGERRED_SPRING_VARIANTS_3 } from '../../../utilities/constants';
import { NoChannelLightSVG } from '../../../svgs/NoChannelLight';
import { NoChannelDarkSVG } from '../../../svgs/NoChannelDark';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -45,7 +45,7 @@ const Channels = (props) => {
<OverlayTrigger
placement='auto'
delay={{ show: 250, hide: 250 }}
overlay={<Tooltip>{titleCase(channel.current_state)}</Tooltip>}
overlay={<Tooltip>{titleCase(channel.current_state) + ' - ' + (channelStateMap[channel.state] ?? titleCase(channel.state?.replaceAll('_', ' ')))}</Tooltip>}
>
<span data-testid='channel-node-alias'>
<div className={'d-inline-block mx-1 dot ' + (channel.current_state?.toLowerCase() === 'active' ? 'bg-success' : channel.current_state?.toLowerCase() === 'pending' ? 'bg-warning' : 'bg-danger')}></div>
Expand Down
16 changes: 16 additions & 0 deletions apps/frontend/src/utilities/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ export enum ApplicationModes {
DARK = 'DARK',
}

export const channelStateMap: Record<string, string> = {
OPENINGD: "Opening",
CHANNELD_AWAITING_LOCKIN: "Awaiting Lock-In",
CHANNELD_SHUTTING_DOWN: "Shutting Down",
CLOSINGD_SIGEXCHANGE: "Closing Signature Exchange",
CLOSINGD_COMPLETE: "Closing Complete",
AWAITING_UNILATERAL: "Awaiting Unilateral",
FUNDING_SPEND_SEEN: "Funding Spend Seen",
ONCHAIN: "On-Chain",
DUALOPEND_OPEN_INIT: "Dual Open Initialized",
DUALOPEND_AWAITING_LOCKIN: "Dual Open Awaiting Lock-In",
CHANNELD_AWAITING_SPLICE: "Awaiting Splice",
DUALOPEND_OPEN_COMMITTED: "Dual Open Committed",
DUALOPEND_OPEN_COMMIT_READY: "Dual Open Commit Ready",
};

export const CURRENCY_UNITS = ['SATS', 'BTC'];

export const CURRENCY_UNIT_FORMATS = { Sats: '1.0-0', BTC: '1.6-6', OTHER: '1.2-2' };
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/utilities/data-formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export const sortDescByKey = (array, key) => {
};

export const titleCase = (str: string | undefined) => {
return str && typeof str === 'string' ? str[0].toUpperCase() + str.substring(1).toLowerCase() : '';
if (!str || typeof str !== 'string') return '';
return str.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase());
};

export const copyTextToClipboard = (textToCopy: string | undefined) => {
Expand Down