From c5cd81975e7bccc084d4a6307008d61affc406fd Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 23 Apr 2023 11:43:25 -0400 Subject: [PATCH 1/4] * Clicking anywhere in the row should take you to the process instance page. --- .../components/ProcessInstanceListTable.tsx | 63 ++++++------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index d214c6222..3247fec0d 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -1365,68 +1365,30 @@ export default function ProcessInstanceListTable({ const formatter = reportColumnFormatters[column.accessor] ?? defaultFormatter; const value = row[column.accessor]; - const modifiedModelId = modifyProcessIdentifierForPathParam( - row.process_model_identifier - ); - const navigateToProcessInstance = () => { - navigate(`${processInstanceShowPathPrefix}/${modifiedModelId}/${row.id}`); - }; - const navigateToProcessModel = () => { - navigate(`/admin/process-models/${modifiedModelId}`); - }; if (column.accessor === 'status') { return ( - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions - + {formatter(row, value)} ); } if (column.accessor === 'process_model_display_name') { - const pmStyle = { background: 'rgba(0, 0, 0, .02)' }; - return ( - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions - - {formatter(row, value)} - - ); + return {formatter(row, value)} ; } if (column.accessor === 'waiting_for') { - return ( - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions - - {getWaitingForTableCellComponent(row)} - - ); + return {getWaitingForTableCellComponent(row)} ; } if (column.accessor === 'updated_at_in_seconds') { return ( ); } return ( // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions - + {formatter(row, value)} ); @@ -1484,9 +1446,22 @@ export default function ProcessInstanceListTable({ } const rowStyle = { cursor: 'pointer' }; - + const modifiedModelId = modifyProcessIdentifierForPathParam( + row.process_model_identifier + ); + const navigateToProcessInstance = () => { + navigate( + `${processInstanceShowPathPrefix}/${modifiedModelId}/${row.id}` + ); + }; return ( - + // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions + {currentRow} ); From c8c74dded9c914e1b70bbea1503619869ca1d391 Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 23 Apr 2023 11:46:29 -0400 Subject: [PATCH 2/4] run_pyl --- .../src/spiffworkflow_backend/config/__init__.py | 12 ++++++------ .../spiffworkflow_backend/models/process_instance.py | 6 +++--- .../services/process_instance_processor.py | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py index eaf67f6c9..7711c36f9 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py @@ -18,13 +18,13 @@ def setup_database_uri(app: Flask) -> None: if app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_URI") is None: database_name = f"spiffworkflow_backend_{app.config['ENV_IDENTIFIER']}" if app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == "sqlite": - app.config[ - "SQLALCHEMY_DATABASE_URI" - ] = f"sqlite:///{app.instance_path}/db_{app.config['ENV_IDENTIFIER']}.sqlite3" + app.config["SQLALCHEMY_DATABASE_URI"] = ( + f"sqlite:///{app.instance_path}/db_{app.config['ENV_IDENTIFIER']}.sqlite3" + ) elif app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == "postgres": - app.config[ - "SQLALCHEMY_DATABASE_URI" - ] = f"postgresql://spiffworkflow_backend:spiffworkflow_backend@localhost:5432/{database_name}" + app.config["SQLALCHEMY_DATABASE_URI"] = ( + f"postgresql://spiffworkflow_backend:spiffworkflow_backend@localhost:5432/{database_name}" + ) else: # use pswd to trick flake8 with hardcoded passwords db_pswd = app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_PASSWORD") diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py index 44fe82764..009a7486e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py @@ -127,9 +127,9 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel): def serialized_with_metadata(self) -> dict[str, Any]: process_instance_attributes = self.serialized process_instance_attributes["process_metadata"] = self.process_metadata - process_instance_attributes[ - "process_model_with_diagram_identifier" - ] = self.process_model_with_diagram_identifier + process_instance_attributes["process_model_with_diagram_identifier"] = ( + self.process_model_with_diagram_identifier + ) return process_instance_attributes @property diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index 352bd4ac5..d3f629596 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -423,9 +423,9 @@ class ProcessInstanceProcessor: tld.process_instance_id = process_instance_model.id # we want this to be the fully qualified path to the process model including all group subcomponents - current_app.config[ - "THREAD_LOCAL_DATA" - ].process_model_identifier = f"{process_instance_model.process_model_identifier}" + current_app.config["THREAD_LOCAL_DATA"].process_model_identifier = ( + f"{process_instance_model.process_model_identifier}" + ) self.process_instance_model = process_instance_model self.process_model_service = ProcessModelService() @@ -585,9 +585,9 @@ class ProcessInstanceProcessor: bpmn_subprocess_definition.bpmn_identifier ] = bpmn_process_definition_dict spiff_bpmn_process_dict["subprocess_specs"][bpmn_subprocess_definition.bpmn_identifier]["task_specs"] = {} - bpmn_subprocess_definition_bpmn_identifiers[ - bpmn_subprocess_definition.id - ] = bpmn_subprocess_definition.bpmn_identifier + bpmn_subprocess_definition_bpmn_identifiers[bpmn_subprocess_definition.id] = ( + bpmn_subprocess_definition.bpmn_identifier + ) task_definitions = TaskDefinitionModel.query.filter( TaskDefinitionModel.bpmn_process_definition_id.in_( # type: ignore From 59bf136864021435a9ee67134fccd7503a08a24f Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 23 Apr 2023 12:22:43 -0400 Subject: [PATCH 3/4] * Was doing things a bit out of order - so we weren't always displaying messages as we should have on the interstitial page. * Do a better job of catching all the error messages when they happen. --- .../routes/tasks_controller.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 498603947..8dd8d05d3 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -406,16 +406,25 @@ def _interstitial_stream(process_instance_id: int) -> Generator[str, Optional[st yield f"data: {current_app.json.dumps(task)} \n\n" last_task = spiff_task try: - processor.do_engine_steps(execution_strategy_name="run_until_user_message") processor.do_engine_steps(execution_strategy_name="one_at_a_time") + processor.do_engine_steps(execution_strategy_name="run_until_user_message") + processor.save() # Fixme - maybe find a way not to do this on every loop? except WorkflowTaskException as wfe: api_error = ApiError.from_workflow_exception( "engine_steps_error", "Failed complete an automated task.", exp=wfe ) yield f"data: {current_app.json.dumps(api_error)} \n\n" + except Exception as e: + api_error = ApiError( + error_code="engine_steps_error", + message=f"Failed complete an automated task. Error was: {str(e)}", + status_code=400, + ) + yield f"data: {current_app.json.dumps(api_error)} \n\n" + + # Note, this has to be done in case someone leaves the page, # which can otherwise cancel this function and leave completed tasks un-registered. - processor.save() # Fixme - maybe find a way not to do this on every loop? spiff_task = processor.next_task() # Always provide some response, in the event no instructions were provided. From 9aafe7dad6a78605f78535f61cf7cc0fd43138be Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 23 Apr 2023 12:27:40 -0400 Subject: [PATCH 4/4] run pyl --- .../src/spiffworkflow_backend/routes/tasks_controller.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 8dd8d05d3..9a1796ff1 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -416,13 +416,12 @@ def _interstitial_stream(process_instance_id: int) -> Generator[str, Optional[st yield f"data: {current_app.json.dumps(api_error)} \n\n" except Exception as e: api_error = ApiError( - error_code="engine_steps_error", - message=f"Failed complete an automated task. Error was: {str(e)}", - status_code=400, - ) + error_code="engine_steps_error", + message=f"Failed complete an automated task. Error was: {str(e)}", + status_code=400, + ) yield f"data: {current_app.json.dumps(api_error)} \n\n" - # Note, this has to be done in case someone leaves the page, # which can otherwise cancel this function and leave completed tasks un-registered. spiff_task = processor.next_task()