-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: changing API urls does not need the app refresh (#173)
* feat: changing API urls does not need the app refresh * fix: propagate beeDebugApi and beeApi change to the refresh interval * fix: any failed request on the Bee provider does not stop the execution of other requests * fix: error handling for incorrect bee and bee debug urls * fix: change debug API in the settings tab
- Loading branch information
1 parent
2624cf0
commit d6d03bf
Showing
21 changed files
with
339 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,50 @@ | ||
import React, { ReactElement, useState } from 'react' | ||
import { TextField, Button, CircularProgress, Container } from '@material-ui/core' | ||
import { TextField, Button } from '@material-ui/core' | ||
|
||
interface Props { | ||
defaultHost?: string | ||
hostName: string | ||
setHost: (host: string) => void | ||
} | ||
|
||
export default function ConnectToHost(props: Props): ReactElement { | ||
const [hostInputVisible, toggleHostInputVisibility] = useState(false) | ||
const [connectingToHost, setConnectingToHost] = useState(false) | ||
const [host, setHost] = useState('') | ||
|
||
const handleNewHostConnection = () => { | ||
if (host) { | ||
setConnectingToHost(true) | ||
sessionStorage.setItem(props.hostName, host) | ||
props.setHost(host) | ||
toggleHostInputVisibility(!hostInputVisible) | ||
window.location.reload() | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
{ | ||
// FIXME: this should be broken up | ||
/* eslint-disable no-nested-ternary */ | ||
hostInputVisible ? ( | ||
<div style={{ display: 'flex' }}> | ||
<TextField | ||
defaultValue={props.defaultHost} | ||
label="Enter host" | ||
variant="outlined" | ||
size="small" | ||
onChange={e => setHost(e.target.value)} | ||
style={{ marginRight: '15px', minWidth: '300px' }} | ||
/> | ||
<Button onClick={() => handleNewHostConnection()} size="small" variant="outlined"> | ||
Connect | ||
</Button> | ||
<Button | ||
style={{ marginLeft: '7px' }} | ||
onClick={() => toggleHostInputVisibility(!hostInputVisible)} | ||
size="small" | ||
> | ||
Cancel | ||
</Button> | ||
</div> | ||
) : connectingToHost ? ( | ||
<Container style={{ textAlign: 'center', padding: '0px' }}> | ||
<CircularProgress size={20} /> | ||
</Container> | ||
) : ( | ||
<Button onClick={() => toggleHostInputVisibility(!hostInputVisible)} size="small" variant="outlined"> | ||
Change host | ||
{hostInputVisible ? ( | ||
<div style={{ display: 'flex' }}> | ||
<TextField | ||
defaultValue={props.defaultHost} | ||
label="Enter host" | ||
variant="outlined" | ||
size="small" | ||
onChange={e => setHost(e.target.value)} | ||
style={{ marginRight: '15px', minWidth: '300px' }} | ||
/> | ||
<Button onClick={() => handleNewHostConnection()} size="small" variant="outlined"> | ||
Connect | ||
</Button> | ||
) | ||
/* eslint-enable no-nested-ternary */ | ||
} | ||
<Button | ||
style={{ marginLeft: '7px' }} | ||
onClick={() => toggleHostInputVisibility(!hostInputVisible)} | ||
size="small" | ||
> | ||
Cancel | ||
</Button> | ||
</div> | ||
) : ( | ||
<Button onClick={() => toggleHostInputVisibility(!hostInputVisible)} size="small" variant="outlined"> | ||
Change host | ||
</Button> | ||
)} | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import type { ReactElement } from 'react' | ||
import { beeDebugApi } from '../services/bee' | ||
import { ReactElement, useContext } from 'react' | ||
import { Context as SettingsContext } from '../providers/Settings' | ||
|
||
import WDModal from '../components/WDModal' | ||
import { BigNumber } from 'bignumber.js' | ||
|
||
export default function DepositModal(): ReactElement { | ||
const { beeDebugApi } = useContext(SettingsContext) | ||
|
||
return ( | ||
<WDModal | ||
successMessage="Successful deposit." | ||
errorMessage="Error with depositing" | ||
dialogMessage="Specify the amount of BZZ you would like to withdraw from your node." | ||
label="Deposit" | ||
min={new BigNumber(0)} | ||
action={beeDebugApi.chequebook.deposit} | ||
action={(amount: bigint) => { | ||
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid') | ||
|
||
return beeDebugApi.depositTokens(amount.toString()) | ||
}} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import type { ReactElement } from 'react' | ||
import { beeDebugApi } from '../services/bee' | ||
import { ReactElement, useContext } from 'react' | ||
import { Context as SettingsContext } from '../providers/Settings' | ||
|
||
import WDModal from '../components/WDModal' | ||
import { BigNumber } from 'bignumber.js' | ||
|
||
export default function WithdrawModal(): ReactElement { | ||
const { beeDebugApi } = useContext(SettingsContext) | ||
|
||
return ( | ||
<WDModal | ||
successMessage="Successful withdrawl." | ||
errorMessage="Error with withdrawing." | ||
dialogMessage="Specify the amount of BZZ you would like to withdraw from your node." | ||
label="Withdraw" | ||
min={new BigNumber(0)} | ||
action={beeDebugApi.chequebook.withdraw} | ||
action={(amount: bigint) => { | ||
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid') | ||
|
||
return beeDebugApi.withdrawTokens(amount.toString()) | ||
}} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.