diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py
index 5fbaecdf..31cd66a3 100644
--- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py
+++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py
@@ -548,6 +548,10 @@ def process_instance_task_list(
spiff_tasks = processor.get_all_user_tasks()
subprocesses_by_child_task_ids = processor.get_subprocesses_by_child_task_ids()
+ processor.get_highest_level_subprocesses_by_child_task_ids(
+ subprocesses_by_child_task_ids
+ )
+
tasks = []
for spiff_task in spiff_tasks:
calling_subprocess_task_id = subprocesses_by_child_task_ids.get(
diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py
index 5ef4baf0..9c30e1c8 100644
--- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py
+++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py
@@ -646,6 +646,23 @@ class ProcessInstanceProcessor:
subprocesses_by_child_task_ids[task_id] = subprocess_id
return subprocesses_by_child_task_ids
+ def get_highest_level_subprocesses_by_child_task_ids(
+ self, subprocesses_by_child_task_ids: dict
+ ) -> dict:
+ """Ensure task ids point to the top level subprocess id.
+
+ This is done by checking if a subprocess is also a task until the subprocess is no longer a task.
+ """
+ for task_id, subprocess_id in subprocesses_by_child_task_ids.items():
+ if subprocess_id in subprocesses_by_child_task_ids:
+ subprocesses_by_child_task_ids[task_id] = (
+ subprocesses_by_child_task_ids[subprocess_id]
+ )
+ self.get_highest_level_subprocesses_by_child_task_ids(
+ subprocesses_by_child_task_ids
+ )
+ return subprocesses_by_child_task_ids
+
def save(self) -> None:
"""Saves the current state of this processor to the database."""
self.process_instance_model.bpmn_json = self.serialize()
diff --git a/spiffworkflow-frontend/src/helpers.tsx b/spiffworkflow-frontend/src/helpers.tsx
index b3edd776..8b91367d 100644
--- a/spiffworkflow-frontend/src/helpers.tsx
+++ b/spiffworkflow-frontend/src/helpers.tsx
@@ -219,6 +219,20 @@ export const refreshAtInterval = (
};
};
+// bpmn:SubProcess shape elements do not have children
+// but their moddle elements / businessOjects have flowElements
+// that can include the moddleElement of the subprocesses
+const getChildProcessesFromModdleElement = (bpmnModdleElement: any) => {
+ let elements: string[] = [];
+ bpmnModdleElement.flowElements.forEach((c: any) => {
+ if (c.$type === 'bpmn:SubProcess') {
+ elements.push(c.id);
+ elements = [...elements, ...getChildProcessesFromModdleElement(c)];
+ }
+ });
+ return elements;
+};
+
const getChildProcesses = (bpmnElement: any) => {
let elements: string[] = [];
bpmnElement.children.forEach((c: any) => {
@@ -229,6 +243,10 @@ const getChildProcesses = (bpmnElement: any) => {
elements = [...elements, ...getChildProcesses(c)];
} else if (c.type === 'bpmn:SubProcess') {
elements.push(c.id);
+ elements = [
+ ...elements,
+ ...getChildProcessesFromModdleElement(c.businessObject),
+ ];
}
});
return elements;
diff --git a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx
index dc0e761f..2d0f5291 100644
--- a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx
+++ b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx
@@ -205,7 +205,6 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
!callingSubprocessId ||
callingSubprocessId === task.calling_subprocess_task_id
) {
- console.log('callingSubprocessId', callingSubprocessId);
if (task.state === 'COMPLETED') {
(taskIds.completed as any).push(task);
}
diff --git a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx
index a46d02a2..a9b1224c 100644
--- a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx
+++ b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx
@@ -685,7 +685,7 @@ export default function ProcessModelShow() {
perPageOptions={[2, 5, 25]}
showReports={false}
/>
- true
+
>
);
diff --git a/spiffworkflow-frontend/src/services/UserService.ts b/spiffworkflow-frontend/src/services/UserService.ts
index 53717b8d..f893b926 100644
--- a/spiffworkflow-frontend/src/services/UserService.ts
+++ b/spiffworkflow-frontend/src/services/UserService.ts
@@ -10,9 +10,13 @@ import { BACKEND_BASE_URL } from '../config';
// Some explanation:
// https://dev.to/nilanth/how-to-secure-jwt-in-a-single-page-application-cko
+// const getCurrentLocation = (queryParams: string = window.location.search) => {
const getCurrentLocation = () => {
- // to trim off any query params
- return `${window.location.origin}${window.location.pathname}`;
+ const queryParamString = '';
+ // if (queryParams) {
+ // queryParamString = `?${queryParams}`;
+ // }
+ return `${window.location.origin}${window.location.pathname}${queryParamString}`;
};
const doLogin = () => {
@@ -60,18 +64,20 @@ const getPreferredUsername = () => {
// FIXME: we could probably change this search to a hook
// and then could use useSearchParams here instead
const getAuthTokenFromParams = () => {
- const queryParams = window.location.search;
- const accessTokenMatch = queryParams.match(/.*\baccess_token=([^&]+).*/);
- const idTokenMatch = queryParams.match(/.*\bid_token=([^&]+).*/);
- if (accessTokenMatch) {
- const accessToken = accessTokenMatch[1];
+ const queryParams = new URLSearchParams(window.location.search);
+ const accessToken = queryParams.get('access_token');
+ const idToken = queryParams.get('id_token');
+
+ queryParams.delete('access_token');
+ queryParams.delete('id_token');
+
+ if (accessToken) {
localStorage.setItem('jwtAccessToken', accessToken);
- if (idTokenMatch) {
- const idToken = idTokenMatch[1];
+ if (idToken) {
localStorage.setItem('jwtIdToken', idToken);
}
- // to remove token query param
- window.location.href = getCurrentLocation();
+ // window.location.href = `${getCurrentLocation(queryParams.toString())}`;
+ window.location.href = `${getCurrentLocation()}`;
} else if (!isLoggedIn()) {
doLogin();
}