Merge pull request #226 from sartography/feature/call-activity-references
Feature/call activity references
This commit is contained in:
commit
f45c76ad41
|
@ -19,7 +19,7 @@ import {
|
||||||
|
|
||||||
import React, { useRef, useEffect, useState } from 'react';
|
import React, { useRef, useEffect, useState } from 'react';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Button } from '@carbon/react';
|
import { Button, ButtonSet, Modal, UnorderedList, Link } from '@carbon/react';
|
||||||
|
|
||||||
import 'bpmn-js/dist/assets/diagram-js.css';
|
import 'bpmn-js/dist/assets/diagram-js.css';
|
||||||
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.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 HttpService from '../services/HttpService';
|
||||||
|
|
||||||
import ButtonWithConfirmation from './ButtonWithConfirmation';
|
import ButtonWithConfirmation from './ButtonWithConfirmation';
|
||||||
import { getBpmnProcessIdentifiers, makeid } from '../helpers';
|
import {
|
||||||
|
getBpmnProcessIdentifiers,
|
||||||
|
makeid,
|
||||||
|
modifyProcessIdentifierForPathParam,
|
||||||
|
} from '../helpers';
|
||||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||||
import { PermissionsToCheck, Task } from '../interfaces';
|
import { PermissionsToCheck, Task } from '../interfaces';
|
||||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||||
|
@ -85,6 +89,7 @@ type OwnProps = {
|
||||||
onSearchProcessModels?: (..._args: any[]) => any;
|
onSearchProcessModels?: (..._args: any[]) => any;
|
||||||
onElementsChanged?: (..._args: any[]) => any;
|
onElementsChanged?: (..._args: any[]) => any;
|
||||||
url?: string;
|
url?: string;
|
||||||
|
callers?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://codesandbox.io/s/quizzical-lake-szfyo?file=/src/App.js was a handy reference
|
// https://codesandbox.io/s/quizzical-lake-szfyo?file=/src/App.js was a handy reference
|
||||||
|
@ -110,6 +115,7 @@ export default function ReactDiagramEditor({
|
||||||
onSearchProcessModels,
|
onSearchProcessModels,
|
||||||
onElementsChanged,
|
onElementsChanged,
|
||||||
url,
|
url,
|
||||||
|
callers,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
const [diagramXMLString, setDiagramXMLString] = useState('');
|
const [diagramXMLString, setDiagramXMLString] = useState('');
|
||||||
const [diagramModelerState, setDiagramModelerState] = useState(null);
|
const [diagramModelerState, setDiagramModelerState] = useState(null);
|
||||||
|
@ -125,6 +131,8 @@ export default function ReactDiagramEditor({
|
||||||
const { ability } = usePermissionFetcher(permissionRequestData);
|
const { ability } = usePermissionFetcher(permissionRequestData);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const [showingReferences, setShowingReferences] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (diagramModelerState) {
|
if (diagramModelerState) {
|
||||||
return;
|
return;
|
||||||
|
@ -566,10 +574,48 @@ export default function ReactDiagramEditor({
|
||||||
|
|
||||||
const canViewXml = fileName !== undefined;
|
const canViewXml = fileName !== undefined;
|
||||||
|
|
||||||
|
const showReferences = () => {
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
open={showingReferences}
|
||||||
|
modalHeading="Process Model References"
|
||||||
|
onRequestClose={() => setShowingReferences(false)}
|
||||||
|
passiveModal
|
||||||
|
>
|
||||||
|
<UnorderedList>
|
||||||
|
{callers.map((ref: any) => (
|
||||||
|
<li>
|
||||||
|
<Link
|
||||||
|
size="lg"
|
||||||
|
href={`/admin/process-models/${modifyProcessIdentifierForPathParam(
|
||||||
|
ref.process_model_id
|
||||||
|
)}`}
|
||||||
|
>
|
||||||
|
{`${ref.display_name}`}
|
||||||
|
</Link>{' '}
|
||||||
|
({ref.process_model_id})
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</UnorderedList>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getReferencesButton = () => {
|
||||||
|
if (callers.length > 0) {
|
||||||
|
let buttonText = `View ${callers.length} Reference`;
|
||||||
|
if (callers.length > 1) buttonText += 's';
|
||||||
|
return (
|
||||||
|
<Button onClick={() => setShowingReferences(true)}>{buttonText}</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
const userActionOptions = () => {
|
const userActionOptions = () => {
|
||||||
if (diagramType !== 'readonly') {
|
if (diagramType !== 'readonly') {
|
||||||
return (
|
return (
|
||||||
<>
|
<ButtonSet>
|
||||||
<Can
|
<Can
|
||||||
I="PUT"
|
I="PUT"
|
||||||
a={targetUris.processModelFileShowPath}
|
a={targetUris.processModelFileShowPath}
|
||||||
|
@ -621,11 +667,17 @@ export default function ReactDiagramEditor({
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Can>
|
</Can>
|
||||||
</>
|
{getReferencesButton()}
|
||||||
|
</ButtonSet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return <div>{userActionOptions()}</div>;
|
return (
|
||||||
|
<div>
|
||||||
|
{userActionOptions()}
|
||||||
|
{showReferences()}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,7 @@ export interface ProcessModel {
|
||||||
description: string;
|
description: string;
|
||||||
display_name: string;
|
display_name: string;
|
||||||
primary_file_name: string;
|
primary_file_name: string;
|
||||||
|
primary_process_id: string;
|
||||||
files: ProcessFile[];
|
files: ProcessFile[];
|
||||||
parent_groups?: ProcessGroupLite[];
|
parent_groups?: ProcessGroupLite[];
|
||||||
metadata_extraction_paths?: MetadataExtractionPath[];
|
metadata_extraction_paths?: MetadataExtractionPath[];
|
||||||
|
|
|
@ -147,6 +147,7 @@ export default function MyTasks() {
|
||||||
description: '',
|
description: '',
|
||||||
display_name: '',
|
display_name: '',
|
||||||
primary_file_name: '',
|
primary_file_name: '',
|
||||||
|
primary_process_id: '',
|
||||||
files: [],
|
files: [],
|
||||||
};
|
};
|
||||||
const modifiedProcessModelId = modifyProcessIdentifierForPathParam(
|
const modifiedProcessModelId = modifyProcessIdentifierForPathParam(
|
||||||
|
|
|
@ -119,6 +119,8 @@ export default function ProcessModelEditDiagram() {
|
||||||
|
|
||||||
const processModelPath = `process-models/${modifiedProcessModelId}`;
|
const processModelPath = `process-models/${modifiedProcessModelId}`;
|
||||||
|
|
||||||
|
const [callers, setCallers] = useState<Array<string>>([]);
|
||||||
|
|
||||||
usePrompt('Changes you made may not be saved.', diagramHasChanges);
|
usePrompt('Changes you made may not be saved.', diagramHasChanges);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -162,6 +164,15 @@ export default function ProcessModelEditDiagram() {
|
||||||
}
|
}
|
||||||
}, [processModelPath, params]);
|
}, [processModelPath, params]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (processModel !== null) {
|
||||||
|
HttpService.makeCallToBackend({
|
||||||
|
path: `/processes/${processModel.primary_process_id}/callers`,
|
||||||
|
successCallback: setCallers,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [processModel]);
|
||||||
|
|
||||||
const handleFileNameCancel = () => {
|
const handleFileNameCancel = () => {
|
||||||
setShowFileNameEditor(false);
|
setShowFileNameEditor(false);
|
||||||
setNewFileName('');
|
setNewFileName('');
|
||||||
|
@ -958,6 +969,7 @@ export default function ProcessModelEditDiagram() {
|
||||||
onDmnFilesRequested={onDmnFilesRequested}
|
onDmnFilesRequested={onDmnFilesRequested}
|
||||||
onSearchProcessModels={onSearchProcessModels}
|
onSearchProcessModels={onSearchProcessModels}
|
||||||
onElementsChanged={onElementsChanged}
|
onElementsChanged={onElementsChanged}
|
||||||
|
callers={callers}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ export default function ProcessModelNew() {
|
||||||
display_name: '',
|
display_name: '',
|
||||||
description: '',
|
description: '',
|
||||||
primary_file_name: '',
|
primary_file_name: '',
|
||||||
|
primary_process_id: '',
|
||||||
files: [],
|
files: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue