From 5e3c292f857051d3e88a70589a75d4197d1aa5ed Mon Sep 17 00:00:00 2001 From: Elizabeth Esswein Date: Mon, 24 Apr 2023 12:07:54 -0400 Subject: [PATCH] add modal to display references --- .../src/components/ReactDiagramEditor.tsx | 54 +++++++++++++++++-- .../src/routes/ProcessModelEditDiagram.tsx | 5 +- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx b/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx index 208cbd29..f42e9294 100644 --- a/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx +++ b/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx @@ -19,7 +19,7 @@ import { import React, { useRef, useEffect, useState } from 'react'; // @ts-ignore -import { Button } from '@carbon/react'; +import { Button, Modal, UnorderedList, Link } from '@carbon/react'; import 'bpmn-js/dist/assets/diagram-js.css'; import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'; @@ -58,7 +58,11 @@ import { Can } from '@casl/react'; import HttpService from '../services/HttpService'; import ButtonWithConfirmation from './ButtonWithConfirmation'; -import { getBpmnProcessIdentifiers, makeid } from '../helpers'; +import { + getBpmnProcessIdentifiers, + makeid, + modifyProcessIdentifierForPathParam, +} from '../helpers'; import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { PermissionsToCheck, Task } from '../interfaces'; import { usePermissionFetcher } from '../hooks/PermissionService'; @@ -127,7 +131,7 @@ export default function ReactDiagramEditor({ const { ability } = usePermissionFetcher(permissionRequestData); const navigate = useNavigate(); - console.log(callers); + const [showingReferences, setShowingReferences] = useState(false); useEffect(() => { if (diagramModelerState) { @@ -570,6 +574,42 @@ export default function ReactDiagramEditor({ const canViewXml = fileName !== undefined; + const showReferences = () => { + return ( + setShowingReferences(false)} + passiveModal + > + + {callers.map((ref: any) => ( +
  • + + {`${ref.display_name}`} + +
  • + ))} +
    +
    + ); + }; + + const getReferencesButton = () => { + if (callers.length > 0) { + let buttonText = `View ${callers.length} Reference`; + if (callers.length > 1) buttonText += 's'; + return ( + + ); + } + return null; + }; + const userActionOptions = () => { if (diagramType !== 'readonly') { return ( @@ -631,5 +671,11 @@ export default function ReactDiagramEditor({ return null; }; - return
    {userActionOptions()}
    ; + return ( +
    + {userActionOptions()} + {getReferencesButton()} + {showReferences()} +
    + ); } diff --git a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx index 07f4d16f..1e200ec4 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx @@ -165,13 +165,10 @@ export default function ProcessModelEditDiagram() { }, [processModelPath, params]); useEffect(() => { - const getCallerIds = (result: any) => { - setCallers(result.map((r: any) => r.process_model_id)); - } if (processModel !== null) { HttpService.makeCallToBackend({ path: `/processes/${processModel.primary_process_id}/callers`, - successCallback: getCallerIds, + successCallback: setCallers, }); } }, [processModel]);