add reset database button

This commit is contained in:
Barry Gitarts 2019-04-16 11:29:07 -04:00
parent f43af563e5
commit 62fd24fd7a
2 changed files with 21 additions and 14 deletions

View File

@ -1,21 +1,28 @@
import React, { Fragment } from 'react'
import Button from '@material-ui/core/Button'
import { Button, Divider } from '@material-ui/core'
import { FundingContext } from '../context'
import SetMockedTime from './SetMockedTime'
import database from '../db'
async function resetDb(openSnackBar) {
await database.unsafeResetDatabase()
openSnackBar('success', 'Database has been reset. Refresh the page to populate it')
}
const ContractAdmin = () => (
<FundingContext.Consumer>
{({ needsInit, initVaultAndLP, standardTokenApproval }) =>
<Fragment>
{needsInit && <Button variant="outlined" color="secondary" onClick={initVaultAndLP}>
Initialize Contracts
</Button>}
<Button variant="outlined" color="primary" onClick={standardTokenApproval}>
GIVE VAULT TOKEN APPROVAL
</Button>
<SetMockedTime />
</Fragment>
}
{({ needsInit, initVaultAndLP, standardTokenApproval, openSnackBar }) =>
<Fragment>
<Button color="secondary" variant="contained" onClick={() => resetDb(openSnackBar)}>RESET DATABASE</Button>
<Divider />
{needsInit && <Button variant="outlined" color="secondary" onClick={initVaultAndLP}>
Initialize Contracts
</Button>}
{needsInit && <Button variant="outlined" color="primary" onClick={standardTokenApproval}>
GIVE VAULT TOKEN APPROVAL
</Button>}
</Fragment>
}
</FundingContext.Consumer>
)

View File

@ -183,7 +183,7 @@ class PersistentDrawerLeft extends React.Component {
<Link to="/admin/" className={classes.link}>
<ListItem button>
<ListItemIcon><InboxIcon /></ListItemIcon>
<ListItemText primary="Contract Admin" />
<ListItemText primary="Admin" />
</ListItem>
</Link>
</List>