From fcd5b431e2368a9aafba4c0ea3dfc265cb0fce4a Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 10 Nov 2022 08:42:40 -0500 Subject: [PATCH] support process-groups in breadcrumb component --- .../src/components/ProcessBreadcrumb.tsx | 11 ++++++++--- .../src/routes/ProcessGroupEdit.tsx | 10 +++++++++- .../src/routes/ProcessModelEdit.tsx | 12 +++++++++++- .../src/routes/ProcessModelNew.tsx | 10 +++++++++- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessBreadcrumb.tsx b/spiffworkflow-frontend/src/components/ProcessBreadcrumb.tsx index 3b2a9af98..fcd8b50d5 100644 --- a/spiffworkflow-frontend/src/components/ProcessBreadcrumb.tsx +++ b/spiffworkflow-frontend/src/components/ProcessBreadcrumb.tsx @@ -13,7 +13,7 @@ type OwnProps = { const explodeCrumb = (crumb: HotCrumbItem) => { const url: string = crumb[1] || ''; // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [_unused, processModelId, link] = url.split(':'); + const [endingUrlType, processModelId, link] = url.split(':'); const processModelIdSegments = splitProcessModelId(processModelId); const paths: string[] = []; const lastPathItem = processModelIdSegments.pop(); @@ -29,7 +29,12 @@ const explodeCrumb = (crumb: HotCrumbItem) => { } ); if (link === 'link') { - const lastUrl = `/admin/process-models/${paths.join(':')}:${lastPathItem}`; + if (lastPathItem !== undefined) { + paths.push(lastPathItem); + } + const lastUrl = `/admin/${endingUrlType.replace('_', '-')}s/${paths.join( + ':' + )}`; breadcrumbItems.push( {lastPathItem} @@ -64,7 +69,7 @@ export default function ProcessBreadcrumb({ ); } - if (url && url.startsWith('process_model:')) { + if (url && url.match(/^process_(model|group):/)) { return explodeCrumb(crumb); } return ( diff --git a/spiffworkflow-frontend/src/routes/ProcessGroupEdit.tsx b/spiffworkflow-frontend/src/routes/ProcessGroupEdit.tsx index d624309cd..21bba49d5 100644 --- a/spiffworkflow-frontend/src/routes/ProcessGroupEdit.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessGroupEdit.tsx @@ -24,7 +24,15 @@ export default function ProcessGroupEdit() { if (processGroup) { return ( <> - +

Edit Process Group: {(processGroup as any).id}

(null); const processModelPath = `process-models/${params.process_model_id}`; useEffect(() => { @@ -20,6 +21,15 @@ export default function ProcessModelEdit() { if (processModel) { return ( <> +

Edit Process Model: {(processModel as any).id}

- +

Add Process Model