-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/ricardian contract params and styles adjustments (#91)
* feat(webapp): pass params to abi and actions urls in ricardian contract * chore(webapp): add spacing to BP Json Generator * chore(webapp): adjust styles of the add node modal * chore(webapp): bp.json generator styles adjustments * chore(webapp): update dependencies with no breaking changes * fix(webapp): fix bug when a wrong file is upload and improve error modal * feat(webapp): pass additional nodes types as params * feat(webapp): allow to insert a custom feature in a node * fix(webapp): fix error when try to insert features * chore(webapp): update dependencies with no breaking changes * chore(webapp): remove unneeded validation
- Loading branch information
1 parent
2e31556
commit 74c82ec
Showing
15 changed files
with
3,565 additions
and
2,948 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
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,125 +1,71 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { makeStyles } from '@mui/styles' | ||
import Checkbox from '@mui/material/Checkbox' | ||
import Chip from '@mui/material/Chip' | ||
import MenuItem from '@mui/material/MenuItem' | ||
import ListItemText from '@mui/material/ListItemText' | ||
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete' | ||
import Divider from '@mui/material/Divider' | ||
import TextField from '@mui/material/TextField' | ||
import Typography from '@mui/material/Typography' | ||
|
||
import { NODE_EXTRA_KEYS } from '../utils' | ||
import { NODE_FEATURES } from '../utils' | ||
|
||
import Styles from './styles' | ||
|
||
const useStyles = makeStyles(Styles) | ||
|
||
const features = [ | ||
{ | ||
label: 'chain-api', | ||
value: 'chain-api', | ||
info: 'basic eosio::chain_api_plugin (/v1/chain/*)' | ||
}, | ||
{ | ||
label: 'account-query', | ||
value: 'account-query', | ||
info: '(/v1/chain/get_accounts_by_authorizers)' | ||
}, | ||
{ | ||
label: 'history-v1', | ||
value: 'history-v1', | ||
info: '(/v1/history/*)' | ||
}, | ||
{ | ||
label: 'hyperion-v2', | ||
value: 'hyperion-v2', | ||
info: '(/v2/*)' | ||
}, | ||
{ | ||
label: 'dfuse', | ||
value: 'dfuse', | ||
info: '' | ||
}, | ||
{ | ||
label: 'fio-api', | ||
value: 'fio-api', | ||
info: '' | ||
}, | ||
{ | ||
label: 'snapshot-api', | ||
value: 'snapshot-api', | ||
info: '' | ||
}, | ||
{ | ||
label: 'dsp-api', | ||
value: 'dsp-api', | ||
info: '' | ||
}, | ||
{ | ||
label: 'atomic-assets-api', | ||
value: 'atomic-assets-api', | ||
info: '', | ||
} | ||
] | ||
const filter = createFilterOptions() | ||
|
||
const FeaturesForm = ({ currentNode, handleOnChange }) => { | ||
const FeaturesForm = ({ currentNode, nodesKeys, handleOnChange }) => { | ||
const classes = useStyles() | ||
|
||
if (!(NODE_EXTRA_KEYS[currentNode.node_type]?.indexOf('features') > -1)) { | ||
if (!(nodesKeys[currentNode.node_type]?.indexOf('features') > -1)) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<> | ||
<Typography | ||
className={classes.sectionTitle} | ||
variant="h5" | ||
> | ||
<div className={classes.wrapperForm}> | ||
<Typography className={classes.sectionTitle} variant="h5"> | ||
Features | ||
</Typography> | ||
<TextField | ||
onChange={handleOnChange} | ||
<Divider className={classes.divider} /> | ||
<Autocomplete | ||
multiple | ||
variant="outlined" | ||
label="Node Features" | ||
select | ||
SelectProps={{ | ||
multiple: true, | ||
classes: { | ||
root: currentNode.features?.length ? classes.selectChips : '' | ||
}, | ||
renderValue: (selected) => ( | ||
<div className={classes.chips}> | ||
{selected.map((value, index) => ( | ||
<Chip | ||
key={`chip-item-${index}`} | ||
label={value} | ||
className={classes.chip} | ||
/> | ||
))} | ||
</div> | ||
) | ||
}} | ||
options={NODE_FEATURES} | ||
onChange={handleOnChange} | ||
value={currentNode.features || []} | ||
className={classes.formFieldForm} | ||
> | ||
{features.map((option, index) => ( | ||
<MenuItem key={`menu-item-${index}`} value={option.value}> | ||
<Checkbox | ||
checked={ | ||
(currentNode.features || []).indexOf(option.value) > -1 | ||
} | ||
/> | ||
<ListItemText primary={option.label} /> | ||
</MenuItem> | ||
))} | ||
</TextField> | ||
</> | ||
defaultValue={currentNode.features || []} | ||
filterOptions={(options, params) => { | ||
const filtered = filter(options, params) | ||
|
||
if (params.inputValue !== '') { | ||
filtered.push({ | ||
label: params.inputValue, | ||
value: params.inputValue, | ||
info: '' | ||
}) | ||
} | ||
|
||
return filtered | ||
}} | ||
getOptionLabel={(option) => { | ||
if (typeof option === 'string') return option | ||
|
||
if (option.inputValue) return option.inputValue | ||
|
||
return option.label | ||
}} | ||
renderInput={(params) => ( | ||
<TextField {...params} variant="outlined" label="Node Features" /> | ||
)} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
FeaturesForm.propTypes = { | ||
currentNode: PropTypes.object, | ||
handleOnChange: PropTypes.func, | ||
nodesKeys: PropTypes.object, | ||
handleOnChange: PropTypes.func | ||
} | ||
|
||
export default FeaturesForm | ||
export default FeaturesForm |
Oops, something went wrong.