From 1bc8ffc47dcd6f668ee84e2ede94e71ff6bca0f4 Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Wed, 2 Aug 2023 04:29:12 -0400 Subject: [PATCH] allow setting a failed process instance to the suspended status w/ burnettk (#416) Co-authored-by: jasquat --- .../src/classes/ProcessInstanceClass.tsx | 4 ++ .../src/routes/ProcessInstanceShow.tsx | 43 +++++++++++-------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/spiffworkflow-frontend/src/classes/ProcessInstanceClass.tsx b/spiffworkflow-frontend/src/classes/ProcessInstanceClass.tsx index d44569cd4..a959a002e 100644 --- a/spiffworkflow-frontend/src/classes/ProcessInstanceClass.tsx +++ b/spiffworkflow-frontend/src/classes/ProcessInstanceClass.tsx @@ -2,4 +2,8 @@ export default class ProcessInstanceClass { static terminalStatuses() { return ['complete', 'error', 'terminated']; } + + static nonErrorTerminalStatuses() { + return ['complete', 'terminated']; + } } diff --git a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx index 10c7b10fd..e6b16c8b2 100644 --- a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx @@ -436,10 +436,12 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { return
; }; + // you cannot suspend an instance that is done. except if it has status error, since + // you might want to perform admin actions to recover from an errored instance. const suspendButton = () => { if ( processInstance && - !ProcessInstanceClass.terminalStatuses() + !ProcessInstanceClass.nonErrorTerminalStatuses() .concat(['suspended']) .includes(processInstance.status) ) { @@ -473,6 +475,27 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { return
; }; + const deleteButton = () => { + if ( + processInstance && + ProcessInstanceClass.terminalStatuses().includes(processInstance.status) + ) { + return ( + + ); + } + return
; + }; + const processTaskResult = (result: Task) => { if (result == null) { setTaskDataToDisplay(''); @@ -1135,22 +1158,8 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { if (ability.can('POST', `${targetUris.processInstanceResumePath}`)) { elements.push(resumeButton()); } - if ( - ability.can('DELETE', targetUris.processInstanceActionPath) && - ProcessInstanceClass.terminalStatuses().includes(processInstance.status) - ) { - elements.push( - - ); + if (ability.can('DELETE', targetUris.processInstanceActionPath)) { + elements.push(deleteButton()); } return elements; };