mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-11 18:14:20 +00:00
Feature/ignore save draft errors (#387)
* ignore it if the task cannot be submitted for saving draft data * changed to handle the error on the frontend instead and do not save draft data if a manaul task --------- Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
dac2e28672
commit
68acac0fce
@ -258,15 +258,16 @@ export type HotCrumbItem = HotCrumbItemArray | HotCrumbItemObject;
|
|||||||
export interface ErrorForDisplay {
|
export interface ErrorForDisplay {
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
messageClassName?: string;
|
error_code?: string;
|
||||||
sentry_link?: string;
|
|
||||||
task_name?: string;
|
|
||||||
task_id?: string;
|
|
||||||
line_number?: number;
|
|
||||||
error_line?: string;
|
error_line?: string;
|
||||||
file_name?: string;
|
file_name?: string;
|
||||||
task_trace?: string[];
|
line_number?: number;
|
||||||
|
messageClassName?: string;
|
||||||
|
sentry_link?: string;
|
||||||
stacktrace?: string[];
|
stacktrace?: string[];
|
||||||
|
task_id?: string;
|
||||||
|
task_name?: string;
|
||||||
|
task_trace?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthenticationParam {
|
export interface AuthenticationParam {
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
modifyProcessIdentifierForPathParam,
|
modifyProcessIdentifierForPathParam,
|
||||||
recursivelyChangeNullAndUndefined,
|
recursivelyChangeNullAndUndefined,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import { EventDefinition, Task } from '../interfaces';
|
import { ErrorForDisplay, EventDefinition, Task } from '../interfaces';
|
||||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||||
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
||||||
import TypeaheadWidget from '../rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget';
|
import TypeaheadWidget from '../rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget';
|
||||||
@ -70,11 +70,26 @@ export default function TaskShow() {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [params]);
|
}, [params]);
|
||||||
|
|
||||||
|
const handleAutoSaveError = (error: ErrorForDisplay) => {
|
||||||
|
if (
|
||||||
|
error.error_code &&
|
||||||
|
error.error_code === 'process_instance_not_runnable'
|
||||||
|
) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
addError(error);
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
// Before we auto-saved form data, we remembered what data was in the form, and then created a synthetic submit event
|
// Before we auto-saved form data, we remembered what data was in the form, and then created a synthetic submit event
|
||||||
// in order to implement a "Save and close" button. That button no longer saves (since we have auto-save), but the crazy
|
// in order to implement a "Save and close" button. That button no longer saves (since we have auto-save), but the crazy
|
||||||
// frontend code to support that Save and close button is here, in case we need to reference that someday:
|
// frontend code to support that Save and close button is here, in case we need to reference that someday:
|
||||||
// https://github.com/sartography/spiff-arena/blob/182f56a1ad23ce780e8f5b0ed00efac3e6ad117b/spiffworkflow-frontend/src/routes/TaskShow.tsx#L329
|
// https://github.com/sartography/spiff-arena/blob/182f56a1ad23ce780e8f5b0ed00efac3e6ad117b/spiffworkflow-frontend/src/routes/TaskShow.tsx#L329
|
||||||
const autoSaveTaskData = (formData: any, successCallback?: Function) => {
|
const autoSaveTaskData = (formData: any, successCallback?: Function) => {
|
||||||
|
// save-draft gets called when a manual task form loads but there's no data to save so don't do it
|
||||||
|
if (task?.typename === 'ManualTask') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
let successCallbackToUse = successCallback;
|
let successCallbackToUse = successCallback;
|
||||||
if (!successCallbackToUse) {
|
if (!successCallbackToUse) {
|
||||||
successCallbackToUse = doNothing;
|
successCallbackToUse = doNothing;
|
||||||
@ -84,8 +99,9 @@ export default function TaskShow() {
|
|||||||
postBody: formData,
|
postBody: formData,
|
||||||
httpMethod: 'POST',
|
httpMethod: 'POST',
|
||||||
successCallback: successCallbackToUse,
|
successCallback: successCallbackToUse,
|
||||||
failureCallback: addError,
|
failureCallback: handleAutoSaveError,
|
||||||
});
|
});
|
||||||
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendAutosaveEvent = (eventDetails?: any) => {
|
const sendAutosaveEvent = (eventDetails?: any) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user