added recursive option to process model list to recurse or not and fix some ui components

This commit is contained in:
jasquat 2022-11-22 09:05:33 -05:00
parent ecfb665dad
commit 50c137101b
12 changed files with 44 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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")
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()

View File

@ -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

View File

@ -51,7 +51,7 @@ export default function ProcessGroupListTiles({
displayText = (processGroups || []).map((row: ProcessGroup) => {
return (
<ClickableTile
id="tile-1"
id={`process-group-tile-${row.id}`}
className="tile-process-group"
href={`/admin/process-groups/${modifyProcessModelPath(row.id)}`}
>
@ -61,7 +61,7 @@ export default function ProcessGroupListTiles({
{row.display_name}
</div>
<p className="tile-description">
{truncateString(row.description || '', 25)}
{truncateString(row.description || '', 100)}
</p>
<p className="tile-process-group-children-count tile-pin-bottom">
Total Sub Items: {processGroupDirectChildrenCount(row)}

View File

@ -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 {

View File

@ -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<ProcessModel[] | null>(
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 (
<Tile
id="tile-1"
id={`process-model-tile-${row.id}`}
className="tile-process-group"
href={`/admin/process-models/${modifyProcessModelPath(row.id)}`}
>
<div className="tile-process-group-content-container">
<div className="tile-title-top">{row.display_name}</div>
<p className="tile-description">
{truncateString(row.description || '', 25)}
{truncateString(row.description || '', 100)}
</p>
<ProcessInstanceRun
processModel={row}

View File

@ -35,7 +35,7 @@ export default function ProcessModelSearch({
if (processModel) {
return `${processModel.id} (${truncateString(
processModel.display_name,
20
75
)})`;
}
return null;

View File

@ -41,7 +41,7 @@ export default function ProcessSearch({
if (process) {
return `${process.display_name} (${truncateString(
process.identifier,
20
75
)})`;
}
return null;

View File

@ -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]);

View File

@ -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() {
</Stack>
<br />
<br />
{/* <ProcessModelListTiles
headerElement={<h2>Process Models</h2>}
processGroup={processGroup}
/> */}
{/* eslint-disable-next-line sonarjs/no-gratuitous-expressions */}
{modelPagination && modelPagination.total > 0 && (
<PaginationForTable