call proceses through setProcesses to ensure we have up to date value and removed debug logs w/ burnettk

This commit is contained in:
jasquat 2023-01-09 17:43:56 -05:00
parent 9ad1e0ced0
commit e680734a9b
2 changed files with 22 additions and 27 deletions

View File

@ -265,12 +265,7 @@ export default function ReactDiagramEditor({
});
diagramModeler.on('spiff.callactivity.edit', (event: any) => {
console.log('Received event spiff.callactivity.edit');
if (onLaunchBpmnEditor) {
console.log(
'Calling function onLaunchBpmnEditor with ',
event.processId
);
onLaunchBpmnEditor(event.processId);
}
});

View File

@ -121,10 +121,6 @@ export default function ProcessModelEditDiagram() {
Object.assign(item, { label });
return item;
});
console.log(
'Setting Process arrays with selection of length: ',
selectionArray.length
);
setProcesses(selectionArray);
};
HttpService.makeCallToBackend({
@ -791,7 +787,6 @@ export default function ProcessModelEditDiagram() {
};
const processModelSelector = () => {
console.log('IN MODEL SELECTOR: ', processes);
return (
<Modal
open={showProcessSearch}
@ -832,25 +827,30 @@ export default function ProcessModelEditDiagram() {
};
const onLaunchBpmnEditor = (processId: string) => {
console.log('onLaunchBpmnEditor - processId: ', processId);
console.log('processes', processes);
const processRef = processes.find((p) => {
return p.identifier === processId;
// using the "setState" method with a function gives us access to the
// most current state of processes. Otherwise it uses the stale state
// when passing the callback to a non-React component like bpmn-js:
// https://stackoverflow.com/a/60643670/6090676
setProcesses((upToDateProcesses: ProcessReference[]) => {
const processRef = upToDateProcesses.find((p) => {
return p.identifier === processId;
});
if (processRef) {
const path = generatePath(
'/admin/process-models/:process_model_path/files/:file_name',
{
process_model_path: modifyProcessIdentifierForPathParam(
processRef.process_model_id
),
file_name: processRef.file_name,
}
);
window.open(path);
}
return upToDateProcesses;
});
if (processRef) {
console.log('Found ProcessRef: ', processRef);
const path = generatePath(
'/admin/process-models/:process_model_path/files/:file_name',
{
process_model_path: modifyProcessIdentifierForPathParam(
processRef.process_model_id
),
file_name: processRef.file_name,
}
);
window.open(path);
}
};
const onLaunchJsonEditor = (fileName: string) => {
const path = generatePath(
'/admin/process-models/:process_model_id/form/:file_name',