Skip to content

Commit

Permalink
Fixes #38160 - Update hosts link to new hosts URL (#11296)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanshekar authored Jan 31, 2025
1 parent e3247e8 commit 412e7f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
6 changes: 5 additions & 1 deletion webpack/scenes/ContentViews/expansions/DetailsExpansion.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 (
Expand All @@ -36,7 +40,7 @@ const DetailsExpansion = ({
<div id={`cv-details-expansion-${cvId}`}>
{__('Activation keys: ')}<a aria-label={`activation_keys_link_${cvId}`} href={`/activation_keys?search=content_view_id+%3D+${cvId}`}>{activationKeyCount}</a>
<br />
{__('Hosts: ')}<a aria-label={`host_link_${cvId}`} href={`/hosts?search=content_view_id+%3D+${cvId}`}>{hostCount}</a>
{__('Hosts: ')}<a aria-label={`host_link_${cvId}`} href={hostsPageUrl}>{hostCount}</a>
<br />
{relatedContentViewModal()}
</div>
Expand Down

0 comments on commit 412e7f9

Please sign in to comment.