|
|
@ -1,8 +1,9 @@ |
|
|
|
import React, { useContext, useState } from 'react'; |
|
|
|
import React, { useContext, useState, useEffect } from 'react'; |
|
|
|
import { Form, Button, Alert, InputGroup } from 'react-bootstrap'; |
|
|
|
import { Form, Button, Alert, InputGroup } from 'react-bootstrap'; |
|
|
|
import { FormattedMessage, useIntl } from 'react-intl'; |
|
|
|
import { FormattedMessage, useIntl } from 'react-intl'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
deploy, |
|
|
|
deploy, |
|
|
|
|
|
|
|
teardown, |
|
|
|
emptyInstance, |
|
|
|
emptyInstance, |
|
|
|
resetInstance, |
|
|
|
resetInstance, |
|
|
|
getInfoFromNatSpec, |
|
|
|
getInfoFromNatSpec, |
|
|
@ -36,10 +37,21 @@ function DeployPanel(): JSX.Element { |
|
|
|
error: '', |
|
|
|
error: '', |
|
|
|
loading: false, |
|
|
|
loading: false, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const [teardownState, setTeardownState] = useState({ |
|
|
|
|
|
|
|
code: '', |
|
|
|
|
|
|
|
error: '', |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
window.scrollTo(0, document.body.scrollHeight); |
|
|
|
|
|
|
|
}, [deployState, teardownState]) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="col-3 d-inline-block"> |
|
|
|
<div className="col-3 d-inline-block"> |
|
|
|
<h3 className="mb-3">QuickDapp <FormattedMessage id="quickDapp.admin" /></h3> |
|
|
|
<h3 className="mb-3" data-id="quick-dapp-admin">QuickDapp <FormattedMessage id="quickDapp.admin" /></h3> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
|
|
|
|
data-id="resetFunctions" |
|
|
|
onClick={() => { |
|
|
|
onClick={() => { |
|
|
|
resetInstance(); |
|
|
|
resetInstance(); |
|
|
|
}} |
|
|
|
}} |
|
|
@ -47,6 +59,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
<FormattedMessage id="quickDapp.resetFunctions" /> |
|
|
|
<FormattedMessage id="quickDapp.resetFunctions" /> |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
|
|
|
|
data-id="deleteDapp" |
|
|
|
className="ml-3" |
|
|
|
className="ml-3" |
|
|
|
onClick={() => { |
|
|
|
onClick={() => { |
|
|
|
emptyInstance(); |
|
|
|
emptyInstance(); |
|
|
@ -78,6 +91,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
<Form.Group className="mb-2" controlId="formEmail"> |
|
|
|
<Form.Group className="mb-2" controlId="formEmail"> |
|
|
|
<Form.Label className="text-uppercase mb-0"><FormattedMessage id="quickDapp.email" /></Form.Label> |
|
|
|
<Form.Label className="text-uppercase mb-0"><FormattedMessage id="quickDapp.email" /></Form.Label> |
|
|
|
<Form.Control |
|
|
|
<Form.Control |
|
|
|
|
|
|
|
data-id="surgeEmail" |
|
|
|
type="email" |
|
|
|
type="email" |
|
|
|
placeholder={intl.formatMessage({ id: 'quickDapp.surgeEmail' })} |
|
|
|
placeholder={intl.formatMessage({ id: 'quickDapp.surgeEmail' })} |
|
|
|
required |
|
|
|
required |
|
|
@ -90,6 +104,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
<Form.Group className="mb-2" controlId="formPassword"> |
|
|
|
<Form.Group className="mb-2" controlId="formPassword"> |
|
|
|
<Form.Label className="text-uppercase mb-0"><FormattedMessage id="quickDapp.password" /></Form.Label> |
|
|
|
<Form.Label className="text-uppercase mb-0"><FormattedMessage id="quickDapp.password" /></Form.Label> |
|
|
|
<Form.Control |
|
|
|
<Form.Control |
|
|
|
|
|
|
|
data-id="surgePassword" |
|
|
|
type="password" |
|
|
|
type="password" |
|
|
|
placeholder={intl.formatMessage({ id: 'quickDapp.surgePassword' })} |
|
|
|
placeholder={intl.formatMessage({ id: 'quickDapp.surgePassword' })} |
|
|
|
required |
|
|
|
required |
|
|
@ -104,6 +119,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
<InputGroup> |
|
|
|
<InputGroup> |
|
|
|
<InputGroup.Text>https://</InputGroup.Text>
|
|
|
|
<InputGroup.Text>https://</InputGroup.Text>
|
|
|
|
<Form.Control |
|
|
|
<Form.Control |
|
|
|
|
|
|
|
data-id="surgeSubdomain" |
|
|
|
type="subdomain" |
|
|
|
type="subdomain" |
|
|
|
placeholder={intl.formatMessage({ id: 'quickDapp.uniqueSubdomain' })} |
|
|
|
placeholder={intl.formatMessage({ id: 'quickDapp.uniqueSubdomain' })} |
|
|
|
required |
|
|
|
required |
|
|
@ -133,7 +149,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<div className="d-inline-flex align-items-center custom-control custom-checkbox"> |
|
|
|
<div className="d-inline-flex align-items-center custom-control custom-checkbox"> |
|
|
|
<input |
|
|
|
<input |
|
|
|
id="inline-checkbox-1" |
|
|
|
id="shareToTwitter" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
type="checkbox" |
|
|
|
type="checkbox" |
|
|
|
name="group1" |
|
|
|
name="group1" |
|
|
@ -145,7 +161,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<label |
|
|
|
<label |
|
|
|
htmlFor="inline-checkbox-1" |
|
|
|
htmlFor="shareToTwitter" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
> |
|
|
|
> |
|
|
@ -154,7 +170,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="d-inline-flex align-items-center custom-control custom-checkbox ml-3"> |
|
|
|
<div className="d-inline-flex align-items-center custom-control custom-checkbox ml-3"> |
|
|
|
<input |
|
|
|
<input |
|
|
|
id="inline-checkbox-2" |
|
|
|
id="shareToFacebook" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
type="checkbox" |
|
|
|
type="checkbox" |
|
|
|
name="group1" |
|
|
|
name="group1" |
|
|
@ -166,7 +182,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<label |
|
|
|
<label |
|
|
|
htmlFor="inline-checkbox-2" |
|
|
|
htmlFor="shareToFacebook" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
> |
|
|
|
> |
|
|
@ -180,8 +196,8 @@ function DeployPanel(): JSX.Element { |
|
|
|
</Form.Label> |
|
|
|
</Form.Label> |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<span |
|
|
|
<span |
|
|
|
data-id="remix_ai_switch" |
|
|
|
data-id="useNatSpec" |
|
|
|
id="remix_ai_switch" |
|
|
|
id="useNatSpec" |
|
|
|
className="btn ai-switch pl-0 py-0" |
|
|
|
className="btn ai-switch pl-0 py-0" |
|
|
|
onClick={async () => { |
|
|
|
onClick={async () => { |
|
|
|
getInfoFromNatSpec(!natSpec.checked); |
|
|
|
getInfoFromNatSpec(!natSpec.checked); |
|
|
@ -207,7 +223,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
</Form.Label> |
|
|
|
</Form.Label> |
|
|
|
<div className="d-flex py-1 align-items-center custom-control custom-checkbox"> |
|
|
|
<div className="d-flex py-1 align-items-center custom-control custom-checkbox"> |
|
|
|
<input |
|
|
|
<input |
|
|
|
id="inline-checkbox-3" |
|
|
|
id="verifiedByEtherscan" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
type="checkbox" |
|
|
|
type="checkbox" |
|
|
|
onChange={(e) => { |
|
|
|
onChange={(e) => { |
|
|
@ -220,7 +236,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<label |
|
|
|
<label |
|
|
|
htmlFor="inline-checkbox-3" |
|
|
|
htmlFor="verifiedByEtherscan" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
> |
|
|
|
> |
|
|
@ -234,7 +250,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
</Form.Label> |
|
|
|
</Form.Label> |
|
|
|
<div className="d-flex py-1 align-items-center custom-control custom-checkbox"> |
|
|
|
<div className="d-flex py-1 align-items-center custom-control custom-checkbox"> |
|
|
|
<input |
|
|
|
<input |
|
|
|
id="inline-checkbox-4" |
|
|
|
id="noTerminal" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
className="form-check-input custom-control-input" |
|
|
|
type="checkbox" |
|
|
|
type="checkbox" |
|
|
|
onChange={(e) => { |
|
|
|
onChange={(e) => { |
|
|
@ -247,7 +263,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<label |
|
|
|
<label |
|
|
|
htmlFor="inline-checkbox-4" |
|
|
|
htmlFor="noTerminal" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
className="m-0 form-check-label custom-control-label" |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
style={{ paddingTop: 1 }} |
|
|
|
> |
|
|
|
> |
|
|
@ -257,6 +273,7 @@ function DeployPanel(): JSX.Element { |
|
|
|
</Form.Group> |
|
|
|
</Form.Group> |
|
|
|
<ThemeUI /> |
|
|
|
<ThemeUI /> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
|
|
|
|
data-id="deployDapp" |
|
|
|
variant="primary" |
|
|
|
variant="primary" |
|
|
|
type="submit" |
|
|
|
type="submit" |
|
|
|
className="mt-3" |
|
|
|
className="mt-3" |
|
|
@ -267,21 +284,51 @@ function DeployPanel(): JSX.Element { |
|
|
|
)} |
|
|
|
)} |
|
|
|
<FormattedMessage id="quickDapp.deploy" /> |
|
|
|
<FormattedMessage id="quickDapp.deploy" /> |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
|
|
|
|
<Button |
|
|
|
|
|
|
|
data-id="teardownDapp" |
|
|
|
|
|
|
|
variant="primary" |
|
|
|
|
|
|
|
className="mt-3 ml-3" |
|
|
|
|
|
|
|
disabled={!formVal.email || !formVal.password || !formVal.subdomain} |
|
|
|
|
|
|
|
// hide this button for now, just for e2e use
|
|
|
|
|
|
|
|
style={{ display: 'none' }} |
|
|
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
|
|
setTeardownState({ code: '', error: '', loading: true }); |
|
|
|
|
|
|
|
teardown(formVal, (state) => { |
|
|
|
|
|
|
|
setTeardownState({ ...state, loading: false }); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{teardownState.loading && ( |
|
|
|
|
|
|
|
<i className="fas fa-spinner fa-spin mr-1"></i> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
<FormattedMessage id="quickDapp.teardown" /> |
|
|
|
|
|
|
|
</Button> |
|
|
|
{deployState.code === 'SUCCESS' && ( |
|
|
|
{deployState.code === 'SUCCESS' && ( |
|
|
|
<Alert variant="success" className="mt-4"> |
|
|
|
<Alert variant="success" className="mt-4" data-id="deploySuccess"> |
|
|
|
<FormattedMessage id="quickDapp.text4" /> <br /> <FormattedMessage id="quickDapp.text5" /> |
|
|
|
<FormattedMessage id="quickDapp.text4" /> <br /> <FormattedMessage id="quickDapp.text5" /> |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<a |
|
|
|
<a |
|
|
|
|
|
|
|
data-id="dappUrl" |
|
|
|
target="_blank" |
|
|
|
target="_blank" |
|
|
|
href={`https://${formVal.subdomain}.surge.sh`} |
|
|
|
href={`https://${formVal.subdomain}.surge.sh`} |
|
|
|
>{`https://${formVal.subdomain}.surge.sh`}</a> |
|
|
|
>{`https://${formVal.subdomain}.surge.sh`}</a> |
|
|
|
</Alert> |
|
|
|
</Alert> |
|
|
|
)} |
|
|
|
)} |
|
|
|
{deployState.error && ( |
|
|
|
{deployState.error && ( |
|
|
|
<Alert variant="danger" className="mt-4"> |
|
|
|
<Alert variant="danger" className="mt-4" data-id="deployFail"> |
|
|
|
{deployState.error} |
|
|
|
{deployState.error} |
|
|
|
</Alert> |
|
|
|
</Alert> |
|
|
|
)} |
|
|
|
)} |
|
|
|
|
|
|
|
{teardownState.code === 'SUCCESS' && ( |
|
|
|
|
|
|
|
<Alert variant="success" className="mt-4" data-id="teardownSuccess"> |
|
|
|
|
|
|
|
<FormattedMessage id="quickDapp.text6" /> |
|
|
|
|
|
|
|
</Alert> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
{teardownState.error && ( |
|
|
|
|
|
|
|
<Alert variant="danger" className="mt-4" data-id="teardownFail"> |
|
|
|
|
|
|
|
{teardownState.error} |
|
|
|
|
|
|
|
</Alert> |
|
|
|
|
|
|
|
)} |
|
|
|
</Form> |
|
|
|
</Form> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|