From a99c36964dc8e74f69cf500db2bb743707c9bbe1 Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:53:10 +0000 Subject: [PATCH] mi-task-show-fix (#1412) * check for mi tasks first before checking more newest in task show api w/ burnettk * remove console --------- Co-authored-by: jasquat Co-authored-by: burnettk --- spiffworkflow-backend/bin/query_tasks | 7 ++- .../routes/process_instances_controller.py | 10 +++-- .../src/routes/ProcessInstanceShow.tsx | 44 ++++++++++++------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/spiffworkflow-backend/bin/query_tasks b/spiffworkflow-backend/bin/query_tasks index 43e701ae..6f57bd7a 100755 --- a/spiffworkflow-backend/bin/query_tasks +++ b/spiffworkflow-backend/bin/query_tasks @@ -1,13 +1,16 @@ #!/usr/bin/env bash function error_handler() { - >&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." + echo >&2 "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." exit "$2" } trap 'error_handler ${LINENO} $?' ERR set -o errtrace -o errexit -o nounset -o pipefail -mysql -uroot spiffworkflow_backend_unit_testing -e ' +# db_name=spiffworkflow_backend_unit_testing +db_name=spiffworkflow_backend_local_development + +mysql -uroot "$db_name" -e ' select * from process_instance; select t.guid as task_guid, t.state as task_state, td.bpmn_identifier as task_id, t.properties_json from task t diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py index 6175f327..172a4c53 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -492,7 +492,12 @@ def _process_instance_task_list( full_bpmn_process_path = bpmn_process_cache[task_model.bpmn_process_guid] row_key = f"{':::'.join(full_bpmn_process_path)}:::{task_model.bpmn_identifier}" - if ( + if task_model.runtime_info and ("instance" in task_model.runtime_info or "iteration" in task_model.runtime_info): + # This handles adding all instances of a MI and iterations of loop tasks + additional_tasks.append(task_model) + if task_model.typename in ["SubWorkflowTask", "CallActivity"]: + relevant_subprocess_guids.add(task_model.guid) + elif ( row_key not in most_recent_tasks or most_recent_tasks[row_key].properties_json["last_state_change"] < task_model.properties_json["last_state_change"] @@ -503,9 +508,6 @@ def _process_instance_task_list( # since any task like would no longer be in the list anyway and therefore will not be returned if task_model.typename in ["SubWorkflowTask", "CallActivity"]: relevant_subprocess_guids.add(task_model.guid) - elif task_model.runtime_info and ("instance" in task_model.runtime_info or "iteration" in task_model.runtime_info): - # This handles adding all instances of a MI and iterations of loop tasks - additional_tasks.append(task_model) task_models = [ task_model diff --git a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx index 88194213..df59c3a4 100644 --- a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx @@ -1349,10 +1349,10 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { const switchToTask = (taskGuid: string, taskListToUse: Task[] | null) => { if (taskListToUse && taskToDisplay) { - // set to null right away to hopefully avoid using the incorrect task later - setTaskToDisplay(null); const task = taskListToUse.find((t: Task) => t.guid === taskGuid); if (task) { + // set to null right away to hopefully avoid using the incorrect task later + setTaskToDisplay(null); setTaskToDisplay(task); initializeTaskDataToDisplay(task); } @@ -1399,7 +1399,10 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { ); }; - const createButtonsForMultiTasks = (instances: number[]) => { + const createButtonsForMultiTasks = ( + instances: number[], + infoType: string + ) => { if (!tasks || !taskToDisplay) { return []; } @@ -1407,6 +1410,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { return (