Merge branch 'main' into feature/remove-loop-reset

This commit is contained in:
Elizabeth Esswein 2023-03-09 09:55:52 -05:00
commit 2ecfecb9b4
10 changed files with 166 additions and 102 deletions

View File

@ -660,6 +660,18 @@ paths:
description: The username of the process initiator
schema:
type: string
- name: report_columns
in: query
required: false
description: Base64 encoded json of report columns.
schema:
type: string
- name: report_filter_by
in: query
required: false
description: Base64 encoded json of report filter by.
schema:
type: string
get:
operationId: spiffworkflow_backend.routes.process_instances_controller.process_instance_list_for_me
summary: Returns a list of process instances that are associated with me.
@ -779,6 +791,18 @@ paths:
description: The username of the process initiator
schema:
type: string
- name: report_columns
in: query
required: false
description: Base64 encoded json of report columns.
schema:
type: string
- name: report_filter_by
in: query
required: false
description: Base64 encoded json of report filter by.
schema:
type: string
get:
operationId: spiffworkflow_backend.routes.process_instances_controller.process_instance_list
summary: Returns a list of process instances.

View File

@ -55,7 +55,7 @@ class TaskModel(SpiffworkflowBaseDBModel):
json_data_hash: str = db.Column(db.String(255), nullable=False, index=True)
start_in_seconds: float = db.Column(db.DECIMAL(17, 6))
end_in_seconds: float | None = db.Column(db.DECIMAL(17, 6))
end_in_seconds: Union[float, None] = db.Column(db.DECIMAL(17, 6))
class Task:

View File

