From 3f8b92c8bac50ac3d2969160e2cf06881fbe6bba Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 31 Dec 2018 16:23:23 +0100 Subject: [PATCH] Tuples populate actual values as inputs (#551) --- packages/ui-app/src/Params/Param/Hash.tsx | 2 +- packages/ui-app/src/Params/Param/Tuple.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/ui-app/src/Params/Param/Hash.tsx b/packages/ui-app/src/Params/Param/Hash.tsx index 1d3d619ca3..71646a8815 100644 --- a/packages/ui-app/src/Params/Param/Hash.tsx +++ b/packages/ui-app/src/Params/Param/Hash.tsx @@ -22,7 +22,7 @@ export default class Hash extends React.PureComponent { length={32} name={name} onChange={onChange} - size={isDisabled ? 'full' : 'medium'} + size={isDisabled ? 'full' : 'large'} style={style} type={type} withLabel={withLabel} diff --git a/packages/ui-app/src/Params/Param/Tuple.tsx b/packages/ui-app/src/Params/Param/Tuple.tsx index 708ae72815..0c8b26e886 100644 --- a/packages/ui-app/src/Params/Param/Tuple.tsx +++ b/packages/ui-app/src/Params/Param/Tuple.tsx @@ -6,6 +6,7 @@ import { TypeDef } from '@polkadot/types/codec'; import { Props, RawParam } from '../types'; import React from 'react'; +import { isUndefined } from '@polkadot/util'; import Bare from './Bare'; import findComponent from './findComponent'; @@ -30,7 +31,7 @@ export default class Tuple extends React.PureComponent { }; } - static getDerivedStateFromProps ({ type: { sub, type } }: Props, prevState: State): Partial | null { + static getDerivedStateFromProps ({ defaultValue, type: { sub, type } }: Props, prevState: State): Partial | null { if (type === prevState.type) { return null; } @@ -43,7 +44,11 @@ export default class Tuple extends React.PureComponent { Components: subTypes.map((type) => findComponent(type)), sub: subTypes.map(({ type }) => type), subTypes, - type + type, + values: (defaultValue.value as Array).map((value) => ({ + isValid: !isUndefined(value), + value + })) }; }