Allow boolean dropdowns for contract deploy (#3077)
* Allow boolean dropdowns for contract deploy * Be explicit in deployment types * Extra line as per PR comments
This commit is contained in:
		
							parent
							
								
									9b1f67b2dd
								
							
						
					
					
						commit
						f3d4aa43f3
					
				@ -15,8 +15,9 @@
 | 
				
			|||||||
// along with Parity.  If not, see <http://www.gnu.org/licenses/>.
 | 
					// along with Parity.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import React, { Component, PropTypes } from 'react';
 | 
					import React, { Component, PropTypes } from 'react';
 | 
				
			||||||
 | 
					import { MenuItem } from 'material-ui';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { AddressSelect, Form, Input, InputAddressSelect } from '../../../ui';
 | 
					import { AddressSelect, Form, Input, InputAddressSelect, Select } from '../../../ui';
 | 
				
			||||||
import { validateAbi } from '../../../util/validation';
 | 
					import { validateAbi } from '../../../util/validation';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import styles from '../deployContract.css';
 | 
					import styles from '../deployContract.css';
 | 
				
			||||||
@ -98,6 +99,7 @@ export default class DetailsStep extends Component {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return inputs.map((input, index) => {
 | 
					    return inputs.map((input, index) => {
 | 
				
			||||||
      const onChange = (event, value) => this.onParamChange(index, value);
 | 
					      const onChange = (event, value) => this.onParamChange(index, value);
 | 
				
			||||||
 | 
					      const onChangeBool = (event, _index, value) => this.onParamChange(index, value === 'true');
 | 
				
			||||||
      const onSubmit = (value) => this.onParamChange(index, value);
 | 
					      const onSubmit = (value) => this.onParamChange(index, value);
 | 
				
			||||||
      const label = `${input.name}: ${input.type}`;
 | 
					      const label = `${input.name}: ${input.type}`;
 | 
				
			||||||
      let inputBox = null;
 | 
					      let inputBox = null;
 | 
				
			||||||
@ -115,6 +117,26 @@ export default class DetailsStep extends Component {
 | 
				
			|||||||
          );
 | 
					          );
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case 'bool':
 | 
				
			||||||
 | 
					          const boolitems = ['false', 'true'].map((bool) => {
 | 
				
			||||||
 | 
					            return (
 | 
				
			||||||
 | 
					              <MenuItem
 | 
				
			||||||
 | 
					                key={ bool }
 | 
				
			||||||
 | 
					                value={ bool }
 | 
				
			||||||
 | 
					                label={ bool }>{ bool }</MenuItem>
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					          inputBox = (
 | 
				
			||||||
 | 
					            <Select
 | 
				
			||||||
 | 
					              label={ label }
 | 
				
			||||||
 | 
					              value={ params[index] ? 'true' : 'false' }
 | 
				
			||||||
 | 
					              error={ paramsError[index] }
 | 
				
			||||||
 | 
					              onChange={ onChangeBool }>
 | 
				
			||||||
 | 
					              { boolitems }
 | 
				
			||||||
 | 
					            </Select>
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
          inputBox = (
 | 
					          inputBox = (
 | 
				
			||||||
            <Input
 | 
					            <Input
 | 
				
			||||||
@ -164,12 +186,28 @@ export default class DetailsStep extends Component {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      inputs.forEach((input) => {
 | 
					      inputs.forEach((input) => {
 | 
				
			||||||
        switch (input.type) {
 | 
					        switch (input.type) {
 | 
				
			||||||
 | 
					          case 'address':
 | 
				
			||||||
 | 
					            params.push('0x');
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          case 'bool':
 | 
				
			||||||
 | 
					            params.push(false);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          case 'bytes':
 | 
				
			||||||
 | 
					            params.push('0x');
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          case 'uint':
 | 
				
			||||||
 | 
					            params.push('0');
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          case 'string':
 | 
					          case 'string':
 | 
				
			||||||
            params.push('');
 | 
					            params.push('');
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          default:
 | 
					          default:
 | 
				
			||||||
            params.push('0x');
 | 
					            params.push('0');
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user