diff --git a/config/jest.setupTests.js b/config/jest.setupTests.js index 947ceb4fd..1881282c7 100644 --- a/config/jest.setupTests.js +++ b/config/jest.setupTests.js @@ -99,6 +99,7 @@ global.window.insights = { }) ) }, + getBundleData: Function.prototype, getUserPermissions: () => [], hideGlobalFilter: Function.prototype, identifyApp: Function.prototype, diff --git a/src/components/router/__tests__/__snapshots__/routerContext.test.js.snap b/src/components/router/__tests__/__snapshots__/routerContext.test.js.snap index c70b07d8b..245c1c5f0 100644 --- a/src/components/router/__tests__/__snapshots__/routerContext.test.js.snap +++ b/src/components/router/__tests__/__snapshots__/routerContext.test.js.snap @@ -44,6 +44,7 @@ exports[`RouterContext should apply a hook for useRouteDetail: document title 1` [ [ "t(curiosity-view.title, {"appName":"Subscriptions","context":"RHEL"}) - Subscriptions", + true, ], ] `; diff --git a/src/components/router/routerContext.js b/src/components/router/routerContext.js index 29a9d8327..0d4b89d96 100644 --- a/src/components/router/routerContext.js +++ b/src/components/router/routerContext.js @@ -102,7 +102,8 @@ const useRouteDetail = ({ useChrome: useAliasChrome = useChrome, useSelector: useAliasSelector = storeHooks.reactRedux.useSelectors } = {}) => { - const { updateDocumentTitle = helpers.noop } = useAliasChrome(); + const { getBundleData = helpers.noop, updateDocumentTitle = helpers.noop } = useAliasChrome(); + const bundleData = getBundleData(); const [productPath] = useAliasSelector([({ view }) => view?.product?.config]); const [detail, setDetail] = useState({}); @@ -112,12 +113,13 @@ const useRouteDetail = ({ pathName: productPath }); - // Set document title + // Set document title, remove pre-baked suffix updateDocumentTitle( `${t(`curiosity-view.title`, { appName: helpers.UI_DISPLAY_NAME, context: firstMatch?.productGroup - })} - ${helpers.UI_DISPLAY_NAME}` + })} - ${helpers.UI_DISPLAY_NAME}${(bundleData?.bundleTitle && ` | ${bundleData?.bundleTitle}`) || ''}`, + true ); // Set route detail @@ -132,7 +134,7 @@ const useRouteDetail = ({ productPath }); } - }, [detail?._passed, productPath, t, updateDocumentTitle]); + }, [bundleData?.bundleTitle, detail?._passed, productPath, t, updateDocumentTitle]); return detail; }; diff --git a/src/index.js b/src/index.js index dc4bd5651..fdf61468d 100644 --- a/src/index.js +++ b/src/index.js @@ -23,6 +23,7 @@ window.insights = { }); }) }, + getBundleData: () => ({ bundleId: 'insights', bundleTitle: 'Red Hat Insights' }), getUserPermissions: () => [], hideGlobalFilter: Function.prototype, identifyApp: Function.prototype,