Skip to content

Commit

Permalink
Merge branch 'master' into Nicknyr-master
Browse files Browse the repository at this point in the history
  • Loading branch information
gl2748 authored May 1, 2018
2 parents 878d56f + a3302e8 commit 94bc23b
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 77 deletions.
36 changes: 36 additions & 0 deletions src/app/components/elements/ConfirmTransfer/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';

const ConfirmTransfer = ({ operation }) => {
const info = Object.keys(operation).map((k, i) => {
return (
<div key={`transaction-group-${i}`} className="input-group">
<span
key={`transaction-label-${i}`}
className="input-group-label"
>
{k}
</span>
<input
className="input-group-field"
type="text"
required
value={operation[k]}
disabled={true}
key={`transaction-input-${i}`}
/>
</div>
);
});
return <div className="info">{info}</div>;
};

ConfirmTransfer.propTypes = {
operation: PropTypes.shape({
from: PropTypes.string,
to: PropTypes.string,
amount: PropTypes.string,
}).isRequired,
};

export default ConfirmTransfer;
66 changes: 44 additions & 22 deletions src/app/components/modules/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint react/prop-types: 0 */
import React, { PropTypes, Component } from 'react';
import { Map } from 'immutable';
import * as transactionActions from 'app/redux/TransactionReducer';
import * as globalActions from 'app/redux/GlobalReducer';
import * as userActions from 'app/redux/UserReducer';
Expand All @@ -15,7 +16,7 @@ import { SIGNUP_URL } from 'shared/constants';

