added recursive option to process model list to recurse or not and fix some ui components
This commit is contained in:
parent
f459743ab4
commit
b49a1cd30f
|
@ -273,6 +273,12 @@ paths:
|
||||||
description: The group containing the models we want to return
|
description: The group containing the models we want to return
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
- name: recursive
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
description: Get all sub process models recursively if true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
- name: page
|
- name: page
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -347,11 +347,14 @@ def process_model_move(
|
||||||
|
|
||||||
|
|
||||||
def process_model_list(
|
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:
|
) -> flask.wrappers.Response:
|
||||||
"""Process model list!"""
|
"""Process model list!"""
|
||||||
process_models = ProcessModelService().get_process_models(
|
process_models = ProcessModelService().get_process_models(
|
||||||
process_group_id=process_group_identifier
|
process_group_id=process_group_identifier, recursive=recursive
|
||||||
)
|
)
|
||||||
batch = ProcessModelService().get_batch(
|
batch = ProcessModelService().get_batch(
|
||||||
process_models, page=page, per_page=per_page
|
process_models, page=page, per_page=per_page
|
||||||
|
|
|
@ -179,7 +179,7 @@ class ProcessModelService(FileSystemService):
|
||||||
raise ProcessEntityNotFoundError("process_model_not_found")
|
raise ProcessEntityNotFoundError("process_model_not_found")
|
||||||
|
|
||||||
def get_process_models(
|
def get_process_models(
|
||||||
self, process_group_id: Optional[str] = None
|
self, process_group_id: Optional[str] = None, recursive: Optional[bool] = False
|
||||||
) -> List[ProcessModelInfo]:
|
) -> List[ProcessModelInfo]:
|
||||||
"""Get process models."""
|
"""Get process models."""
|
||||||
process_models = []
|
process_models = []
|
||||||
|
@ -187,7 +187,11 @@ class ProcessModelService(FileSystemService):
|
||||||
if process_group_id:
|
if process_group_id:
|
||||||
awesome_id = process_group_id.replace("/", os.sep)
|
awesome_id = process_group_id.replace("/", os.sep)
|
||||||
root_path = os.path.join(root_path, awesome_id)
|
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):
|
for file in glob(process_model_glob, recursive=True):
|
||||||
process_model_relative_path = os.path.relpath(
|
process_model_relative_path = os.path.relpath(
|
||||||
file, start=FileSystemService.root_path()
|
file, start=FileSystemService.root_path()
|
||||||
|
|
|
@ -381,7 +381,7 @@ class TestProcessApi(BaseTest):
|
||||||
|
|
||||||
# get all models
|
# get all models
|
||||||
response = client.get(
|
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),
|
headers=self.logged_in_headers(with_super_admin_user),
|
||||||
)
|
)
|
||||||
assert response.json is not None
|
assert response.json is not None
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default function ProcessGroupListTiles({
|
||||||
displayText = (processGroups || []).map((row: ProcessGroup) => {
|
displayText = (processGroups || []).map((row: ProcessGroup) => {
|
||||||
return (
|
return (
|
||||||
<ClickableTile
|
<ClickableTile
|
||||||
id="tile-1"
|
id={`process-group-tile-${row.id}`}
|
||||||
className="tile-process-group"
|
className="tile-process-group"
|
||||||
href={`/admin/process-groups/${modifyProcessModelPath(row.id)}`}
|
href={`/admin/process-groups/${modifyProcessModelPath(row.id)}`}
|
||||||
>
|
>
|
||||||
|
@ -61,7 +61,7 @@ export default function ProcessGroupListTiles({
|
||||||
{row.display_name}
|
{row.display_name}
|
||||||
</div>
|
</div>
|
||||||
<p className="tile-description">
|
<p className="tile-description">
|
||||||
{truncateString(row.description || '', 25)}
|
{truncateString(row.description || '', 100)}
|
||||||
</p>
|
</p>
|
||||||
<p className="tile-process-group-children-count tile-pin-bottom">
|
<p className="tile-process-group-children-count tile-pin-bottom">
|
||||||
Total Sub Items: {processGroupDirectChildrenCount(row)}
|
Total Sub Items: {processGroupDirectChildrenCount(row)}
|
||||||
|
|
|
@ -234,7 +234,7 @@ export default function ProcessInstanceListTable({
|
||||||
if (filtersEnabled) {
|
if (filtersEnabled) {
|
||||||
// populate process model selection
|
// populate process model selection
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/process-models?per_page=1000`,
|
path: `/process-models?per_page=1000&recursive=true`,
|
||||||
successCallback: processResultForProcessModels,
|
successCallback: processResultForProcessModels,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,15 +5,19 @@ import {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
} from '@carbon/react';
|
} from '@carbon/react';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import { ProcessModel, ProcessInstance } from '../interfaces';
|
import { ProcessModel, ProcessInstance, ProcessGroup } from '../interfaces';
|
||||||
import { modifyProcessModelPath, truncateString } from '../helpers';
|
import { modifyProcessModelPath, truncateString } from '../helpers';
|
||||||
import ProcessInstanceRun from './ProcessInstanceRun';
|
import ProcessInstanceRun from './ProcessInstanceRun';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
headerElement?: ReactElement;
|
headerElement?: ReactElement;
|
||||||
|
processGroup?: ProcessGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ProcessModelListTiles({ headerElement }: OwnProps) {
|
export default function ProcessModelListTiles({
|
||||||
|
headerElement,
|
||||||
|
processGroup,
|
||||||
|
}: OwnProps) {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [processModels, setProcessModels] = useState<ProcessModel[] | null>(
|
const [processModels, setProcessModels] = useState<ProcessModel[] | null>(
|
||||||
null
|
null
|
||||||
|
@ -25,13 +29,16 @@ export default function ProcessModelListTiles({ headerElement }: OwnProps) {
|
||||||
const setProcessModelsFromResult = (result: any) => {
|
const setProcessModelsFromResult = (result: any) => {
|
||||||
setProcessModels(result.results);
|
setProcessModels(result.results);
|
||||||
};
|
};
|
||||||
// only allow 10 for now until we get the backend only returnin certain models for user execution
|
// only allow 10 for now until we get the backend only returning certain models for user execution
|
||||||
const queryParams = '?per_page=10';
|
let queryParams = '?per_page=100';
|
||||||
|
if (processGroup) {
|
||||||
|
queryParams = `${queryParams}&process_group_identifier=${processGroup.id}`;
|
||||||
|
}
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/process-models${queryParams}`,
|
path: `/process-models${queryParams}`,
|
||||||
successCallback: setProcessModelsFromResult,
|
successCallback: setProcessModelsFromResult,
|
||||||
});
|
});
|
||||||
}, [searchParams]);
|
}, [searchParams, processGroup]);
|
||||||
|
|
||||||
const processInstanceRunResultTag = () => {
|
const processInstanceRunResultTag = () => {
|
||||||
if (processInstance) {
|
if (processInstance) {
|
||||||
|
@ -61,14 +68,14 @@ export default function ProcessModelListTiles({ headerElement }: OwnProps) {
|
||||||
displayText = (processModels || []).map((row: ProcessModel) => {
|
displayText = (processModels || []).map((row: ProcessModel) => {
|
||||||
return (
|
return (
|
||||||
<Tile
|
<Tile
|
||||||
id="tile-1"
|
id={`process-model-tile-${row.id}`}
|
||||||
className="tile-process-group"
|
className="tile-process-group"
|
||||||
href={`/admin/process-models/${modifyProcessModelPath(row.id)}`}
|
href={`/admin/process-models/${modifyProcessModelPath(row.id)}`}
|
||||||
>
|
>
|
||||||
<div className="tile-process-group-content-container">
|
<div className="tile-process-group-content-container">
|
||||||
<div className="tile-title-top">{row.display_name}</div>
|
<div className="tile-title-top">{row.display_name}</div>
|
||||||
<p className="tile-description">
|
<p className="tile-description">
|
||||||
{truncateString(row.description || '', 25)}
|
{truncateString(row.description || '', 100)}
|
||||||
</p>
|
</p>
|
||||||
<ProcessInstanceRun
|
<ProcessInstanceRun
|
||||||
processModel={row}
|
processModel={row}
|
||||||
|
|
|
@ -35,7 +35,7 @@ export default function ProcessModelSearch({
|
||||||
if (processModel) {
|
if (processModel) {
|
||||||
return `${processModel.id} (${truncateString(
|
return `${processModel.id} (${truncateString(
|
||||||
processModel.display_name,
|
processModel.display_name,
|
||||||
20
|
75
|
||||||
)})`;
|
)})`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -41,7 +41,7 @@ export default function ProcessSearch({
|
||||||
if (process) {
|
if (process) {
|
||||||
return `${process.display_name} (${truncateString(
|
return `${process.display_name} (${truncateString(
|
||||||
process.identifier,
|
process.identifier,
|
||||||
20
|
75
|
||||||
)})`;
|
)})`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -174,7 +174,7 @@ export const getProcessModelFullIdentifierFromSearchParams = (
|
||||||
// https://stackoverflow.com/a/71352046/6090676
|
// https://stackoverflow.com/a/71352046/6090676
|
||||||
export const truncateString = (text: string, len: number) => {
|
export const truncateString = (text: string, len: number) => {
|
||||||
if (text.length > len && text.length > 0) {
|
if (text.length > len && text.length > 0) {
|
||||||
return `${text.split(' ').slice(0, len).join(' ')} ...`;
|
return `${text.split('').slice(0, len).join('')} ...`;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default function ProcessGroupList() {
|
||||||
};
|
};
|
||||||
// for search box
|
// for search box
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/process-models?per_page=1000`,
|
path: `/process-models?per_page=1000&recursive=true`,
|
||||||
successCallback: processResultForProcessModels,
|
successCallback: processResultForProcessModels,
|
||||||
});
|
});
|
||||||
}, [searchParams]);
|
}, [searchParams]);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||||
import ProcessGroupListTiles from '../components/ProcessGroupListTiles';
|
import ProcessGroupListTiles from '../components/ProcessGroupListTiles';
|
||||||
|
// import ProcessModelListTiles from '../components/ProcessModelListTiles';
|
||||||
|
|
||||||
export default function ProcessGroupShow() {
|
export default function ProcessGroupShow() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
@ -142,6 +143,10 @@ export default function ProcessGroupShow() {
|
||||||
</Stack>
|
</Stack>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
{/* <ProcessModelListTiles
|
||||||
|
headerElement={<h2>Process Models</h2>}
|
||||||
|
processGroup={processGroup}
|
||||||
|
/> */}
|
||||||
{/* eslint-disable-next-line sonarjs/no-gratuitous-expressions */}
|
{/* eslint-disable-next-line sonarjs/no-gratuitous-expressions */}
|
||||||
{modelPagination && modelPagination.total > 0 && (
|
{modelPagination && modelPagination.total > 0 && (
|
||||||
<PaginationForTable
|
<PaginationForTable
|
||||||
|
|
Loading…
Reference in New Issue