diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index 4f935571..1a683ec5 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -273,6 +273,12 @@ paths: description: The group containing the models we want to return schema: type: string + - name: recursive + in: query + required: false + description: Get all sub process models recursively if true + schema: + type: string - name: page in: query required: false diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index bc9fd79f..8f87ab5c 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -347,11 +347,14 @@ def process_model_move( def process_model_list( - process_group_identifier: Optional[str] = None, page: int = 1, per_page: int = 100 + process_group_identifier: Optional[str] = None, + recursive: Optional[bool] = False, + page: int = 1, + per_page: int = 100, ) -> flask.wrappers.Response: """Process model list!""" process_models = ProcessModelService().get_process_models( - process_group_id=process_group_identifier + process_group_id=process_group_identifier, recursive=recursive ) batch = ProcessModelService().get_batch( process_models, page=page, per_page=per_page diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py index 65de4272..f9788658 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py @@ -179,7 +179,7 @@ class ProcessModelService(FileSystemService): raise ProcessEntityNotFoundError("process_model_not_found") def get_process_models( - self, process_group_id: Optional[str] = None + self, process_group_id: Optional[str] = None, recursive: Optional[bool] = False ) -> List[ProcessModelInfo]: """Get process models.""" process_models = [] @@ -187,7 +187,11 @@ class ProcessModelService(FileSystemService): if process_group_id: awesome_id = process_group_id.replace("/", os.sep) root_path = os.path.join(root_path, awesome_id) - process_model_glob = os.path.join(root_path, "**", "process_model.json") + + process_model_glob = os.path.join(root_path, "*", "process_model.json") + if recursive: + process_model_glob = os.path.join(root_path, "**", "process_model.json") + for file in glob(process_model_glob, recursive=True): process_model_relative_path = os.path.relpath( file, start=FileSystemService.root_path() diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 6f850a89..ef65dfbe 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -381,7 +381,7 @@ class TestProcessApi(BaseTest): # get all models response = client.get( - "/v1.0/process-models?per_page=1000", + "/v1.0/process-models?per_page=1000&recursive=true", headers=self.logged_in_headers(with_super_admin_user), ) assert response.json is not None diff --git a/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx b/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx index 4c964bec..20918017 100644 --- a/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx +++ b/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx @@ -51,7 +51,7 @@ export default function ProcessGroupListTiles({ displayText = (processGroups || []).map((row: ProcessGroup) => { return ( @@ -61,7 +61,7 @@ export default function ProcessGroupListTiles({ {row.display_name}

- {truncateString(row.description || '', 25)} + {truncateString(row.description || '', 100)}

Total Sub Items: {processGroupDirectChildrenCount(row)} diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index 6d5fbb0b..9a0509a9 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -234,7 +234,7 @@ export default function ProcessInstanceListTable({ if (filtersEnabled) { // populate process model selection HttpService.makeCallToBackend({ - path: `/process-models?per_page=1000`, + path: `/process-models?per_page=1000&recursive=true`, successCallback: processResultForProcessModels, }); } else { diff --git a/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx b/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx index a10fd754..b526f755 100644 --- a/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx +++ b/spiffworkflow-frontend/src/components/ProcessModelListTiles.tsx @@ -5,15 +5,19 @@ import { // @ts-ignore } from '@carbon/react'; import HttpService from '../services/HttpService'; -import { ProcessModel, ProcessInstance } from '../interfaces'; +import { ProcessModel, ProcessInstance, ProcessGroup } from '../interfaces'; import { modifyProcessModelPath, truncateString } from '../helpers'; import ProcessInstanceRun from './ProcessInstanceRun'; type OwnProps = { headerElement?: ReactElement; + processGroup?: ProcessGroup; }; -export default function ProcessModelListTiles({ headerElement }: OwnProps) { +export default function ProcessModelListTiles({ + headerElement, + processGroup, +}: OwnProps) { const [searchParams] = useSearchParams(); const [processModels, setProcessModels] = useState( null @@ -25,13 +29,16 @@ export default function ProcessModelListTiles({ headerElement }: OwnProps) { const setProcessModelsFromResult = (result: any) => { setProcessModels(result.results); }; - // only allow 10 for now until we get the backend only returnin certain models for user execution - const queryParams = '?per_page=10'; + // only allow 10 for now until we get the backend only returning certain models for user execution + let queryParams = '?per_page=100'; + if (processGroup) { + queryParams = `${queryParams}&process_group_identifier=${processGroup.id}`; + } HttpService.makeCallToBackend({ path: `/process-models${queryParams}`, successCallback: setProcessModelsFromResult, }); - }, [searchParams]); + }, [searchParams, processGroup]); const processInstanceRunResultTag = () => { if (processInstance) { @@ -61,14 +68,14 @@ export default function ProcessModelListTiles({ headerElement }: OwnProps) { displayText = (processModels || []).map((row: ProcessModel) => { return (

{row.display_name}

- {truncateString(row.description || '', 25)} + {truncateString(row.description || '', 100)}

{ if (text.length > len && text.length > 0) { - return `${text.split(' ').slice(0, len).join(' ')} ...`; + return `${text.split('').slice(0, len).join('')} ...`; } return text; }; diff --git a/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx b/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx index 4c448f08..50fd3eec 100644 --- a/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx @@ -39,7 +39,7 @@ export default function ProcessGroupList() { }; // for search box HttpService.makeCallToBackend({ - path: `/process-models?per_page=1000`, + path: `/process-models?per_page=1000&recursive=true`, successCallback: processResultForProcessModels, }); }, [searchParams]); diff --git a/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx b/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx index f8c856e1..02f63703 100644 --- a/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx @@ -20,6 +20,7 @@ import { import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { usePermissionFetcher } from '../hooks/PermissionService'; import ProcessGroupListTiles from '../components/ProcessGroupListTiles'; +// import ProcessModelListTiles from '../components/ProcessModelListTiles'; export default function ProcessGroupShow() { const params = useParams(); @@ -142,6 +143,10 @@ export default function ProcessGroupShow() {

+ {/* Process Models} + processGroup={processGroup} + /> */} {/* eslint-disable-next-line sonarjs/no-gratuitous-expressions */} {modelPagination && modelPagination.total > 0 && (