Skip to content

Commit

Permalink
Merge pull request #340 from LiskHQ/336-send-to-this-address
Browse files Browse the repository at this point in the history
Open send layover when coming from "send to this address" - Closes #336
  • Loading branch information
gina contrino authored Feb 13, 2018
2 parents 95ce3d5 + 91a0e33 commit 5de6103
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/components/accountVisual/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Gradients, gradientSchemes } from './gradients';
import breakpoints from './../../constants/breakpoints';
import styles from './accountVisual.css';

/*
Expand Down Expand Up @@ -163,7 +164,7 @@ const pickTwo = (chunk, options) => ([
class AccountVisual extends React.Component {
constructor(props) {
super(props);
this.state = { isMobile: window.innerWidth < 1024 };
this.state = { isMobile: window.innerWidth < breakpoints.m };
}

shouldComponentUpdate(nextProps, state) {
Expand All @@ -172,7 +173,7 @@ class AccountVisual extends React.Component {
}

resizeWindow() {
this.setState({ isMobile: window.innerWidth < 1024 });
this.setState({ isMobile: window.innerWidth < breakpoints.m });
}

componentDidMount() {
Expand Down
14 changes: 10 additions & 4 deletions src/components/send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import ResultBox from '../resultBox';
import SendWritable from '../sendWritable';
import SendReadable from './../sendReadable';
import PassphraseSteps from './../passphraseSteps';
import { parseSearchParams } from './../../utils/searchParams';
import breakpoints from './../../constants/breakpoints';
import styles from './styles.css';

class Send extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.address = parseSearchParams(props.search).address;
this.state = {
sendIsActive: false,
sendIsActive: !!this.address,
};
}

Expand All @@ -39,7 +42,10 @@ class Send extends React.Component {
</span>
<MultiStep finalCallback={this.setSendIsActive.bind(this, false)}
className={styles.wrapper}>
<SendWritable autoFocus={this.state.sendIsActive || window.innerWidth > 1024}/>
<SendWritable
autoFocus={this.state.sendIsActive || window.innerWidth > breakpoints.m}
address={this.address}
/>
<PassphraseSteps />
<SendReadable />
<ResultBox />
Expand Down
3 changes: 2 additions & 1 deletion src/components/send/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ describe('Send', () => {
context = {
storeState,
};
wrapper = mountWithContext(<Send/>, context);
wrapper = mountWithContext(<Send search={''}/>, context);
});

it('should render MultiStep component ', () => {
console.log(wrapper.debug());
expect(wrapper.find(MultiStep)).to.have.lengthOf(1);
});

Expand Down
3 changes: 1 addition & 2 deletions src/components/sendWritable/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { withRouter } from 'react-router-dom';

import { sent } from '../../actions/account';
import Send from './send';
Expand All @@ -15,4 +14,4 @@ const mapDispatchToProps = dispatch => ({
sent: data => dispatch(sent(data)),
});

export default withRouter(connect(mapStateToProps, mapDispatchToProps)(translate()(Send)));
export default connect(mapStateToProps, mapDispatchToProps)(translate()(Send));
4 changes: 1 addition & 3 deletions src/components/sendWritable/send.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { fromRawLsk } from '../../utils/lsk';
import { parseSearchParams } from './../../utils/searchParams';
import { Button } from './../toolbox/buttons/button';
import { authStatePrefill } from '../../utils/form';
import AccountVisual from '../accountVisual';
Expand All @@ -13,10 +12,9 @@ import inputTheme from './input.css';
class SendWritable extends React.Component {
constructor(props) {
super(props);
const { address } = parseSearchParams(props.history.location.search);
this.state = {
recipient: {
value: address || '',
value: this.props.address || '',
},
amount: {
value: '',
Expand Down
2 changes: 1 addition & 1 deletion src/components/transactionDashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TransactionsDashboard extends React.Component {
render() {
return <div className={`${grid.row} ${styles.wrapper}`}>
<div className={`${grid['col-md-4']} ${styles.gridPadding}`}>
<Send/>
<Send search={this.props.location.search}/>
</div>
<div className={`${grid['col-sm-12']} ${styles.transactions} ${grid['col-md-8']}`}>
<Transactions {...this.props} />
Expand Down
3 changes: 3 additions & 0 deletions src/constants/breakpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
m: 1024,
};
2 changes: 1 addition & 1 deletion test/integration/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('@integration: Wallet', () => {
store.dispatch(activePeerSet({ network: getNetwork(networks.mainnet.code) }));
accountAPIStub.withArgs(match.any).returnsPromise().resolves({ ...account });
store.dispatch(accountLoggedIn(account));
wrapper = mount(renderWithRouter(Wallet, store));
wrapper = mount(renderWithRouter(Wallet, store, { location: { search: '' } }));
};

const fillInputField = (value, field) => {
Expand Down

0 comments on commit 5de6103

Please sign in to comment.