Queries display IdentityIcons (#3453)

This commit is contained in:
Jaco Greeff 2016-11-15 19:08:16 +01:00 committed by GitHub
parent 039bd3c9f9
commit 6efdc08044
5 changed files with 58 additions and 29 deletions

View File

@ -30,6 +30,10 @@
.iconDisabled { .iconDisabled {
position: absolute; position: absolute;
top: 35px; top: 35px;
&.noLabel {
top: 10px;
}
} }
.icon { .icon {

View File

@ -69,14 +69,19 @@ class InputAddress extends Component {
} }
renderIcon () { renderIcon () {
const { value, disabled } = this.props; const { value, disabled, label } = this.props;
if (!value || !value.length || !util.isAddressValid(value)) { if (!value || !value.length || !util.isAddressValid(value)) {
return null; return null;
} }
const classes = [disabled ? styles.iconDisabled : styles.icon];
if (!label) {
classes.push(styles.noLabel);
}
return ( return (
<div className={ disabled ? styles.iconDisabled : styles.icon }> <div className={ classes.join(' ') }>
<IdentityIcon <IdentityIcon
inline center inline center
address={ value } /> address={ value } />

View File

@ -19,7 +19,7 @@ import React, { Component, PropTypes } from 'react';
import LinearProgress from 'material-ui/LinearProgress'; import LinearProgress from 'material-ui/LinearProgress';
import { Card, CardActions, CardTitle, CardText } from 'material-ui/Card'; import { Card, CardActions, CardTitle, CardText } from 'material-ui/Card';
import { Button, Input, InputAddressSelect } from '../../../ui'; import { Button, Input, InputAddress, InputAddressSelect } from '../../../ui';
import styles from './queries.css'; import styles from './queries.css';
@ -96,32 +96,48 @@ export default class InputQuery extends Component {
} }
if (!results || results.length < 1) return null; if (!results || results.length < 1) return null;
return outputs return outputs
.map((out, index) => ({ .map((out, index) => ({
name: out.name, name: out.name,
type: out.type,
value: results[index], value: results[index],
display: this.renderValue(results[index]) display: this.renderValue(results[index])
})) }))
.sort((outA, outB) => outA.display.length - outB.display.length) .sort((outA, outB) => outA.display.length - outB.display.length)
.map((out, index) => ( .map((out, index) => {
<div key={ index }> let input = null;
<div className={ styles.queryResultName }> if (out.type === 'address') {
{ out.name } input = (
</div> <InputAddress
className={ styles.queryValue }
disabled
value={ out.display }
/>
);
} else {
input = (
<Input <Input
className={ styles.queryValue } className={ styles.queryValue }
readOnly readOnly
allowCopy allowCopy
value={ out.display } value={ out.display }
/> />
<br /> );
}
return (
<div key={ index }>
<div className={ styles.queryResultName }>
{ out.name }
</div> </div>
)); { input }
</div>
);
});
} }
renderInput (input) { renderInput (input) {
const { values } = this.state;
const { name, type } = input; const { name, type } = input;
const label = `${name ? `${name}: ` : ''}${type}`; const label = `${name ? `${name}: ` : ''}${type}`;
@ -143,6 +159,7 @@ export default class InputQuery extends Component {
<InputAddressSelect <InputAddressSelect
hint={ type } hint={ type }
label={ label } label={ label }
value={ values[name] }
required required
onChange={ onChange } onChange={ onChange }
/> />
@ -155,6 +172,7 @@ export default class InputQuery extends Component {
<Input <Input
hint={ type } hint={ type }
label={ label } label={ label }
value={ values[name] }
required required
onChange={ onChange } onChange={ onChange }
/> />

View File

@ -56,18 +56,10 @@
} }
.methodResults { .methodResults {
display: flex;
flex-wrap: wrap;
max-width: 24rem;
justify-content: space-around;
} }
.methodResults > div { .methodResults > div {
padding: 0.25rem 0.5rem; padding: 0.25rem 0.5rem;
display: flex;
flex-direction: column;
align-items: center;
flex: 1 1 50%;
box-sizing: border-box; box-sizing: border-box;
& > div { & > div {

View File

@ -19,7 +19,7 @@ import React, { Component, PropTypes } from 'react';
import { Card, CardTitle, CardText } from 'material-ui/Card'; import { Card, CardTitle, CardText } from 'material-ui/Card';
import InputQuery from './inputQuery'; import InputQuery from './inputQuery';
import { Container, ContainerTitle, Input } from '../../../ui'; import { Container, ContainerTitle, Input, InputAddress } from '../../../ui';
import styles from './queries.css'; import styles from './queries.css';
@ -100,14 +100,14 @@ export default class Queries extends Component {
<CardText <CardText
className={ styles.methodContent } className={ styles.methodContent }
> >
{ this.renderValue(values[fn.name]) } { this.renderValue(values[fn.name], fn.outputs[0].kind.type) }
</CardText> </CardText>
</Card> </Card>
</div> </div>
); );
} }
renderValue (value) { renderValue (value, type) {
if (typeof value === 'undefined') { if (typeof value === 'undefined') {
return null; return null;
} }
@ -125,6 +125,16 @@ export default class Queries extends Component {
valueToDisplay = value.toString(); valueToDisplay = value.toString();
} }
if (type === 'address') {
return (
<InputAddress
className={ styles.queryValue }
value={ valueToDisplay }
disabled
/>
);
}
return ( return (
<Input <Input
className={ styles.queryValue } className={ styles.queryValue }