mi-task-show-fix (#1412)

* check for mi tasks first before checking more newest in task show api w/ burnettk

* remove console

---------

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
jasquat 2024-04-17 18:53:10 +00:00 committed by GitHub
parent 823bdd170b
commit a99c36964d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 23 deletions

View File

@ -1,13 +1,16 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
echo >&2 "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
mysql -uroot spiffworkflow_backend_unit_testing -e '
# db_name=spiffworkflow_backend_unit_testing
db_name=spiffworkflow_backend_local_development
mysql -uroot "$db_name" -e '
select * from process_instance;
select t.guid as task_guid, t.state as task_state, td.bpmn_identifier as task_id, t.properties_json from task t

View File

@ -492,7 +492,12 @@ def _process_instance_task_list(
full_bpmn_process_path = bpmn_process_cache[task_model.bpmn_process_guid]
row_key = f"{':::'.join(full_bpmn_process_path)}:::{task_model.bpmn_identifier}"
if (
if task_model.runtime_info and ("instance" in task_model.runtime_info or "iteration" in task_model.runtime_info):
# This handles adding all instances of a MI and iterations of loop tasks
additional_tasks.append(task_model)
if task_model.typename in ["SubWorkflowTask", "CallActivity"]:
relevant_subprocess_guids.add(task_model.guid)
elif (
row_key not in most_recent_tasks
or most_recent_tasks[row_key].properties_json["last_state_change"]
< task_model.properties_json["last_state_change"]
@ -503,9 +508,6 @@ def _process_instance_task_list(
# since any task like would no longer be in the list anyway and therefore will not be returned
if task_model.typename in ["SubWorkflowTask", "CallActivity"]:
relevant_subprocess_guids.add(task_model.guid)
elif task_model.runtime_info and ("instance" in task_model.runtime_info or "iteration" in task_model.runtime_info):
# This handles adding all instances of a MI and iterations of loop tasks
additional_tasks.append(task_model)
task_models = [
task_model

View File

@ -1349,10 +1349,10 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
const switchToTask = (taskGuid: string, taskListToUse: Task[] | null) => {
if (taskListToUse && taskToDisplay) {
// set to null right away to hopefully avoid using the incorrect task later
setTaskToDisplay(null);
const task = taskListToUse.find((t: Task) => t.guid === taskGuid);
if (task) {
// set to null right away to hopefully avoid using the incorrect task later
setTaskToDisplay(null);
setTaskToDisplay(task);
initializeTaskDataToDisplay(task);
}
@ -1399,7 +1399,10 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
);
};
const createButtonsForMultiTasks = (instances: number[]) => {
const createButtonsForMultiTasks = (
instances: number[],
infoType: string
) => {
if (!tasks || !taskToDisplay) {
return [];
}
@ -1407,6 +1410,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
return (
<Button
kind="ghost"
key={`btn-switch-instance-${infoType}-${v}`}
onClick={() =>
switchToTask(taskToDisplay.runtime_info.instance_map[v], tasks)
}
@ -1430,6 +1434,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
) {
accordionItems.push(
<AccordionItem
key="mi-task-instances"
title={`Task instances (${taskInstancesToDisplay.length})`}
className="task-info-modal-accordion"
>
@ -1442,25 +1447,27 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
['completed', 'running', 'future'].forEach((infoType: string) => {
let taskInstances: ReactElement[] = [];
const infoArray = taskToDisplay.runtime_info[infoType];
if (taskToDisplay.runtime_info.completed.length > 0) {
taskInstances = createButtonsForMultiTasks(infoArray);
accordionItems.push(
<AccordionItem
title={`${titleizeString(infoType)} instances for MI task (${
taskInstances.length
})`}
>
{taskInstances}
</AccordionItem>
);
}
taskInstances = createButtonsForMultiTasks(infoArray, infoType);
accordionItems.push(
<AccordionItem
key={`mi-instance-${titleizeString(infoType)}`}
title={`${titleizeString(infoType)} instances for MI task (${
taskInstances.length
})`}
>
{taskInstances}
</AccordionItem>
);
});
}
if (LOOP_TASK_TYPES.includes(taskToDisplay.typename)) {
const loopTaskInstanceIndexes = [
...Array(taskToDisplay.runtime_info.iterations_completed).keys(),
];
const buttons = createButtonsForMultiTasks(loopTaskInstanceIndexes);
const buttons = createButtonsForMultiTasks(
loopTaskInstanceIndexes,
'mi-loop-iterations'
);
let text = '';
if (
typeof taskToDisplay.runtime_info.iterations_remaining !==
@ -1470,7 +1477,10 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
text += `${taskToDisplay.runtime_info.iterations_remaining} remaining`;
}
accordionItems.push(
<AccordionItem title={`Loop iterations (${buttons.length})`}>
<AccordionItem
key="mi-loop-iterations"
title={`Loop iterations (${buttons.length})`}
>
<div>{text}</div>
<div>{buttons}</div>
</AccordionItem>