diff --git a/connector-proxy-demo/app.py b/connector-proxy-demo/app.py index 8b2cff711..ed398b507 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/config/permissions/example.yml b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example.yml index 261625101..a11578bda 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example.yml @@ -52,6 +52,13 @@ permissions: allowed_permissions: [create, read, update, delete] uri: /tasks/* + # Everybody can start all intstances + create-test-instances: + groups: [ everybody ] + users: [ ] + allowed_permissions: [ create ] + uri: /process-instances/* + # Everyone can see everything (all groups, and processes are visible) read-all-process-groups: groups: [ everybody ] 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 32d35ba35..f6c9ff66b 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 8c8f818f5..4b0498b7e 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,10 @@ export default function ProcessInstanceListTable({ useState([]); const [processInitiatorSelection, setProcessInitiatorSelection] = useState(null); + const [processInitiatorText, setProcessInitiatorText] = useState< + string | null + >(null); + const lastRequestedInitatorSearchTerm = useRef(); const dateParametersToAlwaysFilterBy: dateParameters = useMemo(() => { @@ -202,7 +217,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,6 +605,8 @@ 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())); @@ -1077,24 +1094,47 @@ 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} + /> + ); } - return null; + return ( + + setProcessInitiatorText(event.target.value) + } + /> + ); }} - placeholder="Starting typing username" - titleText="Process Initiator" - selectedItem={processInitiatorSelection} - /> + {processStatusSearch()} @@ -1248,7 +1288,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 92fe3639a..d8c855340 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]);