From f8d4e93b52f77f0d560fc6c62e5cef499cca5c05 Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Thu, 5 Dec 2024 16:04:57 -0800 Subject: [PATCH] Replace default query in inspector when switching steps Signed-off-by: Tyler Ohlsen --- common/interfaces.ts | 2 +- public/pages/workflow_detail/tools/query/query.tsx | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/interfaces.ts b/common/interfaces.ts index 5981a40a..37817c51 100644 --- a/common/interfaces.ts +++ b/common/interfaces.ts @@ -242,7 +242,7 @@ type ReactFlowViewport = { }; export type UIState = { - version: string; + schema_version: 1; config: WorkflowConfig; type: WORKFLOW_TYPE; // Will be used in future when changing from form-based to flow-based configs via drag-and-drop diff --git a/public/pages/workflow_detail/tools/query/query.tsx b/public/pages/workflow_detail/tools/query/query.tsx index d7de4a87..8f1b542e 100644 --- a/public/pages/workflow_detail/tools/query/query.tsx +++ b/public/pages/workflow_detail/tools/query/query.tsx @@ -68,11 +68,14 @@ export function Query(props: QueryProps) { // Standalone / sandboxed search request state. Users can test things out // without updating the base form / persisted value. We default to different values // based on the context (ingest or search). - const [tempRequest, setTempRequest] = useState( - props.selectedStep === CONFIG_STEP.INGEST - ? customStringify(FETCH_ALL_QUERY) - : values?.search?.request || '{}' - ); + const [tempRequest, setTempRequest] = useState(''); + useEffect(() => { + setTempRequest( + props.selectedStep === CONFIG_STEP.INGEST + ? customStringify(FETCH_ALL_QUERY) + : values?.search?.request || '{}' + ); + }, [props.selectedStep]); // state for if to execute search w/ or w/o any configured search pipeline. // default based on if there is an available search pipeline or not.