Skip to content

Commit

Permalink
Use EuiCodeBlock for JSON settings, and overflow if long value (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang authored and Aliaksandr Yankouski committed Jul 16, 2018
1 parent 7b969b3 commit 8138aa7
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ exports[`Field for array setting should render user value if there is user value
grow={true}
size="xs"
>
Default:
<EuiCode>
default_value
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
default_value
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -459,10 +461,12 @@ exports[`Field for boolean setting should render user value if there is user val
grow={true}
size="xs"
>
Default:
<EuiCode>
true
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
true
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -723,10 +727,12 @@ exports[`Field for image setting should render user value if there is user value
grow={true}
size="xs"
>
Default:
<EuiCode>
null
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
null
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -936,10 +942,16 @@ exports[`Field for json setting should render default value if there is no user
grow={true}
size="xs"
>
Default:
<EuiCode>
{}
</EuiCode>
<UNDEFINED>
Default:
<EuiCodeBlock
language="json"
overflowHeight={null}
paddingSize="s"
>
{}
</EuiCodeBlock>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -1058,10 +1070,16 @@ exports[`Field for json setting should render user value if there is user value
grow={true}
size="xs"
>
Default:
<EuiCode>
{}
</EuiCode>
<UNDEFINED>
Default:
<EuiCodeBlock
language="json"
overflowHeight={null}
paddingSize="s"
>
{}
</EuiCodeBlock>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -1371,10 +1389,12 @@ exports[`Field for markdown setting should render user value if there is user va
grow={true}
size="xs"
>
Default:
<EuiCode>
null
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
null
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -1654,10 +1674,12 @@ exports[`Field for number setting should render user value if there is user valu
grow={true}
size="xs"
>
Default:
<EuiCode>
5
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
5
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -1956,10 +1978,12 @@ exports[`Field for select setting should render user value if there is user valu
grow={true}
size="xs"
>
Default:
<EuiCode>
orange
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
orange
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down Expand Up @@ -2241,10 +2265,12 @@ exports[`Field for string setting should render user value if there is user valu
grow={true}
size="xs"
>
Default:
<EuiCode>
null
</EuiCode>
<UNDEFINED>
Default:
<EuiCode>
null
</EuiCode>
</UNDEFINED>
</EuiText>
</UNDEFINED>
</UNDEFINED>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
EuiButton,
EuiButtonEmpty,
EuiCode,
EuiCodeBlock,
EuiCodeEditor,
EuiDescribedFormGroup,
EuiFieldNumber,
Expand Down Expand Up @@ -475,7 +476,22 @@ export class Field extends PureComponent {
<Fragment>
<EuiSpacer size="s" />
<EuiText size="xs">
Default: <EuiCode>{this.getDisplayedDefaultValue(type, defVal)}</EuiCode>
{ type === 'json' ? (
<Fragment>
Default:
<EuiCodeBlock
language="json"
paddingSize="s"
overflowHeight={defVal.length >= 500 ? 300 : null}
>
{this.getDisplayedDefaultValue(type, defVal)}
</EuiCodeBlock>
</Fragment>
) : (
<Fragment>
Default: <EuiCode>{this.getDisplayedDefaultValue(type, defVal)}</EuiCode>
</Fragment>
) }
</EuiText>
</Fragment>
);
Expand Down

0 comments on commit 8138aa7

Please sign in to comment.