diff --git a/connector-proxy-demo/app.py b/connector-proxy-demo/app.py index 8b2cff71..ed398b50 100644 --- a/connector-proxy-demo/app.py +++ b/connector-proxy-demo/app.py @@ -15,4 +15,4 @@ if app.config["ENV"] != "production": app.register_blueprint(proxy_blueprint) if __name__ == "__main__": - app.run(host="localhost", port=5000) \ No newline at end of file + app.run(host="localhost", port=7004) \ No newline at end of file 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 32d35ba3..f6c9ff66 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -272,6 +272,7 @@ def process_instance_list_for_me( with_relation_to_me=True, report_columns=report_columns, report_filter_by=report_filter_by, + process_initiator_username=process_initiator_username, ) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 8c8f818f..794c6d24 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -37,6 +37,7 @@ import { modifyProcessIdentifierForPathParam, refreshAtInterval, } from '../helpers'; +import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import PaginationForTable from './PaginationForTable'; import 'react-datepicker/dist/react-datepicker.css'; @@ -56,6 +57,7 @@ import { ReportFilter, User, ErrorForDisplay, + PermissionsToCheck, } from '../interfaces'; import ProcessModelSearch from './ProcessModelSearch'; import ProcessInstanceReportSearch from './ProcessInstanceReportSearch'; @@ -63,6 +65,8 @@ import ProcessInstanceListDeleteReport from './ProcessInstanceListDeleteReport'; import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport'; import { Notification } from './Notification'; import useAPIError from '../hooks/UseApiError'; +import { usePermissionFetcher } from '../hooks/PermissionService'; +import { Can } from '../contexts/Can'; const REFRESH_INTERVAL = 5; const REFRESH_TIMEOUT = 600; @@ -107,6 +111,13 @@ export default function ProcessInstanceListTable({ const navigate = useNavigate(); const { addError, removeError } = useAPIError(); + const { targetUris } = useUriListForPermissions(); + const permissionRequestData: PermissionsToCheck = { + [targetUris.userSearch]: ['GET'], + }; + const { ability } = usePermissionFetcher(permissionRequestData); + const canSearchUsers: boolean = ability.can('GET', targetUris.userSearch); + const [processInstances, setProcessInstances] = useState([]); const [reportMetadata, setReportMetadata] = useState(); const [pagination, setPagination] = useState(null); @@ -167,6 +178,9 @@ export default function ProcessInstanceListTable({ useState([]); const [processInitiatorSelection, setProcessInitiatorSelection] = useState(null); + const [processInitiatorText, setProcessInitiatorText] = + useState(null); + const lastRequestedInitatorSearchTerm = useRef(); const dateParametersToAlwaysFilterBy: dateParameters = useMemo(() => { @@ -202,7 +216,7 @@ export default function ProcessInstanceListTable({ }; const searchForProcessInitiator = (inputText: string) => { - if (inputText) { + if (inputText && canSearchUsers) { lastRequestedInitatorSearchTerm.current = inputText; HttpService.makeCallToBackend({ path: `/users/search?username_prefix=${inputText}`, @@ -590,8 +604,11 @@ export default function ProcessInstanceListTable({ if (processInitiatorSelection) { queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`; + } else if (processInitiatorText) { + queryParamString += `&process_initiator_username=${processInitiatorText}`; } + const reportColumnsBase64 = encodeBase64(JSON.stringify(reportColumns())); queryParamString += `&report_columns=${reportColumnsBase64}`; const reportFilterByBase64 = encodeBase64(JSON.stringify(reportFilterBy())); @@ -1077,24 +1094,48 @@ export default function ProcessInstanceListTable({ /> - { - setProcessInitiatorSelection(event.selectedItem); - }} - id="process-instance-initiator-search" - data-qa="process-instance-initiator-search" - items={processInstanceInitiatorOptions} - itemToString={(processInstanceInitatorOption: User) => { - if (processInstanceInitatorOption) { - return processInstanceInitatorOption.username; + + {(hasAccess: boolean) => { + if (hasAccess) { + return ( + { + setProcessInitiatorSelection(event.selectedItem); + }} + id="process-instance-initiator-search" + data-qa="process-instance-initiator-search" + items={processInstanceInitiatorOptions} + itemToString={(processInstanceInitatorOption: User) => { + if (processInstanceInitatorOption) { + return processInstanceInitatorOption.username; + } + return null; + }} + placeholder="Start typing username" + titleText="Process Initiator" + selectedItem={processInitiatorSelection} + /> + ); + } else { + return ( + + setProcessInitiatorText(event.target.value) + } + /> + ); } - return null; }} - placeholder="Starting typing username" - titleText="Process Initiator" - selectedItem={processInitiatorSelection} - /> + {processStatusSearch()} @@ -1248,7 +1289,6 @@ export default function ProcessInstanceListTable({ ); } - console.log(column.accessor); if (column.accessor === 'process_model_display_name') { const pmStyle = { background: 'rgba(0, 0, 0, .02)' }; return ( diff --git a/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx b/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx index 92fe3639..d8c85534 100644 --- a/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx +++ b/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx @@ -29,6 +29,7 @@ export const useUriListForPermissions = () => { processModelPublishPath: `/v1.0/process-models/${params.process_model_id}/publish`, processModelShowPath: `/v1.0/process-models/${params.process_model_id}`, secretListPath: `/v1.0/secrets`, + userSearch: `/v1.0/users/search`, }; }, [params]);