Skip to content

Commit

Permalink
Merge pull request #550 from LiskHQ/280-send-launch-protocol
Browse files Browse the repository at this point in the history
Fix the launch protocol for send - Closes #280
  • Loading branch information
gina contrino authored Mar 13, 2018
2 parents 9c9a1d6 + 6b38fd6 commit b4d8019
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/components/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import styles from './dashboard.css';

class Dashboard extends React.Component {
render() {
const { transactions, t } = this.props;
const { transactions, t, history, accountAddress, loading } = this.props;
return <div className={`${grid.row} ${styles.wrapper}`}>
<div className={`${grid['col-md-8']} ${grid['col-xs-12']} ${styles.main}`}>
<Box className={`${styles.graph}`}>
Expand All @@ -31,14 +31,14 @@ class Dashboard extends React.Component {
<TransactionList {...{
transactions,
t,
address: this.props.accountAddress,
address: accountAddress,
dashboard: true,
loading: this.props.loading,
loading,
}} />
</Box>
</div>
<div className={`${grid['col-md-4']} ${styles.sendWrapper}`}>
<Send/>
<Send history={history} />
</div>
</div>;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/dashboard/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Dashboard', () => {
account: { address: 'some address' },
},
};
wrapper = mountWithContext(<Dashboard/>, context);
wrapper = mountWithContext(<Dashboard history={ { location: {} } }/>, context);
});

it('should render transaction list with at most 3 transactions', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/resultBox/resultBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class ResultBox extends React.Component {

<footer>
<Button className={`okay-button ${styles.okButton}`}
onClick={() => { this.props.finalCallback(); this.props.reset(); } }>
onClick={() => {
this.props.finalCallback();
this.props.reset();
this.props.history.push(this.props.history.location.pathname);
}}>
{this.props.t('Okay')}
</Button>
<div className='subTitle'>{this.props.subTitle}</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/resultBox/resultBox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Result Box', () => {
copyToClipboard: () => {},
finalCallback: () => {},
t: () => {},
history: { location: {}, push: () => {} },
};

wrapper = mount(<ResultBox {...props} />, options);
Expand Down
12 changes: 8 additions & 4 deletions src/components/send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ import styles from './send.css';
class Send extends React.Component {
constructor(props) {
super(props);
this.address = parseSearchParams(props.search).address;
this.state = {
sendIsActive: !!this.address,
sendIsActive: !!this.getSearchParams().address || !!this.getSearchParams().amount,
};
}

getSearchParams() {
return parseSearchParams(this.props.history.location.search);
}

setSendIsActive(sendIsActive) {
this.setState({ sendIsActive });
}
Expand All @@ -44,11 +47,12 @@ class Send extends React.Component {
className={styles.wrapper}>
<SendWritable
autoFocus={this.state.sendIsActive || window.innerWidth > breakpoints.m}
address={this.address}
address={this.getSearchParams().address}
amount={this.getSearchParams().amount}
/>
<PassphraseSteps />
<SendReadable />
<ResultBox />
<ResultBox history={this.props.history}/>
</MultiStep>
</Box>
</Fragment>
Expand Down
2 changes: 1 addition & 1 deletion src/components/send/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Send', () => {
context = {
storeState,
};
wrapper = mountWithContext(<Send search={''}/>, context);
wrapper = mountWithContext(<Send history={ { location: {} } }/>, context);
});

it('should render MultiStep component ', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/sendWritable/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SendWritable extends React.Component {
value: this.props.address || '',
},
amount: {
value: '',
value: this.props.amount || '',
},
...authStatePrefill(),
};
Expand All @@ -35,7 +35,7 @@ class SendWritable extends React.Component {
value: this.props.prevState.recipient || this.state.recipient.value,
},
amount: {
value: this.props.prevState.amount || '',
value: this.props.prevState.amount || this.state.amount.value,
},
...authStatePrefill(this.props.account),
};
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']}`}>
<Send search={this.props.location.search}/>
<Send history={this.props.history} />
</div>
<div className={`${grid['col-sm-12']} ${styles.transactions} ${grid['col-md-8']}`}>
<Transactions {...this.props} />
Expand Down
2 changes: 1 addition & 1 deletion test/integration/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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, { location: { search: '' } }));
wrapper = mount(renderWithRouter(Wallet, store, { history: { location: { search: '' } } }));
helper = new Helper(wrapper, store);
};

Expand Down

0 comments on commit b4d8019

Please sign in to comment.