diff --git a/spiffworkflow-frontend/cypress/e2e/process_instances.cy.js b/spiffworkflow-frontend/cypress/e2e/process_instances.cy.js index aa0c6626..db6f53d3 100644 --- a/spiffworkflow-frontend/cypress/e2e/process_instances.cy.js +++ b/spiffworkflow-frontend/cypress/e2e/process_instances.cy.js @@ -1,5 +1,6 @@ import { format } from 'date-fns'; import { DATE_FORMAT, PROCESS_STATUSES } from '../../src/config'; +import { titleizeString } from '../../src/helpers'; const filterByDate = (fromDate) => { cy.get('#date-picker-start-from').clear().type(format(fromDate, DATE_FORMAT)); @@ -172,14 +173,19 @@ describe('process-instances', () => { cy.contains('All Process Instances'); cy.assertAtLeastOneItemInPaginatedResults(); + cy.getBySel('filter-section-expand-toggle').click(); + const statusSelect = '#process-instance-status-select'; PROCESS_STATUSES.forEach((processStatus) => { if (!['all', 'waiting'].includes(processStatus)) { cy.get(statusSelect).click(); - cy.get(statusSelect).contains(processStatus).click(); + cy.get(statusSelect).contains(titleizeString(processStatus)).click(); cy.get(statusSelect).click(); cy.getBySel('filter-button').click(); - cy.url().should('include', `status=${processStatus}`); + + // make sure that there is 1 status item selected in the multiselect + cy.get(`${statusSelect} .cds--tag`).contains('1'); + cy.assertAtLeastOneItemInPaginatedResults(); cy.getBySel(`process-instance-status-${processStatus}`); diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx index b196c2ee..9f912628 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListSaveAsReport.tsx @@ -14,7 +14,7 @@ type OwnProps = { buttonText?: string; buttonClassName?: string; processInstanceReportSelection?: ProcessInstanceReport | null; - reportMetadata: ReportMetadata; + getReportMetadataCallback: Function; }; export default function ProcessInstanceListSaveAsReport({ @@ -22,7 +22,7 @@ export default function ProcessInstanceListSaveAsReport({ processInstanceReportSelection, buttonClassName, buttonText = 'Save as Perspective', - reportMetadata, + getReportMetadataCallback, }: OwnProps) { const [identifier, setIdentifier] = useState( processInstanceReportSelection?.identifier || '' @@ -50,6 +50,11 @@ export default function ProcessInstanceListSaveAsReport({ const addProcessInstanceReport = (event: any) => { event.preventDefault(); + const reportMetadata = getReportMetadataCallback(); + if (!reportMetadata) { + return; + } + let path = `/process-instances/reports`; let httpMethod = 'POST'; if (isEditMode() && processInstanceReportSelection) { diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index b3b496d5..1bb76de9 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -31,7 +31,6 @@ import { DATE_FORMAT_FOR_DISPLAY, } from '../config'; import { - capitalizeFirstLetter, convertDateAndTimeStringsToSeconds, convertDateObjectToFormattedHoursMinutes, convertSecondsToFormattedDateString, @@ -42,6 +41,7 @@ import { refreshAtInterval, REFRESH_INTERVAL_SECONDS, REFRESH_TIMEOUT_SECONDS, + titleizeString, } from '../helpers'; import { useUriListForPermissions } from '../hooks/UriListForPermissions'; @@ -337,10 +337,8 @@ export default function ProcessInstanceListTable({ setProcessStatusSelection( (reportFilter.field_value || '').split(',') ); - setShowFilterOptions(true); } else if (reportFilter.field_name === 'process_initiator_username') { setProcessInitiatorSelection(reportFilter.field_value || ''); - setShowFilterOptions(true); } else if (reportFilter.field_name === 'process_model_identifier') { selectedProcessModelIdentifier = reportFilter.field_value || undefined; @@ -358,7 +356,6 @@ export default function ProcessInstanceListTable({ reportFilter.field_value as any ); timeFunctionToCall(timeString); - setShowFilterOptions(true); } } } @@ -368,11 +365,14 @@ export default function ProcessInstanceListTable({ (processModel: ProcessModel) => { if (processModel.id === selectedProcessModelIdentifier) { setProcessModelSelection(processModel); - setShowFilterOptions(true); } } ); + if (reportMetadataBodyToUse.filter_by.length > 1) { + setShowFilterOptions(true); + } + // eslint-disable-next-line prefer-const let { page, perPage } = getPageInfoFromSearchParams( searchParams, @@ -774,7 +774,7 @@ export default function ProcessInstanceListTable({ }; const formatProcessInstanceStatus = (_row: any, value: any) => { - return capitalizeFirstLetter((value || '').replaceAll('_', ' ')); + return titleizeString((value || '').replaceAll('_', ' ')); }; const processStatusSearch = () => { return ( @@ -845,18 +845,13 @@ export default function ProcessInstanceListTable({ }; const saveAsReportComponent = () => { - const newReportMetadata = getNewReportMetadataBasedOnPageWidgets(); - - if (!newReportMetadata) { - return null; - } return ( ); }; diff --git a/spiffworkflow-frontend/src/helpers.tsx b/spiffworkflow-frontend/src/helpers.tsx index 441d3c0f..08aff8cf 100644 --- a/spiffworkflow-frontend/src/helpers.tsx +++ b/spiffworkflow-frontend/src/helpers.tsx @@ -41,6 +41,10 @@ export const capitalizeFirstLetter = (string: any) => { return string.charAt(0).toUpperCase() + string.slice(1); }; +export const titleizeString = (string: any) => { + return capitalizeFirstLetter((string || '').replaceAll('_', ' ')); +}; + export const convertDateToSeconds = ( date: any, onChangeFunction: any = null