diff --git a/frontend/packages/core/src/AppNotifications/LayoutWithNotifications.tsx b/frontend/packages/core/src/AppNotifications/LayoutWithNotifications.tsx index 392fa88880..323360bf96 100644 --- a/frontend/packages/core/src/AppNotifications/LayoutWithNotifications.tsx +++ b/frontend/packages/core/src/AppNotifications/LayoutWithNotifications.tsx @@ -6,7 +6,7 @@ import { Alert } from "../Feedback"; import Grid from "../grid"; import { Link as LinkComponent } from "../link"; import type { AppBanners } from "../Types"; -import { checkPathMatchList } from "../utils"; +import { findPathMatchList } from "../utils"; interface LayoutWithNotificationsProps { bannersData: AppBanners; @@ -26,12 +26,13 @@ const LayoutWithNotifications = ({ const location = useLocation(); - checkPathMatchList(location?.pathname, perWorkflowData[workflow]?.paths); + const pathMatches = findPathMatchList(location?.pathname, perWorkflowData[workflow]?.paths); const hasPerWorkflowAlert = workflow && perWorkflowData[workflow] && !perWorkflowData[workflow]?.dismissed; const showAlertPerWorkflow = !isEmpty(perWorkflowData[workflow]?.paths) - ? hasPerWorkflowAlert && perWorkflowData[workflow]?.paths?.includes(location.pathname) + ? hasPerWorkflowAlert && + (perWorkflowData[workflow]?.paths?.includes(location.pathname) || pathMatches) : hasPerWorkflowAlert; const showAlertMultiWorkflow = diff --git a/frontend/packages/core/src/utils/index.ts b/frontend/packages/core/src/utils/index.ts index a08d37eaee..b42b50a982 100644 --- a/frontend/packages/core/src/utils/index.ts +++ b/frontend/packages/core/src/utils/index.ts @@ -1,3 +1,3 @@ // eslint-disable-next-line import/prefer-default-export export { default as getDisplayName } from "./getDisplayName"; -export { default as checkPathMatchList } from "./pathMatching"; +export { default as findPathMatchList } from "./pathMatching"; diff --git a/frontend/packages/core/src/utils/pathMatching.tsx b/frontend/packages/core/src/utils/pathMatching.tsx index 944f2477cd..ea6a6d07e3 100644 --- a/frontend/packages/core/src/utils/pathMatching.tsx +++ b/frontend/packages/core/src/utils/pathMatching.tsx @@ -1,11 +1,17 @@ import { matchPath } from "react-router"; -const checkPathMatchList = (locationPathname: string, pathstoMatch: string[]) => { - pathstoMatch.forEach(path => { +const findPathMatchList = (locationPathname: string, pathstoMatch: string[]) => { + let pathFound = false; + + pathstoMatch?.forEach((path: string) => { const match = matchPath({ path }, locationPathname); - console.log("match: ", match); + if (match) { + pathFound = true; + } }); + + return pathFound; }; -export default checkPathMatchList; +export default findPathMatchList;