Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Minor consistency fixes #319

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export function MapField(props: MapFieldProps) {
/>
) : (
<TextField
fullWidth={true}
fieldPath={`${props.fieldPath}.${idx}.key`}
placeholder={props.keyPlaceholder || 'Input'}
showError={false}
Expand All @@ -136,6 +137,7 @@ export function MapField(props: MapFieldProps) {
/>
) : (
<TextField
fullWidth={true}
fieldPath={`${props.fieldPath}.${idx}.value`}
placeholder={
props.valuePlaceholder || 'Output'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ interface TextFieldProps {
helpText?: string;
placeholder?: string;
showError?: boolean;
fullWidth?: boolean;
}

/**
* An input field for a component where users input plaintext
*/
export function TextField(props: TextFieldProps) {
const { errors, touched } = useFormikContext<WorkspaceFormValues>();

return (
<Field name={props.fieldPath}>
{({ field, form }: FieldProps) => {
return (
<EuiCompressedFormRow
fullWidth={props.fullWidth}
key={props.fieldPath}
label={props.label}
labelAppend={
Expand All @@ -50,6 +51,7 @@ export function TextField(props: TextFieldProps) {
isInvalid={getIn(errors, field.name) && getIn(touched, field.name)}
>
<EuiFieldText
fullWidth={props.fullWidth}
{...field}
placeholder={props.placeholder || ''}
compressed={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export function InputTransformModal(props: InputTransformModalProps) {
<EuiFlexGroup direction="column">
<EuiFlexItem>
<>
<EuiText color="subdued">
Fetch some sample input data and how it is transformed.
</EuiText>
<EuiSpacer size="s" />
<EuiText>Expected input</EuiText>
<EuiSmallButton
style={{ width: '100px' }}
Expand All @@ -124,7 +128,7 @@ export function InputTransformModal(props: InputTransformModalProps) {
simulatePipeline({
apiBody: {
pipeline: curIngestPipeline as IngestPipelineConfig,
docs: curDocs,
docs: [curDocs[0]],
},
dataSourceId,
})
Expand All @@ -139,7 +143,13 @@ export function InputTransformModal(props: InputTransformModalProps) {
);
});
} else {
setSourceInput(values.ingest.docs);
try {
const docObjs = JSON.parse(
values.ingest.docs
) as {}[];
if (docObjs.length > 0)
setSourceInput(customStringify([docObjs[0]]));
} catch {}
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export function OutputTransformModal(props: OutputTransformModalProps) {
<EuiFlexGroup direction="column">
<EuiFlexItem>
<>
<EuiText color="subdued">
Fetch some sample output data and how it is transformed.
</EuiText>
<EuiSpacer size="s" />
<EuiText>Expected input</EuiText>
<EuiSmallButton
style={{ width: '100px' }}
Expand Down Expand Up @@ -128,7 +132,7 @@ export function OutputTransformModal(props: OutputTransformModalProps) {
simulatePipeline({
apiBody: {
pipeline: curIngestPipeline,
docs: curDocs,
docs: [curDocs[0]],
},
dataSourceId,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
<EuiCompressedFormRow
label={'Text field'}
isInvalid={false}
helpText="The name of the document field containing plaintext"
helpText="The name of the text document field to be embedded"
>
<EuiCompressedFieldText
value={fieldValues?.textField || ''}
Expand Down
Loading