feat: optional status checks (e.g. connected peers > 0 or funded chequebook) (#331)
* feat: make some check optional (e.g. connected peers > 0 or funded chequebook) * fix: alter setup step text to better describe what needs to be done * refactor: rename isOk from boolean value to checkState enum * fix: add checking for any error
This commit is contained in:
@@ -1,29 +1,37 @@
|
||||
import { ReactElement, useContext } from 'react'
|
||||
import { ReactElement, ReactNode, useContext } from 'react'
|
||||
import ExpandableList from '../../../components/ExpandableList'
|
||||
import ExpandableListItemNote from '../../../components/ExpandableListItemNote'
|
||||
import TopologyStats from '../../../components/TopologyStats'
|
||||
import StatusIcon from '../../../components/StatusIcon'
|
||||
import { Context } from '../../../providers/Bee'
|
||||
import { CheckState, Context } from '../../../providers/Bee'
|
||||
|
||||
export default function PeerConnection(): ReactElement | null {
|
||||
const { status, isLoading, topology } = useContext(Context)
|
||||
const { isEnabled, isOk } = status.topology
|
||||
const { isEnabled, checkState } = status.topology
|
||||
|
||||
if (!isEnabled) return null
|
||||
|
||||
let text: ReactNode
|
||||
switch (checkState) {
|
||||
case CheckState.OK:
|
||||
text = 'You are connected to other Bee nodes'
|
||||
break
|
||||
|
||||
// Both error state and warning state
|
||||
default:
|
||||
text =
|
||||
'Your node is not connected to any peers. Please wait a bit if you just started the node, otherwise review your configuration file.'
|
||||
}
|
||||
|
||||
return (
|
||||
<ExpandableList
|
||||
label={
|
||||
<>
|
||||
<StatusIcon isOk={isOk} isLoading={isLoading} /> Connection to Peers
|
||||
<StatusIcon checkState={checkState} isLoading={isLoading} /> Connection to Peers
|
||||
</>
|
||||
}
|
||||
>
|
||||
<ExpandableListItemNote>
|
||||
{isOk
|
||||
? 'You are connected to other Bee nodes'
|
||||
: 'Your node is not connected to any peers. Please wait a bit if you just started the node, otherwise review your configuration file.'}
|
||||
</ExpandableListItemNote>
|
||||
<ExpandableListItemNote>{text}</ExpandableListItemNote>
|
||||
|
||||
<TopologyStats topology={topology} />
|
||||
</ExpandableList>
|
||||
|
||||
Reference in New Issue
Block a user