Skip to content

Commit

Permalink
fix: add troubleshooting checks (#435)
Browse files Browse the repository at this point in the history
* fix: add troubleshooting checks

* feat: add node warning state
  • Loading branch information
vojtechsimetka committed Jun 24, 2022
1 parent 4cd580c commit a756eed
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 22 deletions.
5 changes: 5 additions & 0 deletions src/pages/account/feeds/AccountFeeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ import { ExportFeedDialog } from '../../feeds/ExportFeedDialog'
import { ImportFeedDialog } from '../../feeds/ImportFeedDialog'
import { AccountNavigation } from '../AccountNavigation'
import { Header } from '../Header'
import TroubleshootConnectionCard from '../../../components/TroubleshootConnectionCard'
import { CheckState, Context as BeeContext } from '../../../providers/Bee'

export function AccountFeeds(): ReactElement {
const { identities, setIdentities } = useContext(IdentityContext)
const { status } = useContext(BeeContext)

const navigate = useNavigate()

Expand Down Expand Up @@ -62,6 +65,8 @@ export function AccountFeeds(): ReactElement {
setShowDelete(true)
}

if (status.all === CheckState.ERROR) return <TroubleshootConnectionCard />

return (
<>
<Header />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/files/UploadLander.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactElement, useContext } from 'react'
import { History } from '../../components/History'
import TroubleshootConnectionCard from '../../components/TroubleshootConnectionCard'
import { Context as BeeContext } from '../../providers/Bee'
import { CheckState, Context as BeeContext } from '../../providers/Bee'
import { defaultUploadOrigin } from '../../providers/File'
import { HISTORY_KEYS } from '../../utils/local-storage'
import { FileNavigation } from './FileNavigation'
Expand All @@ -10,7 +10,7 @@ import { UploadArea } from './UploadArea'
export function UploadLander(): ReactElement {
const { status } = useContext(BeeContext)

if (!status.all) return <TroubleshootConnectionCard />
if (status.all === CheckState.ERROR) return <TroubleshootConnectionCard />

return (
<>
Expand Down
48 changes: 48 additions & 0 deletions src/pages/info/NodeInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ReactElement, useContext } from 'react'
import Search from 'remixicon-react/SearchLineIcon'
import Globe from 'remixicon-react/GlobalLineIcon'
import Settings from 'remixicon-react/Settings2LineIcon'

import { CheckState, Context as BeeContext } from '../../providers/Bee'
import Card from '../../components/Card'
import { useNavigate } from 'react-router'
import { ROUTES } from '../../routes'

export default function NodeInfoCard(): ReactElement {
const { status } = useContext(BeeContext)
const navigate = useNavigate()

if (status.all === CheckState.ERROR) {
return (
<Card
buttonProps={{ iconType: Settings, children: 'Open node setup', onClick: () => navigate(ROUTES.STATUS) }}
icon={<Globe />}
title="Your node is not connected…"
subtitle="You are not connected to Swarm."
status="error"
/>
)
}

if (status.all === CheckState.WARNING) {
return (
<Card
buttonProps={{ iconType: Settings, children: 'Open node setup', onClick: () => navigate(ROUTES.STATUS) }}
icon={<Globe />}
title="Your node is running…"
subtitle="Connection to Swarm might not be optimal."
status="error"
/>
)
}

return (
<Card
buttonProps={{ iconType: Search, children: 'Access Content', onClick: () => navigate(ROUTES.DOWNLOAD) }}
icon={<Globe />}
title="Your node is connected."
subtitle="You are connected to Swarm."
status="ok"
/>
)
}
22 changes: 2 additions & 20 deletions src/pages/info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { ReactElement, useContext } from 'react'
import { Button } from '@material-ui/core'
import Wallet from 'remixicon-react/Wallet3LineIcon'
import ExchangeFunds from 'remixicon-react/ExchangeFundsLineIcon'
import Search from 'remixicon-react/SearchLineIcon'
import Globe from 'remixicon-react/GlobalLineIcon'
import Settings from 'remixicon-react/Settings2LineIcon'
import Upload from 'remixicon-react/UploadLineIcon'

import { Context as BeeContext } from '../../providers/Bee'
Expand All @@ -15,6 +12,7 @@ import { useNavigate } from 'react-router'
import { ROUTES } from '../../routes'
import { useIsBeeDesktop, useNewBeeDesktopVersion } from '../../hooks/apiHooks'
import { BEE_DESKTOP_LATEST_RELEASE_PAGE } from '../../utils/desktop'
import NodeInfoCard from './NodeInfoCard'

export default function Status(): ReactElement {
const {
Expand All @@ -34,23 +32,7 @@ export default function Status(): ReactElement {
return (
<div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'stretch', alignContent: 'stretch' }}>
{status.all === 'OK' ? (
<Card
buttonProps={{ iconType: Search, children: 'Access Content', onClick: () => navigate(ROUTES.DOWNLOAD) }}
icon={<Globe />}
title="Your node is connected."
subtitle="You are connected to Swarm."
status="ok"
/>
) : (
<Card
buttonProps={{ iconType: Settings, children: 'Open node setup', onClick: () => navigate(ROUTES.STATUS) }}
icon={<Globe />}
title="Your node is not connected…"
subtitle="You are not connected to Swarm."
status="error"
/>
)}
<NodeInfoCard />
<div style={{ width: '8px' }}></div>
{nodeInfo?.beeMode && ['light', 'full', 'dev'].includes(nodeInfo.beeMode) ? (
<Card
Expand Down

0 comments on commit a756eed

Please sign in to comment.