From e161c3dedea9277f9c129072a0cba8a0ea4fccc9 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 14 Dec 2023 14:49:56 -0500 Subject: [PATCH] removed bad file w/ burnettk --- spiffworkflow-frontend/' | 146 --------------------------------------- 1 file changed, 146 deletions(-) delete mode 100644 spiffworkflow-frontend/' diff --git a/spiffworkflow-frontend/' b/spiffworkflow-frontend/' deleted file mode 100644 index 9c54c427a..000000000 --- a/spiffworkflow-frontend/' +++ /dev/null @@ -1,146 +0,0 @@ -// @ts-ignore -import { Breadcrumb, BreadcrumbItem } from '@carbon/react'; -import React, { useEffect, useState } from 'react'; -import { modifyProcessIdentifierForPathParam } from '../helpers'; -import { - HotCrumbItem, - HotCrumbItemArray, - HotCrumbItemObject, - ProcessGroup, - ProcessGroupLite, - ProcessModel, -} from '../interfaces'; -import HttpService from '../services/HttpService'; - -type OwnProps = { - hotCrumbs?: HotCrumbItem[]; -}; - -// export default function ProcessBreadcrumb({ hotCrumbs }: OwnProps) { -export const default ProcessBreadcrumb = React.memo(({ hotCrumbs }: OwnProps) => { - const [processEntity, setProcessEntity] = useState< - ProcessGroup | ProcessModel | null - >(null); - - useEffect(() => { - const explodeCrumbItemObject = (crumb: HotCrumbItem) => { - if ('entityToExplode' in crumb) { - const { entityToExplode, entityType } = crumb; - if (entityType === 'process-model-id') { - HttpService.makeCallToBackend({ - path: `/process-models/${modifyProcessIdentifierForPathParam( - entityToExplode as string - )}`, - successCallback: setProcessEntity, - onUnauthorized: () => {}, - }); - } else if (entityType === 'process-group-id') { - HttpService.makeCallToBackend({ - path: `/process-groups/${modifyProcessIdentifierForPathParam( - entityToExplode as string - )}`, - successCallback: setProcessEntity, - onUnauthorized: () => {}, - }); - } else { - setProcessEntity(entityToExplode as any); - } - } - }; - if (hotCrumbs) { - hotCrumbs.forEach(explodeCrumbItemObject); - } - }, [hotCrumbs]); - - const checkPermissions = (crumb: HotCrumbItemObject) => { - if (!crumb.checkPermission) { - return true; - } - return ( - processEntity && - 'actions' in processEntity && - processEntity.actions && - 'read' in processEntity.actions - ); - }; - - // eslint-disable-next-line sonarjs/cognitive-complexity - const hotCrumbElement = () => { - if (hotCrumbs) { - const leadingCrumbLinks = hotCrumbs.map( - (crumb: HotCrumbItemArray | HotCrumbItemObject) => { - if ( - 'entityToExplode' in crumb && - processEntity && - processEntity.parent_groups && - checkPermissions(crumb) - ) { - const breadcrumbs = processEntity.parent_groups.map( - (parentGroup: ProcessGroupLite) => { - const fullUrl = `/process-groups/${modifyProcessIdentifierForPathParam( - parentGroup.id - )}`; - return ( - - {parentGroup.display_name} - - ); - } - ); - - if (crumb.linkLastItem) { - let apiBase = '/process-groups'; - let dataQaTag = ''; - if (crumb.entityType.startsWith('process-model')) { - apiBase = '/process-models'; - dataQaTag = 'process-model-breadcrumb-link'; - } - const fullUrl = `${apiBase}/${modifyProcessIdentifierForPathParam( - processEntity.id - )}`; - breadcrumbs.push( - - {processEntity.display_name} - - ); - } else { - breadcrumbs.push( - - {processEntity.display_name} - - ); - } - return breadcrumbs; - } - if (Array.isArray(crumb)) { - const valueLabel = crumb[0]; - const url = crumb[1]; - if (!url && valueLabel) { - return ( - - {valueLabel} - - ); - } - if (url && valueLabel) { - return ( - - {valueLabel} - - ); - } - } - return null; - } - ); - return {leadingCrumbLinks}; - } - return null; - }; - - return {hotCrumbElement()}; -})