Skip to content

Commit

Permalink
Refs #37441 - use foreman setting for host url
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga committed May 22, 2024
1 parent d31bb57 commit a7a4e2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { useSelector } from 'react-redux';
import URI from 'urijs';
import { List, ListItem, Modal, Button } from '@patternfly/react-core';
import { translate as __, sprintf } from 'foremanReact/common/I18n';
import { foremanUrl } from 'foremanReact/common/helpers';
import { HOSTS_PATH } from 'foremanReact/routes/Hosts/constants';
import {
useForemanHostsPageUrl,
useForemanHostDetailsPageUrl,
} from 'foremanReact/Root/Context/ForemanContext';
import { selectHosts, selectHostCount } from '../../JobWizardSelectors';
import { HOSTS_TO_PREVIEW_AMOUNT } from '../../JobWizardConstants';

export const HostPreviewModal = ({ isOpen, setIsOpen, searchQuery }) => {
const hosts = useSelector(selectHosts);
const hostsCount = useSelector(selectHostCount);
const url = new URI(foremanUrl('/hosts'));

const hostsUrl = new URI(useForemanHostsPageUrl());
const hostUrl = useForemanHostDetailsPageUrl();
return (
<Modal
ouiaId="host-preview-modal"
Expand All @@ -28,7 +30,7 @@ export const HostPreviewModal = ({ isOpen, setIsOpen, searchQuery }) => {
<Button
ouiaId={`host-preview-${host}`}
component="a"
href={foremanUrl(`${HOSTS_PATH}/${host.name}`)}
href={`${hostUrl}${host.name}`}
variant="link"
target="_blank"
rel="noreferrer"
Expand All @@ -43,7 +45,7 @@ export const HostPreviewModal = ({ isOpen, setIsOpen, searchQuery }) => {
<Button
ouiaId="host-preview-more"
component="a"
href={url.addSearch({ search: searchQuery })}
href={hostsUrl.addSearch({ search: searchQuery })}
variant="link"
target="_blank"
rel="noreferrer"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const useForemanOrganization = () => ({ id: 1 });
export const useForemanLocation = () => ({ id: 2 });
export const useForemanVersion = () => '3.7';
export const useForemanHostsPageUrl = () => '/hosts';
export const useForemanHostDetailsPageUrl = () => '/hosts/';

0 comments on commit a7a4e2a

Please sign in to comment.