allow not redirecting to home page at all in interstitial component and do not error out if next task does not exist
This commit is contained in:
parent
4808e346f1
commit
aac0841617
|
@ -430,20 +430,21 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st
|
||||||
break # No more tasks to report
|
break # No more tasks to report
|
||||||
|
|
||||||
spiff_task = processor.next_task()
|
spiff_task = processor.next_task()
|
||||||
task = ProcessInstanceService.spiff_task_to_api_task(processor, processor.next_task())
|
if spiff_task is not None:
|
||||||
if task.id not in reported_ids:
|
task = ProcessInstanceService.spiff_task_to_api_task(processor, spiff_task)
|
||||||
try:
|
if task.id not in reported_ids:
|
||||||
instructions = render_instructions(spiff_task)
|
try:
|
||||||
except Exception as e:
|
instructions = render_instructions(spiff_task)
|
||||||
api_error = ApiError(
|
except Exception as e:
|
||||||
error_code="engine_steps_error",
|
api_error = ApiError(
|
||||||
message=f"Failed to complete an automated task. Error was: {str(e)}",
|
error_code="engine_steps_error",
|
||||||
status_code=400,
|
message=f"Failed to complete an automated task. Error was: {str(e)}",
|
||||||
)
|
status_code=400,
|
||||||
yield render_data("error", api_error)
|
)
|
||||||
raise e
|
yield render_data("error", api_error)
|
||||||
task.properties = {"instructionsForEndUser": instructions}
|
raise e
|
||||||
yield render_data("task", task)
|
task.properties = {"instructionsForEndUser": instructions}
|
||||||
|
yield render_data("task", task)
|
||||||
|
|
||||||
|
|
||||||
def get_ready_engine_step_count(bpmn_process_instance: BpmnWorkflow) -> int:
|
def get_ready_engine_step_count(bpmn_process_instance: BpmnWorkflow) -> int:
|
||||||
|
|
|
@ -514,7 +514,6 @@ class ProcessInstanceService:
|
||||||
add_docs_and_forms: bool = False,
|
add_docs_and_forms: bool = False,
|
||||||
calling_subprocess_task_id: str | None = None,
|
calling_subprocess_task_id: str | None = None,
|
||||||
) -> Task:
|
) -> Task:
|
||||||
"""Spiff_task_to_api_task."""
|
|
||||||
task_type = spiff_task.task_spec.description
|
task_type = spiff_task.task_spec.description
|
||||||
|
|
||||||
props = {}
|
props = {}
|
||||||
|
|
|
@ -15,12 +15,14 @@ type OwnProps = {
|
||||||
processInstanceId: number;
|
processInstanceId: number;
|
||||||
processInstanceShowPageUrl: string;
|
processInstanceShowPageUrl: string;
|
||||||
allowRedirect: boolean;
|
allowRedirect: boolean;
|
||||||
|
redirectToHomeWhenNoTasks?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ProcessInterstitial({
|
export default function ProcessInterstitial({
|
||||||
processInstanceId,
|
processInstanceId,
|
||||||
allowRedirect,
|
allowRedirect,
|
||||||
processInstanceShowPageUrl,
|
processInstanceShowPageUrl,
|
||||||
|
redirectToHomeWhenNoTasks = true,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
const [data, setData] = useState<any[]>([]);
|
const [data, setData] = useState<any[]>([]);
|
||||||
const [lastTask, setLastTask] = useState<any>(null);
|
const [lastTask, setLastTask] = useState<any>(null);
|
||||||
|
@ -49,7 +51,6 @@ export default function ProcessInterstitial({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onclose() {
|
onclose() {
|
||||||
console.log('The state is closed.');
|
|
||||||
setState('CLOSED');
|
setState('CLOSED');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -161,7 +162,7 @@ export default function ProcessInterstitial({
|
||||||
|
|
||||||
/** In the event there is no task information and the connection closed,
|
/** In the event there is no task information and the connection closed,
|
||||||
* redirect to the home page. */
|
* redirect to the home page. */
|
||||||
if (state === 'CLOSED' && lastTask === null) {
|
if (state === 'CLOSED' && lastTask === null && redirectToHomeWhenNoTasks) {
|
||||||
navigate(`/tasks`);
|
navigate(`/tasks`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1113,6 +1113,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
||||||
<ProcessInterstitial
|
<ProcessInterstitial
|
||||||
processInstanceId={processInstance.id}
|
processInstanceId={processInstance.id}
|
||||||
processInstanceShowPageUrl={processInstanceShowPageBaseUrl}
|
processInstanceShowPageUrl={processInstanceShowPageBaseUrl}
|
||||||
|
redirectToHomeWhenNoTasks={false}
|
||||||
allowRedirect={false}
|
allowRedirect={false}
|
||||||
/>
|
/>
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Reference in New Issue