11import { ReactElement , useContext } from 'react'
22import { Button } from '@material-ui/core'
3+ import { Globe , Briefcase , Search , Settings , ArrowUp , RefreshCcw } from 'react-feather'
34
4- import TroubleshootConnectionCard from '../../components/TroubleshootConnectionCard '
5- import { CheckState , Context as BeeContext } from '../../providers/Bee '
6- import ExpandableList from '../../components/ExpandableList '
5+ import { Context as BeeContext } from '../../providers/Bee '
6+ import Card from '../../components/Card '
7+ import Map from '../../components/Map '
78import ExpandableListItem from '../../components/ExpandableListItem'
8- import ExpandableListItemKey from '../../components/ExpandableListItemKey '
9- import TopologyStats from '../../components/TopologyStats '
9+ import { useNavigate } from 'react-router '
10+ import { ROUTES } from '../../routes '
1011
1112export default function Status ( ) : ReactElement {
1213 const {
@@ -15,48 +16,123 @@ export default function Status(): ReactElement {
1516 isLatestBeeVersion,
1617 latestBeeVersionUrl,
1718 topology,
18- nodeAddresses,
19- chequebookAddress,
2019 nodeInfo,
20+ balance,
21+ chequebookBalance,
2122 } = useContext ( BeeContext )
22-
23- if ( status . all === CheckState . ERROR ) return < TroubleshootConnectionCard />
23+ const navigate = useNavigate ( )
2424
2525 return (
2626 < div >
27- < ExpandableList label = "Bee Node" defaultOpen >
28- < ExpandableListItem label = "Mode" value = { nodeInfo ?. beeMode } />
29- < ExpandableListItem
30- label = "Agent"
31- value = {
32- < div >
33- < a href = "https://github.com/ethersphere/bee" rel = "noreferrer" target = "_blank" >
34- Bee
35- </ a >
36- { ` ${ latestUserVersion || '-' } ` }
37- < Button size = "small" variant = "outlined" href = { latestBeeVersionUrl } target = "_blank" >
27+ < div style = { { display : 'flex' , justifyContent : 'space-between' , alignItems : 'stretch' , alignContent : 'stretch' } } >
28+ { status . all ? (
29+ < Card
30+ buttonProps = { { iconType : Search , children : 'Access Content' , onClick : ( ) => navigate ( ROUTES . DOWNLOAD ) } }
31+ icon = { < Globe /> }
32+ title = "Your node is connected."
33+ subtitle = "You can now access content hosted on Swarm."
34+ status = "ok"
35+ />
36+ ) : (
37+ < Card
38+ buttonProps = { { iconType : Settings , children : 'Open node setup' , onClick : ( ) => navigate ( ROUTES . STATUS ) } }
39+ icon = { < Globe /> }
40+ title = "Your node is not connected…"
41+ subtitle = "You’re not connected to Swarm."
42+ status = "error"
43+ />
44+ ) }
45+ < div style = { { width : '8px' } } > </ div >
46+ { nodeInfo ?. beeMode && [ 'light' , 'full' , 'dev' ] . includes ( nodeInfo . beeMode ) ? (
47+ < Card
48+ buttonProps = { {
49+ iconType : Briefcase ,
50+ children : 'Manage your wallet' ,
51+ onClick : ( ) => navigate ( ROUTES . ACCOUNT_WALLET ) ,
52+ } }
53+ icon = { < Briefcase /> }
54+ title = { `${ balance ?. bzz . toSignificantDigits ( 4 ) } xBZZ | ${ balance ?. dai . toSignificantDigits ( 4 ) } xDAI` }
55+ subtitle = "Current wallet balance."
56+ status = "ok"
57+ />
58+ ) : (
59+ < Card
60+ buttonProps = { {
61+ iconType : Settings ,
62+ children : 'Setup wallet' ,
63+ onClick : ( ) => navigate ( ROUTES . WALLET ) ,
64+ } }
65+ icon = { < ArrowUp /> }
66+ title = "Your wallet is not setup."
67+ subtitle = "To share content on Swarm, please setup your wallet."
68+ status = "error"
69+ />
70+ ) }
71+ { nodeInfo ?. beeMode && [ 'light' , 'full' , 'dev' ] . includes ( nodeInfo . beeMode ) && (
72+ < >
73+ < div style = { { width : '8px' } } />
74+ { chequebookBalance ?. availableBalance !== undefined &&
75+ chequebookBalance ?. availableBalance . toBigNumber . isGreaterThan ( 0 ) ? (
76+ < Card
77+ buttonProps = { {
78+ iconType : RefreshCcw ,
79+ children : 'View chequebook' ,
80+ onClick : ( ) => navigate ( ROUTES . ACCOUNT_CHEQUEBOOK ) ,
81+ } }
82+ icon = { < RefreshCcw /> }
83+ title = { `${ chequebookBalance ?. availableBalance . toSignificantDigits ( 4 ) } xBZZ` }
84+ subtitle = "Your chequebook is setup and has balance"
85+ status = "ok"
86+ />
87+ ) : (
88+ < Card
89+ buttonProps = { {
90+ iconType : RefreshCcw ,
91+ children : 'View chequebook' ,
92+ onClick : ( ) => navigate ( ROUTES . ACCOUNT_CHEQUEBOOK ) ,
93+ } }
94+ icon = { < RefreshCcw /> }
95+ title = {
96+ chequebookBalance ?. availableBalance
97+ ? `${ chequebookBalance . availableBalance . toFixedDecimal ( 4 ) } xBZZ`
98+ : 'No available balance'
99+ }
100+ subtitle = "Your chequebook is not setup or has no balance."
101+ status = "error"
102+ />
103+ ) }
104+ </ >
105+ ) }
106+ </ div >
107+ < div style = { { height : '16px' } } />
108+ < Map />
109+ < div style = { { height : '2px' } } />
110+ < ExpandableListItem label = "Connected peers" value = { topology ?. connected ?? '-' } />
111+ < ExpandableListItem label = "Depth" value = { topology ?. depth ?? '-' } />
112+ < div style = { { height : '16px' } } />
113+ < ExpandableListItem
114+ label = "Bee version"
115+ value = {
116+ < div >
117+ < a href = "https://github.com/ethersphere/bee" rel = "noreferrer" target = "_blank" >
118+ Bee
119+ </ a >
120+ { ` ${ latestUserVersion ?? '-' } ` }
121+ { latestUserVersion && (
122+ < Button
123+ size = "small"
124+ variant = "outlined"
125+ href = { latestBeeVersionUrl }
126+ target = "_blank"
127+ style = { { height : '26px' } }
128+ >
38129 { isLatestBeeVersion ? 'latest' : 'update' }
39130 </ Button >
40- </ div >
41- }
42- />
43- < ExpandableListItemKey label = "Public key" value = { nodeAddresses ?. publicKey || '' } />
44- < ExpandableListItemKey label = "PSS public key" value = { nodeAddresses ?. pssPublicKey || '' } />
45- < ExpandableListItemKey label = "Overlay address (Peer ID)" value = { nodeAddresses ?. overlay || '' } />
46-
47- < ExpandableList level = { 1 } label = "Underlay addresses" >
48- { nodeAddresses ?. underlay . map ( addr => (
49- < ExpandableListItem key = { addr } value = { addr } />
50- ) ) }
51- </ ExpandableList >
52- </ ExpandableList >
53- < ExpandableList label = "Blockchain" defaultOpen >
54- < ExpandableListItemKey label = "Ethereum address" value = { nodeAddresses ?. ethereum || '' } />
55- < ExpandableListItemKey label = "Chequebook contract address" value = { chequebookAddress ?. chequebookAddress || '' } />
56- </ ExpandableList >
57- < ExpandableList label = "Connectivity" defaultOpen >
58- < TopologyStats topology = { topology } />
59- </ ExpandableList >
131+ ) }
132+ </ div >
133+ }
134+ />
135+ < ExpandableListItem label = "Mode" value = { nodeInfo ?. beeMode } />
60136 </ div >
61137 )
62138}
0 commit comments