From 9d16a2a5c39e808b5bd8d494559e71bc3469431e Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Wed, 20 Mar 2024 20:24:07 +0000 Subject: [PATCH] use-react-link-for-links (#1242) * use the react Link component to render links w/ burnettk * removed old code w/ burnettk * use a tag for external links according to coderabbit w/ burnettk * click the nav expander again to close in cypress tests w/ burnettk --------- Co-authored-by: jasquat --- .../cypress/support/commands.js | 2 + .../src/components/NavigationBar.tsx | 59 +++++++++++++------ 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/spiffworkflow-frontend/cypress/support/commands.js b/spiffworkflow-frontend/cypress/support/commands.js index 063659002..ecee7651b 100644 --- a/spiffworkflow-frontend/cypress/support/commands.js +++ b/spiffworkflow-frontend/cypress/support/commands.js @@ -35,6 +35,8 @@ Cypress.Commands.add('getBySel', (selector, ...args) => { Cypress.Commands.add('navigateToHome', () => { cy.getBySel('header-menu-expand-button').click(); cy.getBySel('side-nav-items').contains('Home').click(); + // ensure we close the nav + cy.getBySel('header-menu-expand-button').click(); }); Cypress.Commands.add('navigateToAdmin', () => { diff --git a/spiffworkflow-frontend/src/components/NavigationBar.tsx b/spiffworkflow-frontend/src/components/NavigationBar.tsx index 9560151d4..53644a4d0 100644 --- a/spiffworkflow-frontend/src/components/NavigationBar.tsx +++ b/spiffworkflow-frontend/src/components/NavigationBar.tsx @@ -18,20 +18,20 @@ import { } from '@carbon/react'; import { Logout } from '@carbon/icons-react'; import { useEffect, useState } from 'react'; -import { useLocation } from 'react-router-dom'; -import { Can } from '@casl/react'; +import { useLocation, Link, LinkProps } from 'react-router-dom'; // @ts-expect-error TS(2307) FIXME: Cannot find module '../logo.svg' or its correspond... Remove this comment to see the full error message import logo from '../logo.svg'; import UserService from '../services/UserService'; -import { useUriListForPermissions } from '../hooks/UriListForPermissions'; -import { PermissionsToCheck } from '../interfaces'; import { UiSchemaUxElement } from '../extension_ui_schema_interfaces'; -import { usePermissionFetcher } from '../hooks/PermissionService'; import { DOCUMENTATION_URL, SPIFF_ENVIRONMENT } from '../config'; import appVersionInfo from '../helpers/appVersionInfo'; import { slugifyString } from '../helpers'; import ExtensionUxElementForDisplay from './ExtensionUxElementForDisplay'; import SpiffTooltip from './SpiffTooltip'; +import { useUriListForPermissions } from '../hooks/UriListForPermissions'; +import { PermissionsToCheck } from '../interfaces'; +import { usePermissionFetcher } from '../hooks/PermissionService'; +import { Can } from '../contexts/Can'; type OwnProps = { extensionUxElements?: UiSchemaUxElement[] | null; @@ -59,9 +59,9 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { // default to readthedocs and let someone specify an environment variable to override: // - let documentationUrl = 'https://spiffworkflow.readthedocs.io'; + let externalDocumentationUrl = 'https://spiff-arena.readthedocs.io'; if (DOCUMENTATION_URL) { - documentationUrl = DOCUMENTATION_URL; + externalDocumentationUrl = DOCUMENTATION_URL; } const processGroupPath = '/process-groups'; @@ -101,14 +101,14 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { const extensionUserProfileElement = (uxElement: UiSchemaUxElement) => { const navItemPage = `/extensions${uxElement.page}`; - return {uxElement.label}; + return {uxElement.label}; }; const profileToggletip = () => { let aboutLinkElement = null; if (Object.keys(versionInfo).length) { - aboutLinkElement = About; + aboutLinkElement = About; } return ( @@ -128,7 +128,7 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { {username !== userEmail &&

{userEmail}

}
{aboutLinkElement} - + Documentation Configuration @@ -221,7 +222,8 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { return ( @@ -238,14 +240,20 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { return ( <> - + + element={Link} + to="/" + isCurrentPage={isActivePage('/')} + >
Home
+ @@ -260,7 +268,8 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { > Process Instances @@ -270,7 +279,8 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { Messages @@ -280,7 +290,8 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { Data Stores @@ -303,7 +314,12 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { (
- + logo
@@ -324,7 +340,12 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) { onClick={onClickSideNavExpand} isActive={isSideNavExpanded} /> - + logo