From c553277c21d57fa25c2a10129349d68242d10d72 Mon Sep 17 00:00:00 2001 From: danfunk Date: Thu, 11 May 2023 12:34:43 -0400 Subject: [PATCH 1/3] View button styled the same as the go button. Don't show the view button for Suspended, terminated, or Errored Processes when there is nothing to see. On the interstitial page, if the process is not runnable, return out of the process, don't keep looping forever. --- .../routes/tasks_controller.py | 13 ++++++----- .../components/ProcessInstanceListTable.tsx | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index b2ac9fa29..2a610e384 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -388,8 +388,6 @@ def _render_instructions_for_end_user(task_model: TaskModel, extensions: Optiona def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[str, Optional[str], None]: - processor = ProcessInstanceProcessor(process_instance) - reported_ids = [] # A list of all the ids reported by this endpoint so far. def get_reportable_tasks() -> Any: return processor.bpmn_process_instance.get_tasks( @@ -406,6 +404,13 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st return_hash[return_type] = entity return f"data: {current_app.json.dumps(return_hash)} \n\n" + # do not do any processing if the instance is not currently active + if process_instance.status not in ProcessInstanceModel.active_statuses(): + yield render_data("unrunnable_instance", process_instance) + return + + processor = ProcessInstanceProcessor(process_instance) + reported_ids = [] # A list of all the ids reported by this endpoint so far. tasks = get_reportable_tasks() while True: for spiff_task in tasks: @@ -425,10 +430,6 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st yield render_data("task", task) reported_ids.append(spiff_task.id) if spiff_task.state == TaskState.READY: - # do not do any processing if the instance is not currently active - if process_instance.status not in ProcessInstanceModel.active_statuses(): - yield render_data("unrunnable_instance", process_instance) - break try: processor.do_engine_steps(execution_strategy_name="one_at_a_time") processor.do_engine_steps(execution_strategy_name="run_until_user_message") diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index a7f70e6dc..48bb02ff5 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -1597,22 +1597,27 @@ export default function ProcessInstanceListTable({ } let buttonText = 'View'; - let buttonKind = 'ghost'; - if ( - processInstance.status !== 'suspended' && - hasAccessToCompleteTask && - processInstance.task_id - ) { + if (hasAccessToCompleteTask && processInstance.task_id) { buttonText = 'Go'; - buttonKind = 'secondary'; } buttonElement = ( - ); - currentRow.push({buttonElement}); + + console.log(processInstance.status); + if ( + processInstance.status === 'not_started' || + processInstance.status === 'user_input_required' || + processInstance.status === 'waiting' || + processInstance.status === 'complete' + ) { + currentRow.push({buttonElement}); + } else { + currentRow.push(); + } } const rowStyle = { cursor: 'pointer' }; From 1eb440a0b29cbce0e3819732ad9a656ca5679ec9 Mon Sep 17 00:00:00 2001 From: danfunk Date: Thu, 11 May 2023 12:56:59 -0400 Subject: [PATCH 2/3] fixing a stupid mistake. --- .../src/spiffworkflow_backend/routes/tasks_controller.py | 9 ++++----- .../src/components/ProcessInstanceListTable.tsx | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 2a610e384..2105952de 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -388,7 +388,6 @@ def _render_instructions_for_end_user(task_model: TaskModel, extensions: Optiona def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[str, Optional[str], None]: - def get_reportable_tasks() -> Any: return processor.bpmn_process_instance.get_tasks( TaskState.WAITING | TaskState.STARTED | TaskState.READY | TaskState.ERROR @@ -404,10 +403,6 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st return_hash[return_type] = entity return f"data: {current_app.json.dumps(return_hash)} \n\n" - # do not do any processing if the instance is not currently active - if process_instance.status not in ProcessInstanceModel.active_statuses(): - yield render_data("unrunnable_instance", process_instance) - return processor = ProcessInstanceProcessor(process_instance) reported_ids = [] # A list of all the ids reported by this endpoint so far. @@ -430,6 +425,10 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st yield render_data("task", task) reported_ids.append(spiff_task.id) if spiff_task.state == TaskState.READY: + # do not do any processing if the instance is not currently active + if process_instance.status not in ProcessInstanceModel.active_statuses(): + yield render_data("unrunnable_instance", process_instance) + return try: processor.do_engine_steps(execution_strategy_name="one_at_a_time") processor.do_engine_steps(execution_strategy_name="run_until_user_message") diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 48bb02ff5..7b2f0efbe 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -1602,7 +1602,7 @@ export default function ProcessInstanceListTable({ } buttonElement = ( - ); From 062e40dadc57a809614989ecb6b447305d5e3077 Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 11 May 2023 13:46:17 -0400 Subject: [PATCH 3/3] kill console --- .../src/components/ProcessInstanceListTable.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 7b2f0efbe..8297c3557 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -1607,7 +1607,6 @@ export default function ProcessInstanceListTable({ ); - console.log(processInstance.status); if ( processInstance.status === 'not_started' || processInstance.status === 'user_input_required' ||