diff --git a/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx b/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx new file mode 100644 index 000000000..e6916e95b --- /dev/null +++ b/spiffworkflow-frontend/src/components/ProcessGroupListTiles.tsx @@ -0,0 +1,96 @@ +import { ReactElement, useEffect, useState } from 'react'; +import { useNavigate, useSearchParams } from 'react-router-dom'; +import { + ArrowRight, + // @ts-ignore +} from '@carbon/icons-react'; +import { + ClickableTile, + // @ts-ignore +} from '@carbon/react'; +import HttpService from '../services/HttpService'; +import { ProcessGroup } from '../interfaces'; +import { modifyProcessModelPath, truncateString } from '../helpers'; + +type OwnProps = { + processGroup?: ProcessGroup; + headerElement?: ReactElement; +}; + +export default function ProcessGroupListTiles({ + processGroup, + headerElement, +}: OwnProps) { + const [searchParams] = useSearchParams(); + + const [processGroups, setProcessGroups] = useState( + null + ); + + useEffect(() => { + const setProcessGroupsFromResult = (result: any) => { + setProcessGroups(result.results); + }; + let queryParams = '?per_page=1000'; + if (processGroup) { + queryParams = `${queryParams}&process_group_identifier=${processGroup.id}`; + } + HttpService.makeCallToBackend({ + path: `/process-groups${queryParams}`, + successCallback: setProcessGroupsFromResult, + }); + }, [searchParams]); + + const processGroupDirectChildrenCount = (pg: ProcessGroup) => { + return (pg.process_models || []).length + (pg.process_groups || []).length; + }; + + const processGroupsDisplayArea = () => { + let displayText = null; + if (processGroups && processGroups.length > 0) { + displayText = (processGroups || []).map((row: ProcessGroup) => { + return ( + +
+ +
+ {row.display_name} +
+

+ {truncateString(row.description || '', 25)} +

+

+ Total Sub Items: {processGroupDirectChildrenCount(row)} +

+
+
+ ); + }); + } else { + displayText =

No Groups To Display

; + } + return displayText; + }; + + const processGroupArea = () => { + if (processGroups) { + if (!processGroup || processGroups.length > 0) { + return ( + <> + {headerElement} + {processGroupsDisplayArea()} + + ); + } + } + }; + + if (processGroups) { + return <>{processGroupArea()}; + } + return null; +} diff --git a/spiffworkflow-frontend/src/index.css b/spiffworkflow-frontend/src/index.css index a89f6725d..3b8035179 100644 --- a/spiffworkflow-frontend/src/index.css +++ b/spiffworkflow-frontend/src/index.css @@ -5,21 +5,21 @@ color: white; } -h1{ - height: 36px; - font-family: 'IBM Plex Sans'; - font-style: normal; +h1 { font-weight: 400; font-size: 28px; line-height: 36px; color: #161616; - flex: none; - order: 0; - align-self: stretch; - flex-grow: 0; margin-bottom: 1em } +h2 { + font-weight: 400; + font-size: 20px; + line-height: 28px; + color: #161616; +} + .span-tag { color: black; } diff --git a/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx b/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx index a4813020a..ba4513bbb 100644 --- a/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessGroupList.tsx @@ -1,36 +1,23 @@ import { useEffect, useState } from 'react'; import { useNavigate, useSearchParams } from 'react-router-dom'; -import { - ArrowRight, - // @ts-ignore -} from '@carbon/icons-react'; import { Button, - ClickableTile, // @ts-ignore } from '@carbon/react'; import { Can } from '@casl/react'; import ProcessBreadcrumb from '../components/ProcessBreadcrumb'; import HttpService from '../services/HttpService'; import { modifyProcessModelPath, truncateString } from '../helpers'; -import { - CarbonComboBoxSelection, - PermissionsToCheck, - ProcessGroup, -} from '../interfaces'; +import { CarbonComboBoxSelection, PermissionsToCheck } from '../interfaces'; import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { usePermissionFetcher } from '../hooks/PermissionService'; import ProcessModelSearch from '../components/ProcessModelSearch'; +import ProcessGroupListTiles from '../components/ProcessGroupListTiles'; -// Example process group json -// {'process_group_id': 'sure', 'display_name': 'Test Workflows', 'id': 'test_process_group'} export default function ProcessGroupList() { const [searchParams] = useSearchParams(); const navigate = useNavigate(); - const [processGroups, setProcessGroups] = useState( - null - ); const [processModelAvailableItems, setProcessModelAvailableItems] = useState( [] ); @@ -42,9 +29,6 @@ export default function ProcessGroupList() { const { ability } = usePermissionFetcher(permissionRequestData); useEffect(() => { - const setProcessGroupsFromResult = (result: any) => { - setProcessGroups(result.results); - }; const processResultForProcessModels = (result: any) => { const selectionArray = result.results.map((item: any) => { const label = `${item.id}`; @@ -53,12 +37,6 @@ export default function ProcessGroupList() { }); setProcessModelAvailableItems(selectionArray); }; - - // for browsing - HttpService.makeCallToBackend({ - path: `/process-groups?per_page=1000`, - successCallback: setProcessGroupsFromResult, - }); // for search box HttpService.makeCallToBackend({ path: `/process-models?per_page=1000`, @@ -66,44 +44,6 @@ export default function ProcessGroupList() { }); }, [searchParams]); - const processGroupDirectChildrenCount = (processGroup: ProcessGroup) => { - return ( - (processGroup.process_models || []).length + - (processGroup.process_groups || []).length - ); - }; - - const processGroupsDisplayArea = () => { - let displayText = null; - if (processGroups && processGroups.length > 0) { - displayText = (processGroups || []).map((row: ProcessGroup) => { - return ( - -
- -
- {row.display_name} -
-

- {truncateString(row.description || '', 25)} -

-

- Total Sub Items: {processGroupDirectChildrenCount(row)} -

-
-
- ); - }); - } else { - displayText =

No Groups To Display

; - } - return displayText; - }; - const processModelSearchArea = () => { const processModelSearchOnChange = (selection: CarbonComboBoxSelection) => { const processModel = selection.selectedItem; @@ -120,7 +60,7 @@ export default function ProcessGroupList() { ); }; - if (processGroups) { + if (processModelAvailableItems) { return ( <> @@ -134,7 +74,7 @@ export default function ProcessGroupList() {
{processModelSearchArea()}
- {processGroupsDisplayArea()} + ); } diff --git a/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx b/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx index 7bcda61b1..31f5297e9 100644 --- a/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessGroupShow.tsx @@ -19,6 +19,7 @@ import { } from '../interfaces'; import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { usePermissionFetcher } from '../hooks/PermissionService'; +import ProcessGroupListTiles from '../components/ProcessGroupListTiles'; export default function ProcessGroupShow() { const params = useParams(); @@ -95,7 +96,7 @@ export default function ProcessGroupShow() { }); return (
-

Process Models

+

Process Models

@@ -198,15 +199,10 @@ export default function ProcessGroupShow() { )}

- {/* eslint-disable-next-line sonarjs/no-gratuitous-expressions */} - {groupPagination && groupPagination.total > 0 && ( - - )} + Process Groups} + /> );