Files
bee-dashboard/src/pages/settings/index.tsx
T
Vojtech Simetka 87b0b71cc6 feat: add bee-desktop settings capabilities (#323)
* refactor: make the config readonly and extract endpoint calls to hook (+2 squashed commits)
Squashed commits:
[91ffe45] feat: add swap-endpoint
[e1d0c3a] feat: add bee-desktop settings capabilities

* feat: use the request mechanism that uses the bee-desktop API key

* fix: properly reset the error or on error set the config to null
2022-04-29 09:30:46 +02:00

47 lines
1.8 KiB
TypeScript

import CircularProgress from '@material-ui/core/CircularProgress'
import { ReactElement, useContext } from 'react'
import ExpandableList from '../../components/ExpandableList'
import ExpandableListItemInput from '../../components/ExpandableListItemInput'
import { Context as SettingsContext } from '../../providers/Settings'
export default function SettingsPage(): ReactElement {
const { apiUrl, apiDebugUrl, setApiUrl, setDebugApiUrl, lockedApiSettings, config, isLoading } =
useContext(SettingsContext)
if (isLoading) {
return (
<div style={{ textAlign: 'center', width: '100%' }}>
<CircularProgress />
</div>
)
}
// Run within Bee Desktop, display read only config
if (config) {
return (
<ExpandableList label="Bee Desktop Settings" defaultOpen>
<ExpandableListItemInput label="Bee API" value={config['api-addr']} locked />
<ExpandableListItemInput label="Bee Debug API" value={config['debug-api-addr']} locked />
<ExpandableListItemInput label="CORS" value={config['cors-allowed-origins']} locked />
<ExpandableListItemInput label="Data DIR" value={config['data-dir']} locked />
<ExpandableListItemInput label="ENS resolver URL" value={config['resolver-options']} locked />
{config['swap-endpoint'] && (
<ExpandableListItemInput label="SWAP endpoint" value={config['swap-endpoint']} locked />
)}
</ExpandableList>
)
}
return (
<ExpandableList label="API Settings" defaultOpen>
<ExpandableListItemInput label="Bee API" value={apiUrl} onConfirm={setApiUrl} locked={lockedApiSettings} />
<ExpandableListItemInput
label="Bee Debug API"
value={apiDebugUrl}
onConfirm={setDebugApiUrl}
locked={lockedApiSettings}
/>
</ExpandableList>
)
}