Skip to content

Commit

Permalink
Minor consistency fixes (opensearch-project#318)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler authored Aug 28, 2024
1 parent 5828295 commit 1e2ede0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
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

0 comments on commit 1e2ede0

Please sign in to comment.