From 412e7f93ef4a3d9a7601a4cc1ed8d51dfb819ead Mon Sep 17 00:00:00 2001 From: Pavan Soma Shekar <32700193+pavanshekar@users.noreply.github.com> Date: Fri, 31 Jan 2025 10:23:53 -0500 Subject: [PATCH] Fixes #38160 - Update hosts link to new hosts URL (#11296) --- .../scenes/ContentViews/__tests__/contentViewPage.test.js | 2 +- webpack/scenes/ContentViews/expansions/DetailsExpansion.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js b/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js index cc6acf9df04..d7c83bd9bca 100644 --- a/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +++ b/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js @@ -132,7 +132,7 @@ test('Can expand cv and show activation keys and hosts', async (done) => { expect(queryByLabelText('activation_keys_link_2').textContent).toEqual('1'); // Displays hosts link with count - expect(queryByLabelText('host_link_2')).toHaveAttribute('href', '/hosts?search=content_view_id+%3D+2'); + expect(queryByLabelText('host_link_2')).toHaveAttribute('href', '/new/hosts?search=content_view_id%3D2'); expect(queryByLabelText('host_link_2').textContent).toEqual('1'); }); diff --git a/webpack/scenes/ContentViews/expansions/DetailsExpansion.js b/webpack/scenes/ContentViews/expansions/DetailsExpansion.js index 060bdddb944..7a8595e8c9c 100644 --- a/webpack/scenes/ContentViews/expansions/DetailsExpansion.js +++ b/webpack/scenes/ContentViews/expansions/DetailsExpansion.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { translate as __ } from 'foremanReact/common/I18n'; +import { useForemanHostsPageUrl } from 'foremanReact/Root/Context/ForemanContext'; import RelatedCompositeContentViewsModal from './RelatedCompositeContentViewsModal'; import RelatedContentViewComponentsModal from './RelatedContentViewComponentsModal'; @@ -10,6 +11,9 @@ const DetailsExpansion = ({ const activationKeyCount = activationKeys.length; const hostCount = hosts.length; + const baseHostsPageUrl = useForemanHostsPageUrl(); + const hostsPageUrl = `${baseHostsPageUrl}?search=${encodeURIComponent(`content_view_id=${cvId}`)}`; + const relatedContentViewModal = () => { if (cvComposite) { return ( @@ -36,7 +40,7 @@ const DetailsExpansion = ({