diff --git a/public/pages/workflow_detail/workflow_inputs/ingest_inputs/ingest_inputs.tsx b/public/pages/workflow_detail/workflow_inputs/ingest_inputs/ingest_inputs.tsx index 527def78..2358003f 100644 --- a/public/pages/workflow_detail/workflow_inputs/ingest_inputs/ingest_inputs.tsx +++ b/public/pages/workflow_detail/workflow_inputs/ingest_inputs/ingest_inputs.tsx @@ -15,6 +15,7 @@ interface IngestInputsProps { uiConfig: WorkflowConfig; setUiConfig: (uiConfig: WorkflowConfig) => void; workflow: Workflow | undefined; + lastIngested: number | undefined; } /** @@ -28,6 +29,7 @@ export function IngestInputs(props: IngestInputsProps) { workflow={props.workflow} uiConfig={props.uiConfig} setIngestDocs={props.setIngestDocs} + lastIngested={props.lastIngested} /> diff --git a/public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data.tsx b/public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data.tsx index d8447804..5c91e643 100644 --- a/public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data.tsx +++ b/public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data.tsx @@ -35,6 +35,7 @@ import { WorkspaceFormValues, customStringify, isVectorSearchUseCase, + toFormattedDate, } from '../../../../../common'; import { AppState, @@ -48,6 +49,7 @@ interface SourceDataProps { workflow: Workflow | undefined; uiConfig: WorkflowConfig; setIngestDocs: (docs: string) => void; + lastIngested: number | undefined; } enum SOURCE_OPTIONS { @@ -65,6 +67,13 @@ export function SourceData(props: SourceDataProps) { const { values, setFieldValue } = useFormikContext(); const indices = useSelector((state: AppState) => state.opensearch.indices); + // empty/populated docs state + let docs = []; + try { + docs = JSON.parse(getIn(values, 'ingest.docs', [])); + } catch {} + const docsPopulated = docs.length > 0; + // selected option state const [selectedOption, setSelectedOption] = useState( SOURCE_OPTIONS.MANUAL @@ -184,7 +193,7 @@ export function SourceData(props: SourceDataProps) { > -

{`Edit source data`}

+

{`Import data`}

@@ -258,7 +267,7 @@ export function SourceData(props: SourceDataProps) { )} -

Source data

+

Import data

+ {props.lastIngested !== undefined && ( + + + {`Last ingested: ${toFormattedDate(props.lastIngested)}`} + + + )} + setIsEditModalOpen(true)} > - Edit + {docsPopulated ? `Edit` : `Select data`} - - - + {docsPopulated && ( + + + + )} ); diff --git a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx index 624cd0b1..4ef5fee3 100644 --- a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx +++ b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx @@ -77,7 +77,7 @@ interface InputTransformModalProps { onClose: () => void; } -// the max number of input docs we use to display & test transforms with +// the max number of input docs we use to display & test transforms with (search response hits) const MAX_INPUT_DOCS = 10; /** @@ -143,7 +143,9 @@ export function InputTransformModal(props: InputTransformModalProps) { const description = props.context === PROCESSOR_CONTEXT.SEARCH_REQUEST ? 'Fetch an input query and see how it is transformed.' - : `Fetch some sample documents (up to ${MAX_INPUT_DOCS}) and see how they are transformed.`; + : props.context === PROCESSOR_CONTEXT.INGEST + ? 'Fetch a sample document and see how it is transformed' + : `Fetch some returned documents (up to ${MAX_INPUT_DOCS}) and see how they are transformed.`; // hook to re-generate the transform when any inputs to the transform are updated useEffect(() => { diff --git a/public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx b/public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx index f8087377..3d7e9a79 100644 --- a/public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx +++ b/public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx @@ -20,7 +20,6 @@ import { EuiModalHeader, EuiModalHeaderTitle, EuiPanel, - EuiSpacer, EuiStepsHorizontal, EuiText, EuiTitle, @@ -122,6 +121,11 @@ export function WorkflowInputs(props: WorkflowInputsProps) { // confirm modal state const [isModalOpen, setIsModalOpen] = useState(false); + // last ingested state + const [lastIngested, setLastIngested] = useState( + undefined + ); + // maintain global states const onIngest = selectedStep === STEP.INGEST; const onSearch = selectedStep === STEP.SEARCH; @@ -549,6 +553,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) { .unwrap() .then(async (resp) => { props.setIngestResponse(customStringify(resp)); + setLastIngested(Date.now()); }) .catch((error: any) => { props.setIngestResponse(''); @@ -632,7 +637,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) { height: '100%', }} > - + )} - {onIngestAndUnprovisioned && ( - <> - - - - Create an ingest pipeline - - - Configure and ingest data into an index. - - - ), - }} - disabledOption={{ - id: INGEST_OPTION.SKIP, - label: ( - - - Skip ingestion pipeline - - - Use an existing index with data ingested. - - - ), - }} - showLabel={false} - /> - - )} - {!onIngestAndDisabled && ( - <> - - -

- {onIngestAndUnprovisioned ? ( - 'Define ingest pipeline' - ) : onIngestAndProvisioned ? ( - - - Edit ingest pipeline - - - setIsModalOpen(true)} - > - - {` `}Delete resources - - - - ) : ( - 'Define search pipeline' - )} -

-
-
- - {onIngest ? ( + + + +

+ {onIngestAndUnprovisioned ? ( + 'Define ingest pipeline' + ) : onIngestAndProvisioned ? ( + + + Edit ingest pipeline + + + setIsModalOpen(true)} + > + + {` `}Delete resources + + + + ) : ( + 'Define search pipeline' + )} +

+
+
+ {onIngest ? ( + <> + {onIngestAndUnprovisioned && ( + <> + + + Create an ingest pipeline + + + Configure and ingest data into an index. + + + ), + }} + disabledOption={{ + id: INGEST_OPTION.SKIP, + label: ( + + + Skip ingestion pipeline + + + Use an existing index with data ingested. + + + ), + }} + showLabel={false} + /> + + )} + {!onIngestAndDisabled && ( - ) : ( - )} -
- - )} - + + ) : ( + + )} + + diff --git a/public/pages/workflows/import_workflow/import_workflow_modal.tsx b/public/pages/workflows/import_workflow/import_workflow_modal.tsx index 71f8b472..8f8bf9fe 100644 --- a/public/pages/workflows/import_workflow/import_workflow_modal.tsx +++ b/public/pages/workflows/import_workflow/import_workflow_modal.tsx @@ -85,11 +85,7 @@ export function ImportWorkflowModal(props: ImportWorkflowModalProps) { - + {fileContents !== undefined && !isValidWorkflow(fileObj) && ( <> @@ -116,11 +112,15 @@ export function ImportWorkflowModal(props: ImportWorkflowModalProps) { )} { if (files && files.length > 0) { fileReader.readAsText(files[0]); + } else { + setFileContents(undefined); } }} display="large"