mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-12 10:34:17 +00:00
if the process id of the call activity cannot be found then refresh the list and try again w/ burnettk (#316)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
90a2a0ca0b
commit
48fdb142e1
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
generatePath,
|
generatePath,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
@ -129,9 +129,7 @@ export default function ProcessModelEditDiagram() {
|
|||||||
|
|
||||||
usePrompt('Changes you made may not be saved.', diagramHasChanges);
|
usePrompt('Changes you made may not be saved.', diagramHasChanges);
|
||||||
|
|
||||||
useEffect(() => {
|
const getProcessesCallback = useCallback((onProcessesFetched?: Function) => {
|
||||||
// Grab all available process models in case we need to search for them.
|
|
||||||
// Taken from the Process Group List
|
|
||||||
const processResults = (result: any) => {
|
const processResults = (result: any) => {
|
||||||
const selectionArray = result.map((item: any) => {
|
const selectionArray = result.map((item: any) => {
|
||||||
const label = `${item.display_name} (${item.identifier})`;
|
const label = `${item.display_name} (${item.identifier})`;
|
||||||
@ -139,13 +137,19 @@ export default function ProcessModelEditDiagram() {
|
|||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
setProcesses(selectionArray);
|
setProcesses(selectionArray);
|
||||||
|
if (onProcessesFetched) {
|
||||||
|
onProcessesFetched(selectionArray);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/processes`,
|
path: `/processes`,
|
||||||
successCallback: processResults,
|
successCallback: processResults,
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, []);
|
||||||
}, []); // it is critical to only run this once.
|
|
||||||
|
useEffect(() => {
|
||||||
|
getProcessesCallback();
|
||||||
|
}, [getProcessesCallback]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fileResult = (result: any) => {
|
const fileResult = (result: any) => {
|
||||||
@ -900,6 +904,32 @@ export default function ProcessModelEditDiagram() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onLaunchBpmnEditor = (processId: string) => {
|
const onLaunchBpmnEditor = (processId: string) => {
|
||||||
|
const openProcessModelFileInNewTab = (
|
||||||
|
processReference: ProcessReference
|
||||||
|
) => {
|
||||||
|
const path = generatePath(
|
||||||
|
'/admin/process-models/:process_model_path/files/:file_name',
|
||||||
|
{
|
||||||
|
process_model_path: modifyProcessIdentifierForPathParam(
|
||||||
|
processReference.process_model_id
|
||||||
|
),
|
||||||
|
file_name: processReference.file_name,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
window.open(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openFileNameForProcessId = (
|
||||||
|
processesReferences: ProcessReference[]
|
||||||
|
) => {
|
||||||
|
const processRef = processesReferences.find((p) => {
|
||||||
|
return p.identifier === processId;
|
||||||
|
});
|
||||||
|
if (processRef) {
|
||||||
|
openProcessModelFileInNewTab(processRef);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// using the "setState" method with a function gives us access to the
|
// using the "setState" method with a function gives us access to the
|
||||||
// most current state of processes. Otherwise it uses the stale state
|
// most current state of processes. Otherwise it uses the stale state
|
||||||
// when passing the callback to a non-React component like bpmn-js:
|
// when passing the callback to a non-React component like bpmn-js:
|
||||||
@ -908,17 +938,10 @@ export default function ProcessModelEditDiagram() {
|
|||||||
const processRef = upToDateProcesses.find((p) => {
|
const processRef = upToDateProcesses.find((p) => {
|
||||||
return p.identifier === processId;
|
return p.identifier === processId;
|
||||||
});
|
});
|
||||||
if (processRef) {
|
if (!processRef) {
|
||||||
const path = generatePath(
|
getProcessesCallback(openFileNameForProcessId);
|
||||||
'/admin/process-models/:process_model_path/files/:file_name',
|
} else {
|
||||||
{
|
openProcessModelFileInNewTab(processRef);
|
||||||
process_model_path: modifyProcessIdentifierForPathParam(
|
|
||||||
processRef.process_model_id
|
|
||||||
),
|
|
||||||
file_name: processRef.file_name,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
window.open(path);
|
|
||||||
}
|
}
|
||||||
return upToDateProcesses;
|
return upToDateProcesses;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user