Skip to content

Commit

Permalink
Improve form usability & autosave (#273)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler authored Aug 14, 2024
1 parent 8149bef commit eebe1ff
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 40 deletions.
2 changes: 2 additions & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export const FETCH_ALL_QUERY_BODY = {
size: 1000,
};
export const INDEX_NOT_FOUND_EXCEPTION = 'index_not_found_exception';
export const NO_MODIFICATIONS_FOUND_TEXT =
'Template does not contain any modifications';
export const JSONPATH_ROOT_SELECTOR = '$.';
export enum SORT_ORDER {
ASC = 'asc',
Expand Down
26 changes: 12 additions & 14 deletions public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
const debounceAutosave = useCallback(
debounce(async () => {
triggerAutosave();
}, 10000),
}, 1000),
[autosave]
);

Expand Down Expand Up @@ -173,15 +173,14 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
)
.unwrap()
.then(async (result) => {
// TODO: figure out clean way to update the "last updated"
// section. The problem with re-fetching this every time, is it
// triggers lots of component rebuilds due to the base workflow prop
// changing.
// get any updates after autosave
new Promise((f) => setTimeout(f, 1000)).then(async () => {
dispatch(
getWorkflow({
workflowId: props.workflow?.id as string,
dataSourceId,
})
);
});
// new Promise((f) => setTimeout(f, 1000)).then(async () => {
// dispatch(getWorkflow(props.workflow?.id as string));
// });
})
.catch((error: any) => {
console.error('Error autosaving workflow: ', error);
Expand Down Expand Up @@ -676,6 +675,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
onClick={() => {
validateAndRunIngestion();
}}
// TODO: only enable if ingest is dirty
disabled={ingestProvisioned && !isDirty}
>
Run ingestion
Expand All @@ -687,6 +687,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
onClick={() => {
setSelectedStep(STEP.SEARCH);
}}
// TODO: only disable if ingest is dirty
disabled={!ingestProvisioned || isDirty}
>
{`Search pipeline >`}
Expand All @@ -697,18 +698,15 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
<>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
disabled={isDirty}
disabled={false}
onClick={() => setSelectedStep(STEP.INGEST)}
>
Back
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
disabled={
(searchProvisioned && !isDirty) ||
isProposingNoSearchResources
}
disabled={isProposingNoSearchResources}
fill={false}
onClick={() => {
validateAndRunQuery();
Expand Down
12 changes: 12 additions & 0 deletions server/resources/templates/custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Custom",
"description": "A blank workflow with no preset configurations",
"use_case": "CUSTOM",
"version": {
"template": "1.0.0",
"compatibility": [
"2.16.0",
"3.0.0"
]
}
}
12 changes: 0 additions & 12 deletions server/resources/templates/hybrid_search.json

This file was deleted.

12 changes: 0 additions & 12 deletions server/resources/templates/neural_sparse_search.json

This file was deleted.

2 changes: 1 addition & 1 deletion server/resources/templates/semantic_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": {
"template": "1.0.0",
"compatibility": [
"2.13.0",
"2.16.0",
"3.0.0"
]
},
Expand Down
3 changes: 3 additions & 0 deletions server/routes/flow_framework_routes_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ export class FlowFrameworkRoutesService {

return res.ok({ body: { workflowId: workflow_id, workflowTemplate } });
} catch (err: any) {
if (isIgnorableError(err)) {
return res.ok({ body: { workflowId: workflow_id, workflowTemplate } });
}
return generateCustomError(res, err);
}
};
Expand Down
6 changes: 5 additions & 1 deletion server/routes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Model,
ModelDict,
ModelInterface,
NO_MODIFICATIONS_FOUND_TEXT,
SearchHit,
WORKFLOW_RESOURCE_TYPE,
WORKFLOW_STATE,
Expand All @@ -35,7 +36,10 @@ export function generateCustomError(res: any, err: any) {

// Helper fn to filter out backend errors that we don't want to propagate on the frontend.
export function isIgnorableError(error: any): boolean {
return error.body?.error?.type === INDEX_NOT_FOUND_EXCEPTION;
return (
error.body?.error?.type === INDEX_NOT_FOUND_EXCEPTION ||
error.body?.error === NO_MODIFICATIONS_FOUND_TEXT
);
}

// Convert backend workflow into frontend workflow obj
Expand Down

0 comments on commit eebe1ff

Please sign in to comment.