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:
jasquat 2023-05-31 08:54:33 -04:00
parent e7e0972766
commit 8791cc513c
No known key found for this signature in database
4 changed files with 19 additions and 17 deletions

View File

@ -430,7 +430,8 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st
break # No more tasks to report
spiff_task = processor.next_task()
task = ProcessInstanceService.spiff_task_to_api_task(processor, processor.next_task())
if spiff_task is not None:
task = ProcessInstanceService.spiff_task_to_api_task(processor, spiff_task)
if task.id not in reported_ids:
try:
instructions = render_instructions(spiff_task)

View File

@ -514,7 +514,6 @@ class ProcessInstanceService:
add_docs_and_forms: bool = False,
calling_subprocess_task_id: str | None = None,
) -> Task:
"""Spiff_task_to_api_task."""
task_type = spiff_task.task_spec.description
props = {}

View File

@ -15,12 +15,14 @@ type OwnProps = {
processInstanceId: number;
processInstanceShowPageUrl: string;
allowRedirect: boolean;
redirectToHomeWhenNoTasks?: boolean;
};
export default function ProcessInterstitial({
processInstanceId,
allowRedirect,
processInstanceShowPageUrl,
redirectToHomeWhenNoTasks = true,
}: OwnProps) {
const [data, setData] = useState<any[]>([]);
const [lastTask, setLastTask] = useState<any>(null);
@ -49,7 +51,6 @@ export default function ProcessInterstitial({
}
},
onclose() {
console.log('The state is closed.');
setState('CLOSED');
},
});
@ -161,7 +162,7 @@ export default function ProcessInterstitial({
/** In the event there is no task information and the connection closed,
* redirect to the home page. */
if (state === 'CLOSED' && lastTask === null) {
if (state === 'CLOSED' && lastTask === null && redirectToHomeWhenNoTasks) {
navigate(`/tasks`);
}

View File

@ -1113,6 +1113,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
<ProcessInterstitial
processInstanceId={processInstance.id}
processInstanceShowPageUrl={processInstanceShowPageBaseUrl}
redirectToHomeWhenNoTasks={false}
allowRedirect={false}
/>
<br />