Disable time conditions in Tx UI #6445

This commit is contained in:
maciejhirsz 2017-09-25 17:08:09 +02:00
parent b74065a471
commit 0e43ce6e07
8 changed files with 68 additions and 27 deletions

View File

@ -188,6 +188,10 @@ export default class LocalAccountsMiddleware extends Middleware {
return []; return [];
}); });
register('parity_lockedHardwareAccountsInfo', () => {
return [];
});
register('parity_hashContent', () => { register('parity_hashContent', () => {
throw new Error('Functionality unavailable on a public wallet.'); throw new Error('Functionality unavailable on a public wallet.');
}); });

View File

@ -66,6 +66,7 @@ class DeployContract extends Component {
}; };
static propTypes = { static propTypes = {
availability: PropTypes.string.isRequired,
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
abi: PropTypes.string, abi: PropTypes.string,
code: PropTypes.string, code: PropTypes.string,
@ -331,6 +332,7 @@ class DeployContract extends Component {
return ( return (
<Extras <Extras
availability={ this.props.availability }
gasStore={ this.gasStore } gasStore={ this.gasStore }
hideData hideData
isEth isEth
@ -490,9 +492,11 @@ class DeployContract extends Component {
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { gasLimit } = state.nodeStatus; const { gasLimit, nodeKind = {} } = state.nodeStatus;
const { availability = 'unknown' } = nodeKind;
return { return {
availability,
gasLimit gasLimit
}; };
} }

View File

@ -22,15 +22,19 @@ import styles from '../executeContract.css';
export default class AdvancedStep extends Component { export default class AdvancedStep extends Component {
static propTypes = { static propTypes = {
availability: PropTypes.string.isRequired,
gasStore: PropTypes.object.isRequired gasStore: PropTypes.object.isRequired
}; };
render () { render () {
const { gasStore } = this.props; const { availability, gasStore } = this.props;
return ( return (
<div className={ styles.gaseditor }> <div className={ styles.gaseditor }>
<GasPriceEditor store={ gasStore } /> <GasPriceEditor
availability={ availability }
store={ gasStore }
/>
</div> </div>
); );
} }

View File

@ -57,6 +57,7 @@ class ExecuteContract extends Component {
}; };
static propTypes = { static propTypes = {
availability: PropTypes.string.isRequired,
accounts: PropTypes.object, accounts: PropTypes.object,
contract: PropTypes.object.isRequired, contract: PropTypes.object.isRequired,
fromAddress: PropTypes.string, fromAddress: PropTypes.string,
@ -198,7 +199,7 @@ class ExecuteContract extends Component {
} }
renderStep () { renderStep () {
const { accounts, contract, fromAddress, onFromAddressChange } = this.props; const { availability, accounts, contract, fromAddress, onFromAddressChange } = this.props;
const { step } = this.state; const { step } = this.state;
if (step === STEP_DETAILS) { if (step === STEP_DETAILS) {
@ -218,7 +219,10 @@ class ExecuteContract extends Component {
} }
return ( return (
<AdvancedStep gasStore={ this.gasStore } /> <AdvancedStep
availability={ availability }
gasStore={ this.gasStore }
/>
); );
} }
@ -337,9 +341,10 @@ class ExecuteContract extends Component {
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { gasLimit } = state.nodeStatus; const { gasLimit, nodeKind = {} } = state.nodeStatus;
const { availability = 'unknown' } = nodeKind;
return { gasLimit }; return { availability, gasLimit };
} }
export default connect( export default connect(

View File

@ -23,6 +23,7 @@ import styles from '../transfer.css';
export default class Extras extends Component { export default class Extras extends Component {
static propTypes = { static propTypes = {
availability: PropTypes.string.isRequired,
data: PropTypes.string, data: PropTypes.string,
dataError: PropTypes.string, dataError: PropTypes.string,
hideData: PropTypes.bool, hideData: PropTypes.bool,
@ -38,13 +39,14 @@ export default class Extras extends Component {
}; };
render () { render () {
const { gasStore, onChange } = this.props; const { availability, gasStore, onChange } = this.props;
return ( return (
<Form> <Form>
{ this.renderData() } { this.renderData() }
<div className={ styles.gaseditor }> <div className={ styles.gaseditor }>
<GasPriceEditor <GasPriceEditor
availability={ availability }
store={ gasStore } store={ gasStore }
onChange={ onChange } onChange={ onChange }
/> />

View File

@ -42,6 +42,7 @@ class Transfer extends Component {
} }
static propTypes = { static propTypes = {
availability: PropTypes.string.isRequired,
newError: PropTypes.func.isRequired, newError: PropTypes.func.isRequired,
gasLimit: PropTypes.object.isRequired, gasLimit: PropTypes.object.isRequired,
@ -186,6 +187,7 @@ class Transfer extends Component {
onChange={ this.store.onUpdateDetails } onChange={ this.store.onUpdateDetails }
total={ total } total={ total }
totalError={ totalError } totalError={ totalError }
availability={ this.props.availability }
/> />
); );
} }
@ -291,13 +293,14 @@ function mapStateToProps (initState, initProps) {
: null; : null;
return (state) => { return (state) => {
const { gasLimit } = state.nodeStatus; const { gasLimit, nodeKind = {} } = state.nodeStatus;
const { balances } = state; const { balances } = state;
const { availability = 'unknown' } = nodeKind;
const balance = balances[address]; const balance = balances[address];
const sendersBalances = senders ? pick(balances, Object.keys(senders)) : null; const sendersBalances = senders ? pick(balances, Object.keys(senders)) : null;
return { balance, gasLimit, senders, sendersBalances, tokens, wallet }; return { availability, balance, gasLimit, senders, sendersBalances, tokens, wallet };
}; };
} }

View File

@ -64,7 +64,8 @@ export default class GasPriceEditor extends Component {
static propTypes = { static propTypes = {
children: PropTypes.node, children: PropTypes.node,
onChange: PropTypes.func, onChange: PropTypes.func,
store: PropTypes.object.isRequired store: PropTypes.object.isRequired,
availability: PropTypes.string.isRequired
} }
static Store = Store; static Store = Store;
@ -72,7 +73,7 @@ export default class GasPriceEditor extends Component {
render () { render () {
const { api } = this.context; const { api } = this.context;
const { children, store } = this.props; const { children, store } = this.props;
const { conditionType, errorGas, errorPrice, errorTotal, estimated, gas, histogram, price, priceDefault, totalValue } = store; const { errorGas, errorPrice, errorTotal, estimated, gas, histogram, price, priceDefault, totalValue } = store;
const eth = api.util.fromWei(totalValue).toFormat(); const eth = api.util.fromWei(totalValue).toFormat();
const gasLabel = `gas (estimated: ${new BigNumber(estimated).toFormat()})`; const gasLabel = `gas (estimated: ${new BigNumber(estimated).toFormat()})`;
@ -80,18 +81,7 @@ export default class GasPriceEditor extends Component {
return ( return (
<div className={ styles.container }> <div className={ styles.container }>
<RadioButtons { this.renderConditionRadioButtons() }
className={ styles.conditionRadio }
label={
<FormattedMessage
id='txEditor.condition.label'
defaultMessage='Condition where transaction activates'
/>
}
onChange={ this.onChangeConditionType }
value={ conditionType }
values={ CONDITION_VALUES }
/>
{ this.renderConditions() } { this.renderConditions() }
<div className={ styles.graphContainer }> <div className={ styles.graphContainer }>
@ -148,10 +138,35 @@ export default class GasPriceEditor extends Component {
); );
} }
renderConditionRadioButtons () {
const { availability } = this.props;
const { conditionType } = this.props.store;
if (availability !== 'personal') {
return null;
}
return (
<RadioButtons
className={ styles.conditionRadio }
label={
<FormattedMessage
id='txEditor.condition.label'
defaultMessage='Condition where transaction activates'
/>
}
onChange={ this.onChangeConditionType }
value={ conditionType }
values={ CONDITION_VALUES }
/>
);
}
renderConditions () { renderConditions () {
const { availability } = this.props;
const { conditionType, condition, conditionBlockError } = this.props.store; const { conditionType, condition, conditionBlockError } = this.props.store;
if (conditionType === CONDITIONS.NONE) { if (conditionType === CONDITIONS.NONE || availability !== 'personal') {
return null; return null;
} }

View File

@ -36,6 +36,7 @@ class TransactionPending extends Component {
}; };
static propTypes = { static propTypes = {
availability: PropTypes.string.isRequired,
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
className: PropTypes.string, className: PropTypes.string,
date: PropTypes.instanceOf(Date).isRequired, date: PropTypes.instanceOf(Date).isRequired,
@ -140,11 +141,11 @@ class TransactionPending extends Component {
} }
renderTxEditor () { renderTxEditor () {
const { className } = this.props; const { availability, className } = this.props;
return ( return (
<div className={ `${styles.container} ${className}` }> <div className={ `${styles.container} ${className}` }>
<GasPriceEditor store={ this.gasStore }> <GasPriceEditor availability={ availability } store={ this.gasStore }>
<Button <Button
label={ label={
<FormattedMessage <FormattedMessage
@ -190,9 +191,12 @@ class TransactionPending extends Component {
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { nodeKind = {} } = state.nodeStatus;
const { accounts } = state.personal; const { accounts } = state.personal;
const { availability = 'unknown' } = nodeKind;
return { return {
availability,
accounts accounts
}; };
} }