Skip to content

Commit

Permalink
Fixes #37477 - Make host links be settings aware (#571)
Browse files Browse the repository at this point in the history
(cherry picked from commit 81a93e9)
  • Loading branch information
ofedoren committed May 22, 2024
1 parent 511a3ba commit 86f62fd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { Button } from '@patternfly/react-core';

import { translate as __ } from 'foremanReact/common/I18n';
import { foremanUrl } from 'foremanReact/common/helpers';
import { getHostsPageUrl } from 'foremanReact/Root/Context/ForemanContext';
import { useForemanHostsPageUrl } from 'foremanReact/Root/Context/ForemanContext';

const ViewSelectedHostsLink = ({
hostIdsParam,
isAllHostsSelected,
defaultFailedHostsSearch,
}) => {
const search = isAllHostsSelected ? defaultFailedHostsSearch : hostIdsParam;
const url = foremanUrl(`${getHostsPageUrl(false)}?search=${search}`);
const url = foremanUrl(`${useForemanHostsPageUrl()}?search=${search}`);
return (
<Button
component="a"
Expand Down
14 changes: 12 additions & 2 deletions webpack/components/OpenscapRemediationWizard/steps/ReviewHosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ToolbarContent,
ToolbarGroup,
ToolbarItem,
Button,
} from '@patternfly/react-core';
import { Td } from '@patternfly/react-table';
import { toArray } from 'lodash';
Expand All @@ -19,6 +20,7 @@ import { useBulkSelect } from 'foremanReact/components/PF4/TableIndexPage/Table/
import { getPageStats } from 'foremanReact/components/PF4/TableIndexPage/Table/helpers';
import { STATUS } from 'foremanReact/constants';
import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
import { useForemanHostDetailsPageUrl } from 'foremanReact/Root/Context/ForemanContext';

import OpenscapRemediationWizardContext from '../OpenscapRemediationWizardContext';
import WizardHeader from '../WizardHeader';
Expand Down Expand Up @@ -158,11 +160,19 @@ const ReviewHosts = () => {
rowData: PropTypes.object.isRequired,
};

const hostDetailsURL = useForemanHostDetailsPageUrl();
const columns = {
name: {
title: __('Name'),
wrapper: ({ id, display_name: displayName }) => (
<a href={foremanUrl(`hosts/${id}`)}>{displayName}</a>
wrapper: ({ name, display_name: displayName }) => (
<Button
component="a"
variant="link"
target="_blank"
href={foremanUrl(`${hostDetailsURL}${name}`)}
>
{displayName}
</Button>
),
isSorted: true,
weight: 50,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons';

import { translate as __ } from 'foremanReact/common/I18n';
import { foremanUrl } from 'foremanReact/common/helpers';
import { getHostsPageUrl } from 'foremanReact/Root/Context/ForemanContext';
import {
useForemanHostsPageUrl,
useForemanHostDetailsPageUrl,
} from 'foremanReact/Root/Context/ForemanContext';

import OpenscapRemediationWizardContext from '../OpenscapRemediationWizardContext';
import WizardHeader from '../WizardHeader';
import ViewSelectedHostsLink from '../ViewSelectedHostsLink';
import { HOSTS_PATH, FAIL_RULE_SEARCH } from '../constants';
import { FAIL_RULE_SEARCH } from '../constants';
import { findFixBySnippet } from '../helpers';

import './ReviewRemediation.scss';
Expand Down Expand Up @@ -120,7 +123,7 @@ const ReviewRemediation = () => {
iconPosition="right"
target="_blank"
component="a"
href={foremanUrl(`${getHostsPageUrl(true)}/${hostName}`)}
href={foremanUrl(`${useForemanHostDetailsPageUrl()}${hostName}`)}
>
{hostName}
</Button>{' '}
Expand All @@ -133,7 +136,7 @@ const ReviewRemediation = () => {
target="_blank"
component="a"
href={foremanUrl(
`${HOSTS_PATH}/?search=${FAIL_RULE_SEARCH} = ${source}`
`${useForemanHostsPageUrl()}?search=${FAIL_RULE_SEARCH} = ${source}`
)}
>
{__('Other hosts failing this rule')}
Expand Down

0 comments on commit 86f62fd

Please sign in to comment.