Merge pull request #14 from Permissionless-Software-Foundation/ct-unstable

Adding Configuration page
This commit is contained in:
Chris Troutner
2025-04-10 15:11:26 -07:00
committed by GitHub
8 changed files with 18469 additions and 12826 deletions
+18345 -12743
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,20 @@
/*
This component is a View that allows the user to handle configuration
settings for the app.
*/
// Global npm libraries
import React from 'react'
import ServerSelectView from './select-server-view'
function ConfigurationView (props) {
const { appData } = props
return (
<>
<ServerSelectView appData={appData} />
</>
)
}
export default ConfigurationView
@@ -0,0 +1,90 @@
/*
This component is a View that allows the user to select a back end server
from a list of servers.
*/
// Global npm libraries
import React, { useState } from 'react'
import { Row, Col, Form, Card } from 'react-bootstrap'
function ServerSelectView (props) {
const { appData } = props
const [selectedServer, setSelectedServer] = useState(appData.serverUrl)
const servers = appData.servers
// Update server when dropdown selection changes
const handleServerChange = (event) => {
setSelectedServer(event.target.value)
}
const onSaveServer = (serverUrl) => {
console.log('server target: ', serverUrl)
appData.updateLocalStorage({ serverUrl })
window.location.href = '/'
}
return (
<>
<Card className='m-3'>
<Row className='mb-3 mt-3 mx-3'>
<Col className='text-end'>
<button
className='btn btn-primary'
style={{ minWidth: '100px' }}
onClick={() => onSaveServer(selectedServer)}
>
Save
</button>
</Col>
</Row>
<Card.Body>
<Row>
<Col style={{ textAlign: 'center' }}>
<h2>Configuration</h2>
<p>
This page allows you to change configuration settings for different
back end services. This page is for advanced users only.
</p>
</Col>
</Row>
<hr />
<Row className='justify-content-center'>
<Col xs={12} md={6}>
<p>
Select an alternative server below. The app will reload and use
the selected server.
</p>
<Form.Select
value={selectedServer}
onChange={handleServerChange}
className='mb-3'
>
{servers.map((server, i) => (
<option key={`server-${i}`} value={server.value}>
{server.value === appData.serverUrl ? `${server.label} (current)` : server.label}
</option>
))}
</Form.Select>
</Col>
</Row>
<Row className='justify-content-center mt-3'>
<Col xs={12} md={6} className='text-center'>
<button
className='btn btn-primary'
style={{ minWidth: '100px' }}
onClick={() => onSaveServer(selectedServer)}
>
Save
</button>
</Col>
</Row>
</Card.Body>
</Card>
</>
)
}
export default ServerSelectView
+5 -3
View File
@@ -15,12 +15,13 @@ import GetBalance from './balance'
import Wallet from './bch-wallet' import Wallet from './bch-wallet'
import Placeholder2 from './placeholder2' import Placeholder2 from './placeholder2'
import Placeholder3 from './placeholder3' import Placeholder3 from './placeholder3'
import ServerSelectView from './servers/select-server-view' // import ServerSelectView from './servers/select-server-view'
import SelectServerButton from './servers/select-server-button' // import SelectServerButton from './servers/select-server-button'
import BchSend from './bch-send' import BchSend from './bch-send'
import SlpTokens from './slp-tokens' import SlpTokens from './slp-tokens'
import SweepWif from './sweep/index.js' import SweepWif from './sweep/index.js'
import SignMessage from './sign/index.js' import SignMessage from './sign/index.js'
import ServerSelectView from './configuration/select-server-view'
function AppBody (props) { function AppBody (props) {
// Dependency injection through props // Dependency injection through props
@@ -39,9 +40,10 @@ function AppBody (props) {
<Route path='/servers' element={<ServerSelectView appData={appData} />} /> <Route path='/servers' element={<ServerSelectView appData={appData} />} />
<Route path='/sweep' element={<SweepWif appData={appData} />} /> <Route path='/sweep' element={<SweepWif appData={appData} />} />
<Route path='/sign' element={<SignMessage appData={appData} />} /> <Route path='/sign' element={<SignMessage appData={appData} />} />
<Route path='/configuration' element={<ServerSelectView appData={appData} />} />
</Routes> </Routes>
{/** Show in all paths except the servers view */} {/** Show in all paths except the servers view */}
{appData.currentPath !== '/servers' && <SelectServerButton linkTo='/servers' appData={appData} />} {/* {appData.currentPath !== '/servers' && <SelectServerButton linkTo='/servers' appData={appData} />} */}
</> </>
) )
} }
@@ -1,78 +0,0 @@
/*
This component is a View that allows the user to select a back end server
from a list of servers.
*/
// Global npm libraries
import React from 'react'
import { Container, Row, Col, Button } from 'react-bootstrap'
function ServerSelectView (props) {
const { appData } = props
const selectedServer = appData.serverUrl // Selected server
const servers = appData.servers // List of servers
// Update location ref after server url changes
const handleReloadServer = (event) => {
const target = event.target.id
console.log('server target: ', target)
appData.updateLocalStorage({ serverUrl: target })
// Reload the page
window.location.href = '/'
}
return (
<>
<Container>
<Row>
<Col style={{ textAlign: 'center' }}>
<h2>
Select Alternative Server
</h2>
<p>
Select an alternative server below. The app will reload and use
the selected server.
</p>
</Col>
</Row>
<br />
{
/** Map all server data and render a row for each server */
servers.map((server, i) => {
// Background color for each row
const isEven = i % 2
const backgroundColor = isEven ? '#eee' : '#fff'
return (
<div key={`server-${i}`}>
<Row
style={{
padding: '25px',
backgroundColor
}}
>
<Col xs={4}>
<Button
style={{ minWidth: 120 }}
id={server.value}
onClick={handleReloadServer}
>
{selectedServer === server.value ? 'Current' : 'Select'}
</Button>
</Col>
<Col xs={8}>
{server.label}
</Col>
</Row>
</div>
)
})
}
</Container>
</>
)
}
export default ServerSelectView
+8 -1
View File
@@ -31,7 +31,7 @@ function NavMenu (props) {
<Navbar expanded={expanded} onToggle={setExpanded} expand='xxxl' bg='dark' variant='dark' style={{ paddingRight: '20px' }}> <Navbar expanded={expanded} onToggle={setExpanded} expand='xxxl' bg='dark' variant='dark' style={{ paddingRight: '20px' }}>
<Navbar.Brand href='#home' style={{ paddingLeft: '20px' }}> <Navbar.Brand href='#home' style={{ paddingLeft: '20px' }}>
<Image src={Logo} thumbnail width='50' />{' '} <Image src={Logo} thumbnail width='50' />{' '}
PSF Web3 Demo SLP Wallet
</Navbar.Brand> </Navbar.Brand>
<Navbar.Toggle aria-controls='responsive-navbar-nav' /> <Navbar.Toggle aria-controls='responsive-navbar-nav' />
@@ -84,6 +84,13 @@ function NavMenu (props) {
> >
Sign Sign
</NavLink> </NavLink>
<NavLink
className={currentPath === '/configuration' ? 'nav-link-active' : 'nav-link-inactive'}
to='/configuration'
onClick={handleClickEvent}
>
Configuration
</NavLink>
</Nav> </Nav>
</Navbar.Collapse> </Navbar.Collapse>
</Navbar> </Navbar>
+1 -1
View File
@@ -11,7 +11,7 @@ const config = {
// Backup Info that goes into the Footer. // Backup Info that goes into the Footer.
ghPagesUrl: 'https://permissionless-software-foundation.github.io/react-bootstrap-web3-spa/', ghPagesUrl: 'https://permissionless-software-foundation.github.io/react-bootstrap-web3-spa/',
ghRepo: 'https://github.com/Permissionless-Software-Foundation/react-bootstrap-web3-spa', ghRepo: 'https://github.com/Permissionless-Software-Foundation/bch-wallet-web3-spa',
radicleUrl: 'https://app.radicle.network/seeds/maple.radicle.garden/rad:git:hnrkd5cjwwb5tzx37hq9uqm5ubon7ee468xcy/remotes/hyyycncbn9qzqmobnhjq9rry6t4mbjiadzjoyhaknzxjcz3cxkpfpc' radicleUrl: 'https://app.radicle.network/seeds/maple.radicle.garden/rad:git:hnrkd5cjwwb5tzx37hq9uqm5ubon7ee468xcy/remotes/hyyycncbn9qzqmobnhjq9rry6t4mbjiadzjoyhaknzxjcz3cxkpfpc'
} }