added link to go back to most recent

This commit is contained in:
jasquat 2023-03-23 13:55:16 -04:00
parent 46b49bbfe3
commit f45f2c1cc6
3 changed files with 65 additions and 26 deletions

View File

@ -685,7 +685,7 @@ def process_instance_task_list(
if to_task_model is not None:
task_models_dict = json.loads(current_app.json.dumps(task_models))
for task_model in task_models_dict:
end_in_seconds = float(task_model["end_in_seconds"])
end_in_seconds = float(task_model["end_in_seconds"]) if task_model["end_in_seconds"] is not None else None
if to_task_model.guid == task_model["guid"] and task_model["state"] == "COMPLETED":
TaskService.reset_task_model_dict(task_model, state="READY")
elif (

View File

@ -55,8 +55,7 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
const tableRow = [];
const taskNameCell = (
<td>
{logEntry.spiff_task_guid ||
logEntry.task_definition_name ||
{logEntry.task_definition_name ||
(logEntry.bpmn_task_type === 'StartEvent' ? 'Process Started' : '') ||
(logEntry.bpmn_task_type === 'EndEvent' ? 'Process Ended' : '')}
</td>
@ -96,17 +95,24 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
</>
);
}
// tableRow.push(<td>{convertSecondsToFormattedDateTime(logEntry.timestamp)}</td>);
tableRow.push(
<td>
<Link
data-qa="process-instance-show-link"
to={`${processInstanceShowPageBaseUrl}/${logEntry.process_instance_id}/${logEntry.spiff_task_guid}`}
>
{convertSecondsToFormattedDateTime(logEntry.timestamp)}
</Link>
</td>
let timestampComponent = (
<td>{convertSecondsToFormattedDateTime(logEntry.timestamp)}</td>
);
if (logEntry.spiff_task_guid) {
timestampComponent = (
<td>
<Link
data-qa="process-instance-show-link"
to={`${processInstanceShowPageBaseUrl}/${logEntry.process_instance_id}/${logEntry.spiff_task_guid}`}
title="View state when task was completed"
>
{convertSecondsToFormattedDateTime(logEntry.timestamp)}
</Link>
</td>
);
}
tableRow.push(timestampComponent);
return <tr key={logEntry.id}>{tableRow}</tr>;
};

View File

@ -605,7 +605,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
}
};
const isCurrentTask = (task: Task) => {
const isActiveTask = (task: Task) => {
const subprocessTypes = [
'Subprocess',
'CallActivity',
@ -622,7 +622,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
return (
processInstance &&
ability.can('PUT', targetUris.processInstanceTaskDataPath) &&
isCurrentTask(task) &&
isActiveTask(task) &&
processInstance.status === 'suspended' &&
showingLastSpiffStep()
);
@ -646,7 +646,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
processInstance &&
processInstance.status === 'suspended' &&
ability.can('POST', targetUris.processInstanceCompleteTaskPath) &&
isCurrentTask(task) &&
isActiveTask(task) &&
showingLastSpiffStep()
);
};
@ -976,16 +976,18 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
): {taskToUse.state}
{taskDisplayButtons(taskToUse)}
</Stack>
<div>
<Stack orientation="horizontal" gap={2}>
{completionViewLink(
'View state at task completion',
taskToUse.guid
)}
</Stack>
<br />
<br />
</div>
{taskToUse.state == 'COMPLETED' ? (
<div>
<Stack orientation="horizontal" gap={2}>
{completionViewLink(
'View state at task completion',
taskToUse.guid
)}
</Stack>
<br />
<br />
</div>
) : null}
{selectingEvent
? eventSelector(candidateEvents)
: taskDataContainer()}
@ -1029,6 +1031,36 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
return elements;
};
// right now this just assume if to_task_guid was passed in then
// this cannot be the active task.
// we may need a better way to figure this out.
const showingActiveTask = () => {
return !!params.to_task_guid;
};
const viewMostRecentStateComponent = () => {
if (!showingActiveTask()) {
return null;
}
return (
<>
<Grid condensed fullWidth>
<Column md={6} lg={8} sm={4}>
<Link
reloadDocument
data-qa="process-instance-view-active-task-link"
to={processInstanceShowPageBaseUrl}
>
View at most recent state
</Link>
</Column>
</Grid>
<br />
</>
);
};
if (processInstance && (tasks || tasksCallHadError)) {
const taskIds = getTaskIds();
const processModelId = unModifyProcessIdentifierForPathParam(
@ -1083,6 +1115,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
{processDataDisplayArea()}
{processInstanceMetadataArea()}
<br />
{viewMostRecentStateComponent()}
<ReactDiagramEditor
processModelId={processModelId || ''}
diagramXML={processInstance.bpmn_xml_file_contents || ''}