From c06c54f48edf09205aeb378e5e355c30ade2872a Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 10 May 2023 10:13:02 -0400 Subject: [PATCH] only show task instruction text if process instance is active and display the view button if instance is suspended --- .../components/ProcessInstanceListTable.tsx | 36 +++++++++++-------- .../src/routes/ProcessInterstitial.tsx | 34 +++++++++--------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 84c7bc96c..a7f70e6dc 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -1578,32 +1578,38 @@ export default function ProcessInstanceListTable({ headers.push('Action'); } - const rows = processInstances.map((row: ProcessInstance) => { + const rows = processInstances.map((processInstance: ProcessInstance) => { const currentRow = reportColumns().map((column: ReportColumn) => { - return formattedColumn(row, column); + return formattedColumn(processInstance, column); }); if (showActionsColumn) { let buttonElement = null; const interstitialUrl = `/process/${modifyProcessIdentifierForPathParam( - row.process_model_identifier - )}/${row.id}/interstitial`; + processInstance.process_model_identifier + )}/${processInstance.id}/interstitial`; const regex = new RegExp(`\\b(${preferredUsername}|${userEmail})\\b`); let hasAccessToCompleteTask = false; if ( canCompleteAllTasks || - (row.potential_owner_usernames || '').match(regex) + (processInstance.potential_owner_usernames || '').match(regex) ) { hasAccessToCompleteTask = true; } + let buttonText = 'View'; + let buttonKind = 'ghost'; + if ( + processInstance.status !== 'suspended' && + hasAccessToCompleteTask && + processInstance.task_id + ) { + buttonText = 'Go'; + buttonKind = 'secondary'; + } + buttonElement = ( - ); currentRow.push({buttonElement}); @@ -1611,18 +1617,18 @@ export default function ProcessInstanceListTable({ const rowStyle = { cursor: 'pointer' }; const modifiedModelId = modifyProcessIdentifierForPathParam( - row.process_model_identifier + processInstance.process_model_identifier ); const navigateToProcessInstance = () => { navigate( - `${processInstanceShowPathPrefix}/${modifiedModelId}/${row.id}` + `${processInstanceShowPathPrefix}/${modifiedModelId}/${processInstance.id}` ); }; return ( // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions diff --git a/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx b/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx index 1998c924f..270a00d24 100644 --- a/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx @@ -147,22 +147,24 @@ export default function ProcessInterstitial() { } const userMessage = (myTask: ProcessInstanceTask) => { - if (!myTask.can_complete && userTasks.includes(myTask.type)) { - return ( - <> -

Waiting on Someone Else

-

- This next task is assigned to a different person or team. There is - no action for you to take at this time. -

- - ); - } - if (shouldRedirect(myTask)) { - return
Redirecting you to the next task now ...
; - } - if (myTask.error_message) { - return
{myTask.error_message}
; + if (!processInstance || processInstance.status === 'completed') { + if (!myTask.can_complete && userTasks.includes(myTask.type)) { + return ( + <> +

Waiting on Someone Else

+

+ This next task is assigned to a different person or team. There is + no action for you to take at this time. +

+ + ); + } + if (shouldRedirect(myTask)) { + return
Redirecting you to the next task now ...
; + } + if (myTask.error_message) { + return
{myTask.error_message}
; + } } let message =