Remove contentShorten flags (#7245)

This commit is contained in:
Jaco 2022-03-27 10:07:08 +02:00 committed by GitHub
parent c2fc3b4174
commit c0107b2e0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -32,7 +32,7 @@ function Results ({ queue = [] }: Props): React.ReactElement<Props> | null {
value={
error
? error.message
: <pre>{valueToText('', result as null, false)}</pre>
: <pre>{valueToText('', result as null)}</pre>
}
/>
))}

View File

@ -28,7 +28,7 @@ interface Props {
interface CacheInstance {
Component: React.ComponentType<any>;
render: RenderFn;
refresh: (swallowErrors: boolean, contentShorten: boolean) => React.ComponentType<any>;
refresh: (swallowErrors: boolean) => React.ComponentType<any>;
}
const cache: CacheInstance[] = [];
@ -66,13 +66,13 @@ function queryTypeToString (registry: Registry, { creator: { meta: { modifier, t
: _type;
}
function createComponent (type: string, Component: React.ComponentType<any>, defaultProps: DefaultProps, renderHelper: ComponentRenderer): { Component: React.ComponentType<any>; render: (createComponent: RenderFn) => React.ComponentType<any>; refresh: (swallowErrors: boolean, contentShorten: boolean) => React.ComponentType<any> } {
function createComponent (type: string, Component: React.ComponentType<any>, defaultProps: DefaultProps, renderHelper: ComponentRenderer): { Component: React.ComponentType<any>; render: (createComponent: RenderFn) => React.ComponentType<any>; refresh: (swallowErrors: boolean) => React.ComponentType<any> } {
return {
Component,
// In order to modify the parameters which are used to render the default component, we can use this method
refresh: (contentShorten: boolean): React.ComponentType<any> =>
refresh: (): React.ComponentType<any> =>
renderHelper(
(value: unknown) => <pre>{valueToText(type, value as null, contentShorten)}</pre>,
(value: unknown) => <pre>{valueToText(type, value as null)}</pre>,
defaultProps
),
// In order to replace the default component during runtime we can provide a RenderFn to create a new 'plugged' component
@ -131,7 +131,7 @@ function getCachedComponent (registry: Registry, query: QueryTypes): CacheInstan
const defaultProps = { className: 'ui--output' };
const Component = renderHelper(
// By default we render a simple div node component with the query results in it
(value: unknown) => <pre>{valueToText(type, value as null, true)}</pre>,
(value: unknown) => <pre>{valueToText(type, value as null)}</pre>,
defaultProps
);

View File

@ -49,7 +49,7 @@ export function toHumanJson (value: any): string {
.replace(/\],\[/g, '],\n[');
}
export default function valueToText (type: string, value: Codec | undefined | null, contentShorten = true): React.ReactNode {
export default function valueToText (type: string, value: Codec | undefined | null): React.ReactNode {
if (isNull(value) || isUndefined(value)) {
return div({}, '<unknown>');
}
@ -57,7 +57,7 @@ export default function valueToText (type: string, value: Codec | undefined | nu
return div(
{},
['Bytes', 'Raw', 'Option<Keys>', 'Keys'].includes(type) && isFunction(value.toU8a)
? u8aToHex(value.toU8a(true), contentShorten ? 512 : -1)
? u8aToHex(value.toU8a(true))
// HACK Handle Keys as hex-only (this should go away once the node value is
// consistently swapped to `Bytes`)
: type === 'Vec<(ValidatorId,Keys)>'