diff --git a/spiffworkflow-frontend/src/components/MarkdownDisplayForFile.tsx b/spiffworkflow-frontend/src/components/MarkdownDisplayForFile.tsx new file mode 100644 index 00000000..15be7204 --- /dev/null +++ b/spiffworkflow-frontend/src/components/MarkdownDisplayForFile.tsx @@ -0,0 +1,34 @@ +import MDEditor from '@uiw/react-md-editor'; +import { useEffect, useState } from 'react'; +import HttpService from '../services/HttpService'; + +type OwnProps = { + apiPath: string; +}; + +export default function MarkdownDisplayForFile({ apiPath }: OwnProps) { + const [markdownContents, setMarkdownContents] = useState(null); + + useEffect(() => { + const processResult = (result: any) => { + if (result.file_contents) { + setMarkdownContents(result.file_contents); + } + }; + + HttpService.makeCallToBackend({ + path: apiPath, + successCallback: processResult, + }); + }, [apiPath]); + + if (markdownContents) { + return ( +
+ +
+ ); + } + + return null; +} diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index bb135797..f99197c7 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -1840,6 +1840,9 @@ export default function ProcessInstanceListTable({ ); } + if (!headerElement && !filterButtonLink) { + return null; + } return ( <> (null); const [processInstance, setProcessInstance] = @@ -62,7 +67,8 @@ export default function ProcessModelShow() { useState(false); const [processModelPublished, setProcessModelPublished] = useState(null); const [publishDisabled, setPublishDisabled] = useState(false); - const navigate = useNavigate(); + const [selectedTabIndex, setSelectedTabIndex] = useState(0); + const [readmeFile, setReadmeFile] = useState(null); const { targetUris } = useUriListForPermissions(); const permissionRequestData: PermissionsToCheck = { @@ -98,6 +104,15 @@ export default function ProcessModelShow() { setProcessModel(result); setReloadModel(false); setPageTitle([result.display_name]); + + let newTabIndex = 1; + result.files.forEach((file: ProcessFile) => { + if (file.name === 'README.md') { + setReadmeFile(file); + newTabIndex = 0; + } + }); + setSelectedTabIndex(newTabIndex); }; HttpService.makeCallToBackend({ path: `/process-models/${modifiedProcessModelId}`, @@ -562,44 +577,124 @@ export default function ProcessModelShow() { ); }; - const processModelFilesSection = () => { - return ( - - - - - - - - - } - > + const readmeFileArea = () => { + if (readmeFile) { + return ( +
+ + +

{readmeFile.name}

+
+ - {addFileComponent()} -
+
+ ); + } + return ( + <> +

No README file found

+ + + + + ); + }; + + const updateSelectedTab = (newTabIndex: any) => { + setSelectedTabIndex(newTabIndex.selectedIndex); + }; + + const tabArea = () => { + if (!processModel) { + return null; + } + + return ( + + + About + Files + My Process instances + + + {readmeFileArea()} + + + + +
+ Files + {processModel && + processModel.bpmn_version_control_identifier && + ` (revision ${processModel.bpmn_version_control_identifier})`} +
+ {addFileComponent()} +
+
+ {processModelFileList()} +
+
+
+ + {selectedTabIndex !== 2 ? null : ( + + + + + )} + +
+
); }; @@ -666,9 +761,7 @@ export default function ProcessModelShow() { iconDescription="Edit Process Model" hasIconOnly href={`/admin/process-models/${modifiedProcessModelId}/edit`} - > - Edit process model - + />

{processModel.description}

{processModel.primary_file_name ? processStartButton : null} - {processModelFilesSection()} - - My Process Instances} - filtersEnabled={false} - showLinkToReport - variant="for-me" - additionalReportFilters={[ - { - field_name: 'process_model_identifier', - field_value: processModel.id, - }, - ]} - perPageOptions={[2, 5, 25]} - showReports={false} - /> - - +
{tabArea()}
); } diff --git a/spiffworkflow-frontend/src/routes/ReactFormEditor.tsx b/spiffworkflow-frontend/src/routes/ReactFormEditor.tsx index d8cbaf59..7676e805 100644 --- a/spiffworkflow-frontend/src/routes/ReactFormEditor.tsx +++ b/spiffworkflow-frontend/src/routes/ReactFormEditor.tsx @@ -6,6 +6,7 @@ import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; // @ts-ignore import { Button, ButtonSet, Modal } from '@carbon/react'; import { Can } from '@casl/react'; +import MDEditor from '@uiw/react-md-editor'; import ProcessBreadcrumb from '../components/ProcessBreadcrumb'; import HttpService from '../services/HttpService'; import ButtonWithConfirmation from '../components/ButtonWithConfirmation'; @@ -57,6 +58,7 @@ export default function ReactFormEditor() { const hasDiagram = fileExtension === 'bpmn' || fileExtension === 'dmn'; const hasFormBuilder = fileExtension === 'json'; + const defaultFileName = searchParams.get('default_file_name'); const editorDefaultLanguage = (() => { if (fileExtension === 'json') { @@ -106,7 +108,8 @@ export default function ReactFormEditor() { setProcessModelFile(file); } if (!params.file_name) { - const fileNameWithExtension = `${newFileName}.${fileExtension}`; + const fileNameWithExtension = + defaultFileName ?? `${newFileName}.${fileExtension}`; navigate( `/admin/process-models/${modifiedProcessModelId}/form/${fileNameWithExtension}` ); @@ -119,7 +122,7 @@ export default function ReactFormEditor() { let url = `/process-models/${modifiedProcessModelId}/files`; let httpMethod = 'PUT'; - let fileNameWithExtension = params.file_name; + let fileNameWithExtension = params.file_name || defaultFileName; if (newFileName) { fileNameWithExtension = `${newFileName}.${fileExtension}`; @@ -219,6 +222,30 @@ export default function ReactFormEditor() { return null; }; + const editorArea = () => { + if (fileExtension === 'md') { + return ( +
+ setProcessModelFileContents(value || '')} + /> +
+ ); + } + return ( + setProcessModelFileContents(value || '')} + /> + ); + }; + if (processModelFile || !params.file_name) { const processModelFileName = processModelFile ? processModelFile.name : ''; const formBuildFileParam = params.file_name @@ -318,13 +345,7 @@ export default function ReactFormEditor() {
- setProcessModelFileContents(value || '')} - /> + {editorArea()} ); }