allow setting a failed process instance to the suspended status w/ burnettk (#416)

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2023-08-02 04:29:12 -04:00 committed by GitHub
parent b661f3b930
commit 1bc8ffc47d
2 changed files with 30 additions and 17 deletions

View File

@ -2,4 +2,8 @@ export default class ProcessInstanceClass {
static terminalStatuses() {
return ['complete', 'error', 'terminated'];
}
static nonErrorTerminalStatuses() {
return ['complete', 'terminated'];
}
}

View File

@ -436,10 +436,12 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
return <div />;
};
// 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 <div />;
};
const deleteButton = () => {
if (
processInstance &&
ProcessInstanceClass.terminalStatuses().includes(processInstance.status)
) {
return (
<ButtonWithConfirmation
data-qa="process-instance-delete"
kind="ghost"
renderIcon={TrashCan}
iconDescription="Delete"
hasIconOnly
description={`Delete Process Instance: ${processInstance.id}`}
onConfirmation={deleteProcessInstance}
confirmButtonLabel="Delete"
/>
);
}
return <div />;
};
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(
<ButtonWithConfirmation
data-qa="process-instance-delete"
kind="ghost"
renderIcon={TrashCan}
iconDescription="Delete"
hasIconOnly
description={`Delete Process Instance: ${processInstance.id}`}
onConfirmation={deleteProcessInstance}
confirmButtonLabel="Delete"
/>
);
if (ability.can('DELETE', targetUris.processInstanceActionPath)) {
elements.push(deleteButton());
}
return elements;
};