Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37477 - Make host links be settings aware #571

Merged
merged 1 commit into from
May 22, 2024

Conversation

ofedoren
Copy link
Member

No description provided.

wrapper: ({ id, display_name: displayName }) => (
<a href={foremanUrl(`hosts/${id}`)}>{displayName}</a>
wrapper: ({ name, display_name: displayName }) => (
<a href={foremanUrl(`${getHostsPageUrl(true)}/${name}`)}>{displayName}</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested the same mistake I did in yesterdays PR 🙃
I meant HOSTS_PATH from import { HOSTS_PATH } from 'foremanReact/routes/Hosts/constants';
HOSTS_PATH is for /new/hosts , for single hosts
getHostsPageUrl is for the experimental index host page

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think getHostsPageUrl is supposed to be used this way anyway

export const getHostsPageUrl = displayNewHostsPage =>
  displayNewHostsPage ? '/new/hosts' : '/hosts';

export const useForemanHostsPageUrl = () => {
  const { displayNewHostsPage } = useForemanSettings();
  return getHostsPageUrl(displayNewHostsPage);
};

useForemanHostsPageUrl is using the setting displayNewHostsPage which is for the index page, and not for the show page

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created theforeman/foreman#10174 so foreman context will use the settings for both index and show page for host url

@ofedoren ofedoren changed the title Fixes #37477 - Use getHostsPageUrl in hosts table Fixes #37477 - Make host links be settings aware May 22, 2024
@ofedoren
Copy link
Member Author

Thanks, @MariaAga, I've updated all the links in the wizard to use helpers from core.

component="a"
variant="link"
target="_blank"
href={foremanUrl(`${useForemanHostDetailsPageUrl()}${name}`)} // eslint-disable-line react-hooks/rules-of-hooks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move useForemanHostDetailsPageUrl out so it wont break react by accident

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really... weird that this could break anything :/

Updated.

Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good but I didnt test it 👍

@ofedoren ofedoren merged commit 81a93e9 into theforeman:master May 22, 2024
21 of 26 checks passed
ofedoren added a commit that referenced this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants