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

Show complete hostgroup name in host overview and table #10244

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const DetailsCard = ({
comment,
owner_id: ownerID,
owner_name: ownerName,
hostgroup_title: hostgroupTitle,
hostgroup_name: hostgroupName,
hostgroup_id: hostgroupId,
permissions: {
Expand Down Expand Up @@ -120,18 +121,24 @@ const DetailsCard = ({
justifyContent={{ default: 'justifyContentSpaceBetween' }}
>
<FlexItem>
<Button
ouiaId="host-group-link"
component="a"
href={foremanUrl(
`/hosts?search=hostgroup="${hostgroupName}"`
<span>
{hostgroupTitle?.substring(
0,
hostgroupTitle?.lastIndexOf(hostgroupName)
)}
variant="link"
target="_blank"
isInline
>
{hostgroupName}
</Button>
<Button
ouiaId="host-group-link"
component="a"
href={foremanUrl(
`/hosts?search=hostgroup="${hostgroupName}"`
Copy link
Contributor

Choose a reason for hiding this comment

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

There is still one issue with this. If you have a parent host group "parentA" and "parentB" its allowed to have a child host group with the name "child" in both "parentA" and "parentB" - so the child has the same name.
if you know have a button to "child" it will search for "child" having both, hosts of group "parentA/child" AND "parentB/child".

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbernhard thank you for noticing, I'm looking into that

)}
variant="link"
target="_blank"
isInline
>
{hostgroupName}
</Button>
</span>
</FlexItem>
<FlexItem>
<Button
Expand Down Expand Up @@ -196,6 +203,7 @@ DetailsCard.propTypes = {
status: PropTypes.string,
hostDetails: PropTypes.shape({
comment: PropTypes.string,
hostgroup_title: PropTypes.string,
hostgroup_name: PropTypes.string,
hostgroup_id: PropTypes.number,
ip: PropTypes.string,
Expand All @@ -212,6 +220,7 @@ DetailsCard.defaultProps = {
status: STATUS.PENDING,
hostDetails: {
comment: undefined,
hostgroup_title: undefined,
hostgroup_name: undefined,
hostgroup_id: undefined,
ip: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SystemPropertiesCard = ({ status, hostDetails }) => {
organization_name: organization,
owner_name: ownerName,
domain_name: domain,
hostgroup_name: hostgroupName,
hostgroup_title: hostgroupTitle,
owner_type: ownerType,
} = hostDetails;
return (
Expand Down Expand Up @@ -103,7 +103,7 @@ const SystemPropertiesCard = ({ status, hostDetails }) => {
status={status}
emptyState={<DefaultLoaderEmptyState />}
>
{hostgroupName}
{hostgroupTitle}
</SkeletonLoader>
</DescriptionListDescription>
</DescriptionListGroup>
Expand Down Expand Up @@ -164,7 +164,7 @@ const SystemPropertiesCard = ({ status, hostDetails }) => {
SystemPropertiesCard.propTypes = {
status: PropTypes.string,
hostDetails: PropTypes.shape({
hostgroup_name: PropTypes.string,
hostgroup_title: PropTypes.string,
model_name: PropTypes.string,
organization_name: PropTypes.string,
location_name: PropTypes.string,
Expand All @@ -184,7 +184,7 @@ SystemPropertiesCard.defaultProps = {
model_name: undefined,
organization_name: undefined,
location_name: undefined,
hostgroup_name: undefined,
hostgroup_title: undefined,
owner_type: undefined,
owner_name: undefined,
domain_name: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ const coreHostsIndexColumns = [
{
columnName: 'hostgroup',
title: __('Host group'),
wrapper: hostDetails => (
<a href={`/hostgroups/${hostDetails?.hostgroup_id}/edit`}>
{hostDetails?.hostgroup_name}
</a>
),
wrapper: hostDetails => {
const fullTitle = hostDetails?.hostgroup_title;
const name = hostDetails?.hostgroup_name;
return (
<span>
{fullTitle?.substring(0, fullTitle?.lastIndexOf(name))}
<a href={`/hostgroups/${hostDetails?.hostgroup_id}/edit`}>{name}</a>
</span>
);
},
isSorted: true,
weight: 100,
},
Expand Down
Loading