From dc9ce04728ee21946b7a340fe9d56ca2c49b91a9 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 31 May 2023 12:11:27 -0400 Subject: [PATCH] redirect to the non-for-me page if allowed when performing an admin action w/ burnettk --- .../src/routes/ProcessInstanceShow.tsx | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx index ca7968a2b..4e6fee340 100644 --- a/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessInstanceShow.tsx @@ -105,7 +105,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { [`${targetUris.processInstanceTerminatePath}`]: ['POST'], [targetUris.processInstanceResetPath]: ['POST'], [targetUris.messageInstanceListPath]: ['GET'], - [targetUris.processInstanceActionPath]: ['DELETE'], + [targetUris.processInstanceActionPath]: ['DELETE', 'GET'], [targetUris.processInstanceLogListPath]: ['GET'], [targetUris.processInstanceTaskDataPath]: ['GET', 'PUT'], [targetUris.processInstanceSendEventPath]: ['POST'], @@ -125,8 +125,9 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { let processInstanceShowPageBaseUrl = `/admin/process-instances/for-me/${params.process_model_id}/${params.process_instance_id}`; let processInstanceLogListPageBaseUrl = `/admin/logs/for-me/${params.process_model_id}/${params.process_instance_id}`; + const processInstanceShowPageBaseUrlAllVariant = `/admin/process-instances/${params.process_model_id}/${params.process_instance_id}`; if (variant === 'all') { - processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}/${params.process_instance_id}`; + processInstanceShowPageBaseUrl = processInstanceShowPageBaseUrlAllVariant; processInstanceLogListPageBaseUrl = `/admin/logs/${params.process_model_id}/${params.process_instance_id}`; } @@ -209,9 +210,33 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { }); }; + const queryParams = () => { + const processIdentifier = searchParams.get('process_identifier'); + const callActivityTaskId = searchParams.get('bpmn_process_guid'); + const queryParamArray = []; + if (processIdentifier) { + queryParamArray.push(`process_identifier=${processIdentifier}`); + } + if (callActivityTaskId) { + queryParamArray.push(`bpmn_process_guid=${callActivityTaskId}`); + } + let queryParamString = ''; + if (queryParamArray.length > 0) { + queryParamString = `?${queryParamArray.join('&')}`; + } + return queryParamString; + }; + // to force update the diagram since it could have changed const refreshPage = () => { - window.location.reload(); + // redirect to the all variant page if possible to avoid potential user/task association issues. + // such as terminating a process instance with a task that the current user is assigned to which + // will remove the task assigned to them and could potentially remove that users association to the process instance + if (ability.can('GET', targetUris.processInstanceActionPath)) { + window.location.href = `${processInstanceShowPageBaseUrlAllVariant}${queryParams()}`; + } else { + window.location.reload(); + } }; const terminateProcessInstance = () => { @@ -252,23 +277,6 @@ export default function ProcessInstanceShow({ variant }: OwnProps) { return !taskToTimeTravelTo; }; - const queryParams = () => { - const processIdentifier = searchParams.get('process_identifier'); - const callActivityTaskId = searchParams.get('bpmn_process_guid'); - const queryParamArray = []; - if (processIdentifier) { - queryParamArray.push(`process_identifier=${processIdentifier}`); - } - if (callActivityTaskId) { - queryParamArray.push(`bpmn_process_guid=${callActivityTaskId}`); - } - let queryParamString = ''; - if (queryParamArray.length > 0) { - queryParamString = `?${queryParamArray.join('&')}`; - } - return queryParamString; - }; - const completionViewLink = (label: any, taskGuid: string) => { return (