Skip to content

Commit

Permalink
Require script when first adding a field. Shorten painless script edi…
Browse files Browse the repository at this point in the history
…tor. Remove error callout.
  • Loading branch information
cjcenizal committed Sep 22, 2020
1 parent 8a53f68 commit 3ac63a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React from 'react';
import { EuiFormRow, EuiCallOut, EuiSpacer } from '@elastic/eui';
import { EuiFormRow } from '@elastic/eui';

import { CodeEditor, UseField } from '../../../shared_imports';
import { getFieldConfig } from '../../../lib';
Expand All @@ -18,35 +18,26 @@ export const PainlessScriptParameter = () => {
const isInvalid = error ? Boolean(error.length) : false;

return (
<>
{isInvalid && (
<>
<EuiCallOut size="s" color="danger" title={error} />
<EuiSpacer />
</>
)}

<EuiFormRow label={scriptField.label} error={error} isInvalid={isInvalid} fullWidth>
<CodeEditor
languageId="painless"
// 99% width allows the editor to resize horizontally. 100% prevents it from resizing.
width="99%"
height="800px"
value={scriptField.value as string}
onChange={scriptField.setValue}
options={{
fontSize: 12,
minimap: {
enabled: false,
},
scrollBeyondLastLine: false,
wordWrap: 'on',
wrappingIndent: 'indent',
automaticLayout: true,
}}
/>
</EuiFormRow>
</>
<EuiFormRow label={scriptField.label} error={error} isInvalid={isInvalid} fullWidth>
<CodeEditor
languageId="painless"
// 99% width allows the editor to resize horizontally. 100% prevents it from resizing.
width="99%"
height="400px"
value={scriptField.value as string}
onChange={scriptField.setValue}
options={{
fontSize: 12,
minimap: {
enabled: false,
},
scrollBeyondLastLine: false,
wordWrap: 'on',
wrappingIndent: 'indent',
automaticLayout: true,
}}
/>
</EuiFormRow>
);
}}
</UseField>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

import React from 'react';

import { RuntimeTypeParameter } from '../../../field_parameters';
import { RuntimeTypeParameter, PainlessScriptParameter } from '../../../field_parameters';

export const RuntimeTypeRequiredParameters = () => {
return <RuntimeTypeParameter />;
return (
<>
<RuntimeTypeParameter />
<PainlessScriptParameter />
</>
);
};

0 comments on commit 3ac63a6

Please sign in to comment.