Skip to content

Commit

Permalink
feat: clarify labels and syncing (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 committed Jul 17, 2024
1 parent 8558860 commit 01b1b39
Show file tree
Hide file tree
Showing 10 changed files with 1,166 additions and 1,033 deletions.
2,066 changes: 1,100 additions & 966 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"crypto": "npm:crypto-browserify",
"crypto-browserify": "^3.12.0",
"dotted-map": "^2.2.3",
"ethers": "^5.6.4",
"ethers": "^5.7.2",
"file-saver": "^2.0.5",
"formik": "2.2.9",
"formik-material-ui": "3.0.1",
Expand All @@ -48,7 +48,7 @@
"opener": "1.5.2",
"qrcode.react": "1.0.1",
"react": ">= 17.0.2",
"react-copy-to-clipboard": "5.0.4",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": ">= 17.0.2",
"react-identicons": "1.2.5",
"react-router": "6.2.1",
Expand Down Expand Up @@ -76,15 +76,15 @@
"@types/jest": "27.0.2",
"@types/qrcode.react": "1.0.2",
"@types/react": "17.0.34",
"@types/react-copy-to-clipboard": "5.0.2",
"@types/react-copy-to-clipboard": "^5.0.2",
"@types/react-dom": "17.0.11",
"@types/react-router": "5.1.18",
"@types/react-router-dom": "5.3.2",
"@types/react-syntax-highlighter": "13.5.2",
"@typescript-eslint/eslint-plugin": "5.28.0",
"@typescript-eslint/parser": "5.28.0",
"babel-eslint": "10.1.0",
"babel-loader": "8.1.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"babel-plugin-syntax-dynamic-import": "6.18.0",
"babel-plugin-tsconfig-paths": "1.0.2",
"base64-inline-loader": "^2.0.1",
Expand Down Expand Up @@ -112,7 +112,7 @@
"ts-node": "^10.8.1",
"typescript": "4.8.3",
"web-vitals": "2.1.2",
"webpack": "^5.73.0",
"webpack": "^5.93.0",
"webpack-cli": "^4.10.0"
},
"peerDependencies": {
Expand Down
12 changes: 4 additions & 8 deletions src/components/ExpandableListItemInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Box, Grid, IconButton, InputBase, ListItem, Typography } from '@materia
import Collapse from '@material-ui/core/Collapse'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import { ChangeEvent, ReactElement, useState } from 'react'
import type { RemixiconReactIconProps } from 'remixicon-react'
import Check from 'remixicon-react/CheckLineIcon'
import X from 'remixicon-react/CloseLineIcon'
import Edit from 'remixicon-react/PencilLineIcon'
import Minus from 'remixicon-react/SubtractLineIcon'
import X from 'remixicon-react/CloseLineIcon'
import ExpandableListItemActions from './ExpandableListItemActions'
import ExpandableListItemNote from './ExpandableListItemNote'
import { SwarmButton } from './SwarmButton'
import type { RemixiconReactIconProps } from 'remixicon-react'

