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 #!/usr/bin/env bash
function error_handler() { 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" exit "$2"
} }
trap 'error_handler ${LINENO} $?' ERR trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail 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 * 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 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] full_bpmn_process_path = bpmn_process_cache[task_model.bpmn_process_guid]
row_key = f"{':::'.join(full_bpmn_process_path)}:::{task_model.bpmn_identifier}" 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 row_key not in most_recent_tasks
or most_recent_tasks[row_key].properties_json["last_state_change"] or most_recent_tasks[row_key].properties_json["last_state_change"]
< task_model.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 # 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"]: if task_model.typename in ["SubWorkflowTask", "CallActivity"]:
relevant_subprocess_guids.add(task_model.guid) 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_models = [
task_model task_model

View File

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