class LoginForm extends Component {
static propTypes = {
//Steemit
// Steemit.
login_error: PropTypes.string,
onCancel: PropTypes.func,
};
Expand Down Expand Up @@ -268,6 +269,45 @@ class LoginForm extends Component {
? tt('loginform_jsx.password_info')
: null;

const isTransfer =
Map.isMap(loginBroadcastOperation) &&
loginBroadcastOperation.has('type') &&
loginBroadcastOperation
.get('type')
.toLowerCase()
.indexOf('transfer') >= 0;

const titleText = !isTransfer ? (
<h3>
{tt('loginform_jsx.returning_users')}
<span className="OpAction">{title}</span>
</h3>
) : (
<h3>
<span className="OpAction">
{tt('loginform_jsx.sign_transfer')}
</span>
</h3>
);

const signupLink = (
<div className="sign-up">
<hr />
<p>
{tt('loginform_jsx.join_our')}{' '}
<em>{tt('loginform_jsx.amazing_community')}</em>
{tt('loginform_jsx.to_comment_and_reward_others')}
</p>
<button
type="button"
className="button hollow"
onClick={this.SignUp}
>
{tt('loginform_jsx.sign_up_get_steem')}
</button>
</div>
);

const form = (
<form
onSubmit={handleSubmit(({ data }) => {
Expand All @@ -293,7 +333,7 @@ class LoginForm extends Component {
{...username.props}
onChange={usernameOnChange}
autoComplete="on"
disabled={submitting}
disabled={submitting || isTransfer}
/>
</div>
{username.touched && username.blur && username.error ? (
Expand Down Expand Up @@ -362,32 +402,15 @@ class LoginForm extends Component {
</button>
)}
</div>
<div className="sign-up">
<hr />
<p>
{tt('loginform_jsx.join_our')}{' '}
<em>{tt('loginform_jsx.amazing_community')}</em>
{tt('loginform_jsx.to_comment_and_reward_others')}
</p>
<button
type="button"
className="button hollow"
onClick={this.SignUp}
>
{tt('loginform_jsx.sign_up_get_steem')}
</button>
</div>
{!isTransfer && signupLink}
</form>
);

return (
<div className="LoginForm row">
<div className="column">
{message}
<h3>
{tt('loginform_jsx.returning_users')}
<span className="OpAction">{title}</span>
</h3>
{titleText}
{form}
</div>
</div>
Expand Down Expand Up @@ -433,7 +456,6 @@ export default connect(
const loginBroadcastOperation = state.user.get(
'loginBroadcastOperation'
);

const initialValues = {
saveLogin: saveLoginDefault,
};
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/modules/Transfer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as transactionActions from 'app/redux/TransactionReducer';
import * as userActions from 'app/redux/UserReducer';
import * as globalActions from 'app/redux/GlobalReducer';
import LoadingIndicator from 'app/components/elements/LoadingIndicator';
import ConfirmTransfer from 'app/components/elements/ConfirmTransfer';
import runTests, { browserTests } from 'app/utils/BrowserTests';
import {
validate_account_name,
Expand Down Expand Up @@ -503,7 +504,7 @@ class TransferForm extends Component {
>
{toVesting
? tt('g.power_up')
: tt('g.submit')}
: tt('g.next')}
</button>
{transferToSelf && (
<button
Expand Down Expand Up @@ -633,12 +634,11 @@ export default connect(
amount: parseFloat(amount, 10).toFixed(3) + ' ' + asset2,
memo: toVesting ? undefined : memo ? memo : '',
};

const confirm = () => <ConfirmTransfer operation={operation} />;
if (transferType === 'Savings Withdraw')
operation.request_id = Math.floor(
(Date.now() / 1000) % 4294967295
);

dispatch(
transactionActions.broadcastOperation({
type: toVesting
Expand All @@ -653,6 +653,7 @@ export default connect(
operation,
successCallback,
errorCallback,
confirm,
})
);
},
Expand Down
35 changes: 2 additions & 33 deletions src/app/components/pages/Market.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,37 +311,6 @@ class Market extends React.Component {
const orderbook = aggOrders(normalizeOrders(this.props.orderbook));
const { open_orders, open_orders_sort } = this.props;

// ORDERBOOK TABLE GENERATOR
// function table(orderbook, side = 'bids', callback = ((price,steem,sbd) => {})) {
//
// let rows = orderbook[side].slice(0, 25).map( (o,i) =>
// <OrderbookRow side={side} onClick={e => {callback( o.price, o.steem_depth, o.sbd_depth) }} />
// );
//
// return
// }

function normalizeOpenOrders(open_orders) {
return open_orders.map(o => {
const type =
o.sell_price.base.indexOf(LIQUID_TICKER) > 0
? 'ask'
: 'bid';
//{orderid: o.orderid,
// created: o.created,
return {
...o,
type: type,
price: parseFloat(
type == 'ask' ? o.real_price : o.real_price
),
steem:
type == 'ask' ? o.sell_price.base : o.sell_price.quote,
sbd: type == 'bid' ? o.sell_price.base : o.sell_price.quote,
};
});
}

// Logged-in user's open orders
function open_orders_table(open_orders, open_orders_sort) {
const rows =
Expand Down Expand Up @@ -407,11 +376,11 @@ class Market extends React.Component {
</th>
<th
className={classNames(
activeClass('real_price'),
activeClass('price'),
'sortable'
)}
onClick={e =>
handleToggleOpenOrdersSort('real_price')
handleToggleOpenOrdersSort('price')
}
>
{tt('g.price')}
Expand Down
6 changes: 4 additions & 2 deletions src/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,8 @@
"signup_button_emphasis": "FREE STEEM!",
"sign_up_get_steem": "Sign up. Get STEEM!",
"returning_users": "Returning Users: ",
"join_our": "Join our"
"join_our": "Join our",
"sign_transfer": "Sign to complete transfer"
},
"chainvalidation_js": {
"account_name_should_not_be_empty": "Account name should not be empty.",
Expand Down Expand Up @@ -823,7 +824,8 @@
"beware_of_spam_and_phishing_links":
"Beware of spam and phishing links in transfer memos. Do not open links from users you do not trust. Do not provide your private keys to any third party websites.",
"autocomplete_previous_transfers": "previous transfers",
"autocomplete_user_following": "following"
"autocomplete_user_following": "following",
"confirm_transfer": "Transfer %(amount)s from %(from)s to %(to)s?"
},
"userwallet_jsx": {
"transfer": "Transfer",
Expand Down
18 changes: 7 additions & 11 deletions src/app/redux/MarketReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@ export default function reducer(state = defaultState, action = {}) {
o.sell_price.base.indexOf(LIQUID_TICKER) > 0
? 'ask'
: 'bid';
const sbd =
type == 'bid' ? o.sell_price.base : o.sell_price.quote;
const steem =
type == 'ask' ? o.sell_price.base : o.sell_price.quote;
return {
...o,
type: type,
price: parseFloat(
type == 'ask' ? o.real_price : o.real_price
),
steem:
type == 'ask'
? o.sell_price.base
: o.sell_price.quote,
sbd:
type == 'bid'
? o.sell_price.base
: o.sell_price.quote,
price: parseFloat(sbd) / parseFloat(steem),
steem,
sbd,
};
})
.sort(createOrderSorter(getValue, column, dir));
Expand Down
12 changes: 6 additions & 6 deletions src/app/redux/MarketReducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const someOpenOrders = [
base: '3.000 STEEM',
quote: '1.998 SBD',
},
real_price: '0.66600000000000004',
real_price: '0',
rewarded: false,
},
{
Expand All @@ -31,7 +31,7 @@ const someOpenOrders = [
base: '7.000 STEEM',
quote: '4.578 SBD',
},
real_price: '0.65400000000000003',
real_price: '0',
rewarded: false,
},
{
Expand All @@ -45,7 +45,7 @@ const someOpenOrders = [
base: '3.000 STEEM',
quote: '1.953 SBD',
},
real_price: '0.65100000000000002',
real_price: '0',
rewarded: false,
},
{
Expand All @@ -59,7 +59,7 @@ const someOpenOrders = [
base: '0.507 SBD',
quote: '1.000 STEEM',
},
real_price: '0.50700000000000001',
real_price: '0',
rewarded: false,
},
{
Expand All @@ -73,13 +73,13 @@ const someOpenOrders = [
base: '0.507 SBD',
quote: '1.000 STEEM',
},
real_price: '0.50700000000000001',
real_price: '0',
rewarded: false,
},
];

const toggleSortByPrice = {
column: 'real_price',
column: 'price',
dataType: 'float',
};

Expand Down

0 comments on commit 94bc23b

Please sign in to comment.