@ -1,4 +1,5 @@
"""APIs for dealing with process groups, process models, and process instances."""
import base64
import json
from uuid import UUID
from typing import Any
@ -117,10 +118,10 @@ def process_instance_run(
)
processor = ProcessInstanceProcessor(process_instance)
processor.lock_process_instance("Web")
if do_engine_steps:
try:
processor.lock_process_instance("Web")
processor.do_engine_steps(save=True)
except ApiError as e:
ErrorHandlingService().handle_error(processor, e)
@ -252,6 +253,8 @@ def process_instance_list_for_me(
report_id: Optional[int] = None,
user_group_identifier: Optional[str] = None,
process_initiator_username: Optional[str] = None,
report_columns: Optional[str] = None,
report_filter_by: Optional[str] = None,
) -> flask.wrappers.Response:
"""Process_instance_list_for_me."""
return process_instance_list(
@ -268,6 +271,8 @@ def process_instance_list_for_me(
report_id=report_id,
user_group_identifier=user_group_identifier,
with_relation_to_me=True,
report_columns=report_columns,
report_filter_by=report_filter_by,
)
@ -286,12 +291,21 @@ def process_instance_list(
report_id: Optional[int] = None,
user_group_identifier: Optional[str] = None,
process_initiator_username: Optional[str] = None,
report_columns: Optional[str] = None,
report_filter_by: Optional[str] = None,
) -> flask.wrappers.Response:
"""Process_instance_list."""
process_instance_report = ProcessInstanceReportService.report_with_identifier(
g.user, report_id, report_identifier
)
report_column_list = None
if report_columns:
report_column_list = json.loads(base64.b64decode(report_columns))
report_filter_by_list = None
if report_filter_by:
report_filter_by_list = json.loads(base64.b64decode(report_filter_by))
if user_filter:
report_filter = ProcessInstanceReportFilter(
process_model_identifier=process_model_identifier,
@ -303,6 +317,8 @@ def process_instance_list(
with_relation_to_me=with_relation_to_me,
process_status=process_status.split(",") if process_status else None,
process_initiator_username=process_initiator_username,
report_column_list=report_column_list,
report_filter_by_list=report_filter_by_list,
)
else:
report_filter = (
@ -317,6 +333,8 @@ def process_instance_list(
process_status=process_status,
with_relation_to_me=with_relation_to_me,
process_initiator_username=process_initiator_username,
report_column_list=report_column_list,
report_filter_by_list=report_filter_by_list,
)
)

View File

@ -2,6 +2,7 @@
import json
import logging
import re
import sys
from typing import Any
from typing import Optional
@ -171,6 +172,10 @@ def setup_logger(app: Flask) -> None:
the_logger.propagate = False
the_logger.addHandler(spiff_logger_filehandler)
else:
if len(the_logger.handlers) < 1:
# it's very verbose, so only add handlers for the obscure loggers when log level is DEBUG
if upper_log_level_string == "DEBUG":
the_logger.addHandler(logging.StreamHandler(sys.stdout))
for the_handler in the_logger.handlers:
the_handler.setFormatter(log_formatter)
the_handler.setLevel(log_level)

View File

@ -50,6 +50,8 @@ class ProcessInstanceReportFilter:
with_tasks_assigned_to_my_group: Optional[bool] = None
with_relation_to_me: Optional[bool] = None
process_initiator_username: Optional[str] = None
report_column_list: Optional[list] = None
report_filter_by_list: Optional[list] = None
def to_dict(self) -> dict[str, str]:
"""To_dict."""
@ -85,6 +87,10 @@ class ProcessInstanceReportFilter:
d["with_relation_to_me"] = str(self.with_relation_to_me).lower()
if self.process_initiator_username is not None:
d["process_initiator_username"] = str(self.process_initiator_username)
if self.report_column_list is not None:
d["report_column_list"] = str(self.report_column_list)
if self.report_filter_by_list is not None:
d["report_filter_by_list"] = str(self.report_filter_by_list)
return d
@ -229,6 +235,8 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group = bool_value("with_tasks_assigned_to_my_group")
with_relation_to_me = bool_value("with_relation_to_me")
process_initiator_username = filters.get("process_initiator_username")
report_column_list = list_value("report_column_list")
report_filter_by_list = list_value("report_filter_by_list")
report_filter = ProcessInstanceReportFilter(
process_model_identifier=process_model_identifier,
@ -244,6 +252,8 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group=with_tasks_assigned_to_my_group,
with_relation_to_me=with_relation_to_me,
process_initiator_username=process_initiator_username,
report_column_list=report_column_list,
report_filter_by_list=report_filter_by_list,
)
return report_filter
@ -265,6 +275,8 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group: Optional[bool] = None,
with_relation_to_me: Optional[bool] = None,
process_initiator_username: Optional[str] = None,
report_column_list: Optional[list] = None,
report_filter_by_list: Optional[list] = None,
) -> ProcessInstanceReportFilter:
"""Filter_from_metadata_with_overrides."""
report_filter = cls.filter_from_metadata(process_instance_report)
@ -291,6 +303,10 @@ class ProcessInstanceReportService:
report_filter.with_tasks_completed_by_me = with_tasks_completed_by_me
if process_initiator_username is not None:
report_filter.process_initiator_username = process_initiator_username
if report_column_list is not None:
report_filter.report_column_list = report_column_list
if report_filter_by_list is not None:
report_filter.report_filter_by_list = report_filter_by_list
if with_tasks_assigned_to_my_group is not None:
report_filter.with_tasks_assigned_to_my_group = (
with_tasks_assigned_to_my_group
@ -483,6 +499,15 @@ class ProcessInstanceReportService:
stock_columns = ProcessInstanceReportService.get_column_names_for_model(
ProcessInstanceModel
)
if report_filter.report_column_list:
process_instance_report.report_metadata["columns"] = (
report_filter.report_column_list
)
if report_filter.report_filter_by_list:
process_instance_report.report_metadata["filter_by"] = (
report_filter.report_filter_by_list
)
for column in process_instance_report.report_metadata["columns"]:
if column["accessor"] in stock_columns:
continue

View File

@ -10,7 +10,7 @@ const approveWithUser = (
.contains(/^Submit$/)
.click();
cy.contains('Tasks I can complete', { timeout: 20000 });
cy.contains('Tasks I can complete', { timeout: 30000 });
cy.get('.cds--btn').contains(/^Go$/).click();
// approve!
@ -19,12 +19,12 @@ const approveWithUser = (
.contains(/^Submit$/)
.click();
if (expectAdditionalApprovalInfoPage) {
cy.contains(expectAdditionalApprovalInfoPage, { timeout: 20000 });
cy.contains(expectAdditionalApprovalInfoPage, { timeout: 30000 });
cy.get('button')
.contains(/^Continue$/)
.click();
}
cy.location({ timeout: 20000 }).should((loc) => {
cy.location({ timeout: 30000 }).should((loc) => {
expect(loc.pathname).to.eq('/tasks');
});
cy.logout();
@ -37,7 +37,7 @@ describe('pp1', () => {
cy.contains('Start New +').click();
cy.contains('Raise New Demand Request');
cy.runPrimaryBpmnFile(true);
cy.contains('Please select the type of request to Start the process.');
cy.contains('Please select the type of request to start the process.');
// wait a second to ensure we can click the radio button
cy.wait(1000);
cy.get('input#root-procurement').click();
@ -47,7 +47,7 @@ describe('pp1', () => {
.click();
cy.contains(
'Submit a new demand request for the procurement of needed items',
{ timeout: 20000 }
{ timeout: 30000 }
);
cy.url().then((currentUrl) => {
@ -68,7 +68,7 @@ describe('pp1', () => {
.contains(/^Submit$/)
.click();
cy.contains('Task: Enter NDR Items', { timeout: 20000 });
cy.contains('Task: Enter NDR Items', { timeout: 30000 });
cy.get('#root_0_sub_category').select('op_src');
cy.get('#root_0_item').clear().type('spiffworkflow');
cy.get('#root_0_qty').clear().type('1');
@ -81,13 +81,14 @@ describe('pp1', () => {
cy.contains(
'Review and provide any supporting information or files for your request.',
{ timeout: 20000 }
{ timeout: 30000 }
);
cy.contains('Submit the Request').click();
cy.get('input[value="Submit the Request"]').click();
cy.get('button')
.contains(/^Submit$/)
.click();
cy.contains('Tasks for my open instances', { timeout: 30000 });
cy.logout();
approveWithUser(

View File

@ -36,6 +36,7 @@ import {
convertSecondsToFormattedDateString,
convertSecondsToFormattedDateTime,
convertSecondsToFormattedTimeHoursMinutes,
encodeBase64,
getPageInfoFromSearchParams,
getProcessModelFullIdentifierFromSearchParams,
modifyProcessIdentifierForPathParam,
@ -268,6 +269,17 @@ export default function ProcessInstanceListTable({
queryParamString += `&report_identifier=${reportIdentifier}`;
}
if (searchParams.get('report_columns')) {
queryParamString += `&report_columns=${searchParams.get(
'report_columns'
)}`;
}
if (searchParams.get('report_filter_by')) {
queryParamString += `&report_filter_by=${searchParams.get(
'report_filter_by'
)}`;
}
Object.keys(dateParametersToAlwaysFilterBy).forEach(
(paramName: string) => {
const dateFunctionToCall =
@ -529,6 +541,14 @@ export default function ProcessInstanceListTable({
};
};
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const reportFilterBy = () => {
return (reportMetadata as any).filter_by;
};
const applyFilter = (event: any) => {
event.preventDefault();
const { page, perPage } = getPageInfoFromSearchParams(
@ -578,6 +598,11 @@ export default function ProcessInstanceListTable({
queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`;
}
const reportColumnsBase64 = encodeBase64(JSON.stringify(reportColumns()));
queryParamString += `&report_columns=${reportColumnsBase64}`;
const reportFilterByBase64 = encodeBase64(JSON.stringify(reportFilterBy()));
queryParamString += `&report_filter_by=${reportFilterByBase64}`;
removeError();
setProcessInstanceReportJustSaved(null);
setProcessInstanceFilters({});
@ -683,10 +708,6 @@ export default function ProcessInstanceListTable({
navigate(`${processInstanceListPathPrefix}${queryParamString}`);
};
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const reportColumnAccessors = () => {
return reportColumns().map((reportColumn: ReportColumn) => {
return reportColumn.accessor;

View File

@ -1,4 +1,6 @@
import { format } from 'date-fns';
import { Buffer } from 'buffer';
import {
DATE_TIME_FORMAT,
DATE_FORMAT,
@ -260,3 +262,11 @@ export const getBpmnProcessIdentifiers = (rootBpmnElement: any) => {
export const isInteger = (str: string | number) => {
return /^\d+$/.test(str.toString());
};
export const encodeBase64 = (data: string) => {
return Buffer.from(data).toString('base64');
};
export const decodeBase64 = (data: string) => {
return Buffer.from(data, 'base64').toString('ascii');
};

View File

@ -80,7 +80,6 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
const [eventPayload, setEventPayload] = useState<string>('{}');
const [eventTextEditorEnabled, setEventTextEditorEnabled] =
useState<boolean>(false);
const [displayDetails, setDisplayDetails] = useState<boolean>(false);
const [showProcessInstanceMetadata, setShowProcessInstanceMetadata] =
useState<boolean>(false);
@ -304,92 +303,26 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
});
};
const detailedViewElement = () => {
if (!processInstance) {
return null;
}
if (displayDetails) {
return (
<>
<Grid condensed fullWidth>
<Button
kind="ghost"
className="button-link"
onClick={() => setDisplayDetails(false)}
title="Hide Details"
>
&laquo; Hide Details
</Button>
</Grid>
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
Updated At:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
{convertSecondsToFormattedDateTime(
processInstance.updated_at_in_seconds
)}
</Column>
</Grid>
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
Created At:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
{convertSecondsToFormattedDateTime(
processInstance.created_at_in_seconds
)}
</Column>
</Grid>
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
Process model revision:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
{processInstance.bpmn_version_control_identifier} (
{processInstance.bpmn_version_control_type})
</Column>
</Grid>
</>
);
}
return (
<Grid condensed fullWidth>
<Button
kind="ghost"
className="button-link"
onClick={() => setDisplayDetails(true)}
title="Show Details"
>
View Details &raquo;
</Button>
</Grid>
);
};
const getInfoTag = () => {
if (!processInstance) {
return null;
}
const currentEndDate = convertSecondsToFormattedDateTime(
processInstance.end_in_seconds || 0
);
let currentEndDateTag;
if (currentEndDate) {
currentEndDateTag = (
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
Completed:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
{convertSecondsToFormattedDateTime(
processInstance.end_in_seconds || 0
) || 'N/A'}
</Column>
</Grid>
);
let lastUpdatedTimeLabel = 'Updated At';
let lastUpdatedTime = processInstance.updated_at_in_seconds;
if (processInstance.end_in_seconds) {
lastUpdatedTimeLabel = 'Completed';
lastUpdatedTime = processInstance.end_in_seconds;
}
const lastUpdatedTimeTag = (
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
{lastUpdatedTimeLabel}:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
{convertSecondsToFormattedDateTime(lastUpdatedTime || 0) || 'N/A'}
</Column>
</Grid>
);
let statusIcon = <InProgress />;
if (processInstance.status === 'suspended') {
@ -433,13 +366,30 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
<Column sm={1} md={1} lg={2} className="grid-list-title">
Started:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
<Column
sm={3}
md={3}
lg={3}
className="grid-date"
title={`Created At: ${convertSecondsToFormattedDateTime(
processInstance.created_at_in_seconds
)}`}
>
{convertSecondsToFormattedDateTime(
processInstance.start_in_seconds || 0
)}
</Column>
</Grid>
{currentEndDateTag}
{lastUpdatedTimeTag}
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
Process model revision:{' '}
</Column>
<Column sm={3} md={3} lg={3} className="grid-date">
{processInstance.bpmn_version_control_identifier} (
{processInstance.bpmn_version_control_type})
</Column>
</Grid>
<Grid condensed fullWidth>
<Column sm={1} md={1} lg={2} className="grid-list-title">
Status:{' '}
@ -450,7 +400,6 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
</Tag>
</Column>
</Grid>
{detailedViewElement()}
<br />
<Grid condensed fullWidth>
<Column sm={2} md={2} lg={2}>
@ -493,7 +442,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
setShowProcessInstanceMetadata(true);
}}
>
Metadata
Details
</Button>
) : null}
</ButtonSet>
@ -1012,7 +961,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
return (
<Modal
open={showProcessInstanceMetadata}
modalHeading="Metadata"
modalHeading="Details"
passiveModal
onRequestClose={() => setShowProcessInstanceMetadata(false)}
>

View File

@ -19,6 +19,7 @@ import HttpService from '../services/HttpService';
import useAPIError from '../hooks/UseApiError';
import { modifyProcessIdentifierForPathParam } from '../helpers';
import { ProcessInstanceTask } from '../interfaces';
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
export default function TaskShow() {
const [task, setTask] = useState<ProcessInstanceTask | null>(null);
@ -85,7 +86,6 @@ export default function TaskShow() {
successCallback: processSubmitResult,
failureCallback: (error: any) => {
addError(error);
setDisabled(false);
},
httpMethod: 'PUT',
postBody: dataToSubmit,
@ -270,7 +270,7 @@ export default function TaskShow() {
return (
<div className="markdown">
{/*
https://www.npmjs.com/package/@uiw/react-md-editor switches to dark mode by default by respecting @media (prefers-color-scheme: dark)
https://www.npmjs.com/package/@uiw/react-md-editor switches to dark mode by default by respecting @media (prefers-color-scheme: dark)
This makes it look like our site is broken, so until the rest of the site supports dark mode, turn off dark mode for this component.
*/}
<div data-color-mode="light">
@ -288,6 +288,17 @@ export default function TaskShow() {
return (
<main>
<ProcessBreadcrumb
hotCrumbs={[
[
`Process Instance Id: ${params.process_instance_id}`,
`/admin/process-instances/for-me/${modifyProcessIdentifierForPathParam(
task.process_model_identifier
)}/${params.process_instance_id}`,
],
[`Task: ${task.title || task.id}`],
]}
/>
<div>{buildTaskNavigation()}</div>
<h3>
Task: {task.title} ({task.process_model_display_name}){statusString}