Skip to content

Commit

Permalink
Update defaults/wording around ingest docs being an array
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Jul 17, 2024
1 parent 042f3d3 commit b4abd93
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function SourceData(props: SourceDataProps) {
<JsonField
label="Upload JSON documents"
fieldPath={'ingest.docs'}
helpText="Documents should be formatted as a valid JSON array."
// when ingest doc values change, don't update the form
// since we initially only support running ingest once per configuration
onFormChange={() => {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export function InputTransformModal(props: InputTransformModalProps) {
const { values } = useFormikContext<WorkflowFormValues>();

// source input / transformed output state
const [sourceInput, setSourceInput] = useState<string>('{}');
const [transformedOutput, setTransformedOutput] = useState<string>('{}');
const [sourceInput, setSourceInput] = useState<string>('[]');
const [transformedOutput, setTransformedOutput] = useState<string>('[]');

return (
<EuiModal onClose={props.onClose} style={{ width: '70vw' }}>
Expand Down
2 changes: 1 addition & 1 deletion public/utils/config_to_form_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function ingestConfigToFormik(
let ingestFormikValues = {} as FormikValues;
if (ingestConfig) {
ingestFormikValues['enabled'] = ingestConfig.enabled;
ingestFormikValues['docs'] = ingestDocs || getInitialValue('json');
ingestFormikValues['docs'] = ingestDocs || '[]';
ingestFormikValues['enrich'] = processorsConfigToFormik(
ingestConfig.enrich
);
Expand Down
4 changes: 2 additions & 2 deletions public/utils/config_to_schema_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ function getFieldSchema(fieldType: ConfigFieldType): Schema {
break;
}
case 'json': {
baseSchema = yup.string().test('json', 'Invalid JSON', (value) => {
baseSchema = yup.string().test('json', 'Invalid JSON array', (value) => {
try {
// @ts-ignore
JSON.parse(value);
return Array.isArray(JSON.parse(value));
return true;
} catch (error) {
return false;
Expand Down

0 comments on commit b4abd93

Please sign in to comment.