const useStyles = makeStyles((theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -108,12 +108,8 @@ export default function ExpandableListItemKey({
<div>
{!open && value}
{!expandedOnly && !locked && (
<IconButton size="small" className={classes.copyValue}>
{open ? (
<Minus onClick={toggleOpen} strokeWidth={1} />
) : (
<Edit onClick={toggleOpen} strokeWidth={1} />
)}
<IconButton size="small" className={classes.copyValue} onClick={toggleOpen}>
{open ? <Minus strokeWidth={1} /> : <Edit strokeWidth={1} />}
</IconButton>
)}
</div>
Expand Down
26 changes: 12 additions & 14 deletions src/components/ExpandableListItemKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,18 @@ export default function ExpandableListItemKey({ label, value, expanded }: Props)
<Grid container direction="row" justifyContent="space-between" alignItems="center">
{label && <Typography variant="body1">{label}</Typography>}
<Typography variant="body2">
<div>
{!open && (
<span className={classes.copyValue}>
<Tooltip title={copied ? 'Copied' : 'Copy'} placement="top" arrow onClose={tooltipCloseHandler}>
<CopyToClipboard text={value}>
<span onClick={tooltipClickHandler}>{value ? spanText : ''}</span>
</CopyToClipboard>
</Tooltip>
</span>
)}
<IconButton size="small" className={classes.copyValue}>
{open ? <Minus onClick={toggleOpen} strokeWidth={1} /> : <Eye onClick={toggleOpen} strokeWidth={1} />}
</IconButton>
</div>
{!open && (
<span className={classes.copyValue}>
<Tooltip title={copied ? 'Copied' : 'Copy'} placement="top" arrow onClose={tooltipCloseHandler}>
<CopyToClipboard text={value}>
<span onClick={tooltipClickHandler}>{value ? spanText : ''}</span>
</CopyToClipboard>
</Tooltip>
</span>
)}
<IconButton size="small" className={classes.copyValue} onClick={toggleOpen}>
{open ? <Minus strokeWidth={1} /> : <Eye strokeWidth={1} />}
</IconButton>
</Typography>
</Grid>
<Collapse in={open} timeout="auto" unmountOnExit>
Expand Down
30 changes: 14 additions & 16 deletions src/components/ExpandableListItemLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ export default function ExpandableListItemLink({
<Grid container direction="row" justifyContent="space-between" alignItems="center">
{label && <Typography variant="body1">{label}</Typography>}
<Typography variant="body2">
<div>
{allowClipboard && (
<span className={classes.copyValue}>
<Tooltip title={copied ? 'Copied' : 'Copy'} placement="top" arrow onClose={tooltipCloseHandler}>
<CopyToClipboard text={value}>
<span onClick={tooltipClickHandler}>{displayValue}</span>
</CopyToClipboard>
</Tooltip>
</span>
)}
{!allowClipboard && <span onClick={onNavigation}>{displayValue}</span>}
<IconButton size="small" className={classes.openLinkIcon}>
{navigationType === 'NEW_WINDOW' && <OpenInNewSharp onClick={onNavigation} strokeWidth={1} />}
{navigationType === 'HISTORY_PUSH' && <ArrowForward onClick={onNavigation} strokeWidth={1} />}
</IconButton>
</div>
{allowClipboard && (
<span className={classes.copyValue}>
<Tooltip title={copied ? 'Copied' : 'Copy'} placement="top" arrow onClose={tooltipCloseHandler}>
<CopyToClipboard text={value}>
<span onClick={tooltipClickHandler}>{displayValue}</span>
</CopyToClipboard>
</Tooltip>
</span>
)}
{!allowClipboard && <span onClick={onNavigation}>{displayValue}</span>}
<IconButton size="small" className={classes.openLinkIcon} onClick={onNavigation}>
{navigationType === 'NEW_WINDOW' && <OpenInNewSharp strokeWidth={1} />}
{navigationType === 'HISTORY_PUSH' && <ArrowForward strokeWidth={1} />}
</IconButton>
</Typography>
</Grid>
</Grid>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/account/stamps/AccountStamps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CircularProgress, Container, createStyles, makeStyles } from '@material
import { ReactElement, useContext, useEffect } from 'react'
import { useNavigate } from 'react-router'
import PlusSquare from 'remixicon-react/AddBoxLineIcon'
import { ChainSync } from '../../../components/ChainSync'
import { Loading } from '../../../components/Loading'
import { SwarmButton } from '../../../components/SwarmButton'
import TroubleshootConnectionCard from '../../../components/TroubleshootConnectionCard'
Expand Down Expand Up @@ -57,7 +58,7 @@ export function AccountStamps(): ReactElement {
{error && (
<Container style={{ textAlign: 'center', padding: '50px' }}>
<Loading />
{error.message}
<ChainSync />
</Container>
)}
{!error && (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/files/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function Download(): ReactElement {
<>
{nodeInfo?.beeMode !== BeeModes.ULTRA_LIGHT && <FileNavigation active="DOWNLOAD" />}
<ExpandableListItemInput
label="Swarm Hash"
label="Swarm Hash or ENS"
onConfirm={value => onSwarmIdentifier(value)}
onChange={validateChange}
helperText={referenceError}
Expand Down
45 changes: 25 additions & 20 deletions src/pages/restart/LightModeRestart.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
import { BeeModes } from '@ethersphere/bee-js'
import { Box, Grid, Typography } from '@material-ui/core'
import { useSnackbar } from 'notistack'
import { ReactElement, useContext, useEffect, useState } from 'react'
import { ReactElement, useContext, useEffect } from 'react'
import { useNavigate } from 'react-router'
import { ChainSync } from '../../components/ChainSync'
import { Waiting } from '../../components/Waiting'
import { Context } from '../../providers/Bee'
import { Context } from '../../providers/Settings'
import { ROUTES } from '../../routes'

const STARTED_UPGRADE_AT = 'started-upgrade-at'

export default function LightModeRestart(): ReactElement {
const [startedAt] = useState(Number.parseInt(localStorage.getItem(STARTED_UPGRADE_AT) ?? Date.now().toFixed()))
const { apiHealth, nodeInfo } = useContext(Context)
const navigate = useNavigate()
const { enqueueSnackbar } = useSnackbar()
const { beeApi } = useContext(Context)

useEffect(() => {
localStorage.setItem(STARTED_UPGRADE_AT, startedAt.toFixed())
}, [startedAt])

useEffect(() => {
if (Date.now() - startedAt < 45_000) {
if (!beeApi) {
return
}

if (apiHealth && nodeInfo?.beeMode === BeeModes.LIGHT) {
enqueueSnackbar('Upgraded to light node', { variant: 'success' })
localStorage.removeItem(STARTED_UPGRADE_AT)
navigate(ROUTES.INFO)
}
}, [startedAt, navigate, nodeInfo, apiHealth, enqueueSnackbar])
const interval = setInterval(() => {
beeApi
.getNodeInfo()
.then(nodeInfo => {
if (nodeInfo.beeMode === BeeModes.LIGHT) {
enqueueSnackbar('Upgraded to light node', { variant: 'success' })
navigate(ROUTES.INFO)
}
})
.catch(console.error) // eslint-disable-line
}, 3_000)

return () => clearInterval(interval)
}, [beeApi, enqueueSnackbar, navigate])

return (
<Grid container direction="column" justifyContent="center" alignItems="center">
Expand All @@ -41,9 +43,12 @@ export default function LightModeRestart(): ReactElement {
<strong>Upgrading Bee</strong>
</Typography>
</Box>
<Typography>
You will be redirected automatically once your node is up and running. This may take up to 10 minutes.
</Typography>
<Box mb={1}>
<Typography>
You will be redirected automatically once your node is up and running. This may take up to 10 minutes.
</Typography>
</Box>
<ChainSync />
</Grid>
)
}
1 change: 1 addition & 0 deletions src/providers/Stamps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function Provider({ children }: Props): ReactElement {

setStamps(stamps.filter(x => x.exists).map(enrichStamp))
setLastUpdate(Date.now())
setError(null)
} catch (e) {
setError(e as Error)
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function sendRequest(
const authorization = localStorage.getItem('apiKey')

if (!authorization) {
throw Error('API key not found in local storage')
throw Error('API key not found in local storage. Please reopen via Swarm Desktop > Open Web UI.')
}
const headers = {
authorization,
Expand Down

0 comments on commit 01b1b39

Please sign in to comment.