Skip to content

Commit

Permalink
Merge pull request #80 from rnsdomains/develop
Browse files Browse the repository at this point in the history
v2.0-beta.6 release merge.
  • Loading branch information
ilanolkies authored Nov 29, 2019
2 parents 517ab9b + f08c9a2 commit 2ea8aad
Show file tree
Hide file tree
Showing 23 changed files with 452 additions and 135 deletions.
11 changes: 9 additions & 2 deletions src/app/components/GetDomainStateComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class GetDomainStateComponent extends Component {
}

render() {
const { strings, domain, getDomainState } = this.props;
const {
strings, domain, getDomainState, disableSearchButton,
} = this.props;

const { invalid } = this.state;

Expand All @@ -47,7 +49,10 @@ class GetDomainStateComponent extends Component {
className={invalid ? 'is-invalid' : null}
/>
<InputGroup.Append>
<Button type="submit" size="sm">{strings.search}</Button>
<InputGroup.Text>{strings.rskTld}</InputGroup.Text>
</InputGroup.Append>
<InputGroup.Append>
<Button type="submit" size="sm" disabled={disableSearchButton}>{strings.search}</Button>
</InputGroup.Append>
<div className="invalid-feedback">
{invalid}
Expand All @@ -63,8 +68,10 @@ GetDomainStateComponent.propTypes = {
strings: propTypes.shape({
search: propTypes.string.isRequired,
invalid_name: propTypes.string.isRequired,
rskTld: propTypes.string.isRequired,
}).isRequired,
domain: propTypes.string,
disableSearchButton: propTypes.bool.isRequired,
getDomainState: propTypes.func.isRequired,
};

Expand Down
1 change: 1 addition & 0 deletions src/app/containers/GetDomainStateContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GetDomainStateComponent } from '../components';

const mapStateToProps = state => ({
domain: parse(state.router.location.search).domain,
disableSearchButton: (state.registrar.committing || state.registrar.committed) && state.router.location.pathname === '/registrar',
});

const mapDispatchToProps = dispatch => ({
Expand Down
22 changes: 20 additions & 2 deletions src/app/tabs/registrar/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
REQUEST_REGISTRAR_GET_COST, RECEIVE_REGISTRAR_GET_COST,
REQUEST_REGISTRAR_COMMIT, RECEIVE_REGISTRAR_COMMIT, ERROR_REGISTRAR_COMMIT,
REQUEST_REGISTRAR_REVEAL_COMMIT, RECEIVE_REGISTRAR_REVEAL_COMMIT,
RECEIVE_CAN_REVEAL_COMMIT,
RECEIVE_CAN_REVEAL_COMMIT, ERROR_REGISTRAR_REVEAL_COMMIT, SALT_NOT_FOUND,
REGISTRAR_COMMIT_CONFIRMED, REVEAL_COMMIT_CONFIRMED,
} from './types';

export const requestGetCost = duration => ({
Expand All @@ -19,9 +20,10 @@ export const requestCommitRegistrar = () => ({
type: REQUEST_REGISTRAR_COMMIT,
});

export const receiveCommitRegistrar = hash => ({
export const receiveCommitRegistrar = (hash, commitConfirmed) => ({
type: RECEIVE_REGISTRAR_COMMIT,
hash,
commitConfirmed,
});

export const errorRegistrarCommit = () => ({
Expand All @@ -36,7 +38,23 @@ export const receiveRevealCommit = () => ({
type: RECEIVE_REGISTRAR_REVEAL_COMMIT,
});

export const errorRevealCommit = () => ({
type: ERROR_REGISTRAR_REVEAL_COMMIT,
});

export const receiveCanRevealCommit = canReveal => ({
type: RECEIVE_CAN_REVEAL_COMMIT,
canReveal,
});

export const saltNotFound = () => ({
type: SALT_NOT_FOUND,
});

export const commitTxMined = () => ({
type: REGISTRAR_COMMIT_CONFIRMED,
});

export const revealTxMined = () => ({
type: REVEAL_COMMIT_CONFIRMED,
});
90 changes: 49 additions & 41 deletions src/app/tabs/registrar/components/CommitComponent.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
import React from 'react';
import React, { Component } from 'react';
import { multilanguage } from 'redux-multilanguage';
import propTypes from 'prop-types';
import {
Container, Row, Col, Spinner, Button,
} from 'react-bootstrap';

const CommitComponent = (props) => {
const {
committing, strings, doCommitment, committed,
} = props;
class CommitComponent extends Component {
componentDidMount() {
const { checkIfAlreadyCommitted } = this.props;
checkIfAlreadyCommitted();
}

return (
<Container>
<Row>
<Col md={6} className="offset-md-3">
<p>
2.
{strings.process_step_1_explanation}
</p>
</Col>
</Row>
<Row>
<Col>
{
committing
? <Spinner animation="grow" variant="primary" />
: (
<Button
disabled={committing || committed}
onClick={doCommitment}
>
{strings.process_step_1}
</Button>
)
}
</Col>
</Row>
<Row>
<Col md={8} className="offset-md-2">
<i>
{strings.process_step_2_explanation}
</i>
</Col>
</Row>
</Container>
);
};
render() {
const {
committing, strings, doCommitment, committed,
} = this.props;

return (
<Container>
<Row>
<Col md={6} className="offset-md-3">
<p>
2.
{strings.process_step_1_explanation}
</p>
</Col>
</Row>
<Row>
<Col>
{
committing
? <Spinner animation="grow" variant="primary" />
: (
<Button
disabled={committing || committed}
onClick={doCommitment}
>
{strings.process_step_1}
</Button>
)
}
</Col>
</Row>
<Row>
<Col md={8} className="offset-md-2">
<i>
{strings.process_step_2_explanation}
</i>
</Col>
</Row>
</Container>
);
}
}

CommitComponent.propTypes = {
strings: propTypes.shape({
Expand All @@ -54,6 +61,7 @@ CommitComponent.propTypes = {
process_step_2_explanation: propTypes.string.isRequired,
}).isRequired,
doCommitment: propTypes.func.isRequired,
checkIfAlreadyCommitted: propTypes.func.isRequired,
committing: propTypes.bool.isRequired,
committed: propTypes.bool.isRequired,
};
Expand Down
86 changes: 63 additions & 23 deletions src/app/tabs/registrar/components/RegistrarComponent.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,78 @@
import React from 'react';
import React, { Component } from 'react';
import propTypes from 'prop-types';
import { multilanguage } from 'redux-multilanguage';
import { Link } from 'react-router-dom';
import { Card, Spinner } from 'react-bootstrap';
import { TabWithSearchComponent } from '../../../components';
import { RentalPeriodContainer, CommitContainer, RevealContainer } from '../containers';

const RegistrarComponent = (props) => {
const {
strings, domain,
} = props;

return (
<div>
<TabWithSearchComponent>
<h2>
{strings.start_registration_for}
{' '}
<code>{domain}</code>
</h2>
<h4>registering a name requires you to complete 3 steps</h4>
<RentalPeriodContainer />
<hr />
<CommitContainer />
<RevealContainer />
</TabWithSearchComponent>
</div>
);
};
class RegistrarComponent extends Component {
componentDidMount() {
const { domain, getState } = this.props;
if (domain && getState) getState(domain);
}

render() {
const {
strings, domain, owned, blocked, domainStateLoading,
} = this.props;

let elementToRender;

if (domainStateLoading) {
elementToRender = <Spinner animation="grow" variant="primary" />;
} else if (owned) {
elementToRender = (
<Card.Text>
{strings.owned}
<br />
<Link to={`/admin?domain=${domain}`} className="btn btn-primary">{strings.admin_your_domain_title}</Link>
</Card.Text>
);
} else if (blocked) {
elementToRender = <h4>{strings.domain_not_available}</h4>;
} else {
const domainDisplay = `${domain}.rsk`;

elementToRender = (
<div>
<h2>
{strings.start_registration_for}
{' '}
<code>{domainDisplay}</code>
</h2>
<h4>registering a name requires you to complete 3 steps</h4>
<RentalPeriodContainer />
<hr />
<CommitContainer />
<RevealContainer />
</div>
);
}

return (
<div>
<TabWithSearchComponent>
{elementToRender}
</TabWithSearchComponent>
</div>
);
}
}

RegistrarComponent.propTypes = {
strings: propTypes.shape({
start_registration_for: propTypes.string.isRequired,
rental_period: propTypes.string.isRequired,
domain_not_available: propTypes.string.isRequired,
admin_your_domain_title: propTypes.string.isRequired,
owned: propTypes.string.isRequired,
}).isRequired,
domain: propTypes.string.isRequired,
domainStateLoading: propTypes.string.isRequired,
owned: propTypes.bool.isRequired,
blocked: propTypes.bool.isRequired,
getState: propTypes.func.isRequired,
};

export default multilanguage(RegistrarComponent);
Loading

0 comments on commit 2ea8aad

Please sign in to comment.