-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37309 - Add Katello columns to new host index page
- Loading branch information
1 parent
d8b7638
commit 77aa1d5
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* eslint-disable no-param-reassign */ | ||
import React from 'react'; | ||
import { | ||
BugIcon, | ||
SecurityIcon, | ||
EnhancementIcon, | ||
PackageIcon, | ||
} from '@patternfly/react-icons'; | ||
import { Link } from 'react-router-dom'; | ||
import { Flex, FlexItem } from '@patternfly/react-core'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import RelativeDateTime from 'foremanReact/components/common/dates/RelativeDateTime'; | ||
|
||
const hostsIndexColumnExtensions = [ | ||
{ | ||
columnName: 'rhel_lifecycle_status', | ||
title: __('RHEL Lifecycle status'), | ||
wrapper: (hostDetails) => { | ||
const rhelLifecycle = hostDetails?.rhel_lifecycle_status_label; | ||
return rhelLifecycle || '—'; | ||
}, | ||
weight: 100, | ||
isSorted: true, | ||
}, | ||
{ | ||
columnName: 'installable_updates', | ||
title: __('Installable updates'), | ||
wrapper: (hostDetails) => { | ||
const errataCounts = hostDetails?.content_facet_attributes?.errata_counts; | ||
const registered = !!hostDetails?.subscription_facet_attributes?.uuid; | ||
const { security, bugfix, enhancement } = errataCounts ?? {}; | ||
const upgradableRpmCount = hostDetails?.content_facet_attributes?.upgradable_package_count; | ||
if (!registered) return '—'; | ||
const hostErrataUrl = type => `hosts/${hostDetails?.name}#/Content/errata?type=${type}&show=installable`; | ||
return ( | ||
<Flex align={{ default: 'spaceBetween' }}> | ||
{security !== undefined && | ||
<FlexItem> | ||
<SecurityIcon color="#0066cc" /> | ||
<Link to={hostErrataUrl('security')}>{security}</Link> | ||
</FlexItem> | ||
} | ||
{bugfix !== undefined && | ||
<FlexItem> | ||
<BugIcon color="#8bc1f7" /> | ||
<Link to={hostErrataUrl('bugfix')}>{bugfix}</Link> | ||
</FlexItem> | ||
} | ||
{enhancement !== undefined && | ||
<FlexItem> | ||
<EnhancementIcon color="#002f5d" /> | ||
<Link to={hostErrataUrl('enhancement')}>{enhancement}</Link> | ||
</FlexItem> | ||
} | ||
{upgradableRpmCount !== undefined && | ||
<FlexItem> | ||
<PackageIcon /> | ||
<Link to={`hosts/${hostDetails?.name}#/Content/Packages?status=Upgradable`}>{upgradableRpmCount}</Link> | ||
</FlexItem> | ||
} | ||
</Flex> | ||
); | ||
}, | ||
weight: 200, | ||
isSorted: false, | ||
}, | ||
{ | ||
columnName: 'last_checkin', | ||
title: __('Last seen'), | ||
wrapper: (hostDetails) => { | ||
const lastCheckin = | ||
hostDetails?.subscription_facet_attributes?.last_checkin; | ||
return <RelativeDateTime defaultValue={__('Never')} date={lastCheckin} />; | ||
}, | ||
weight: 400, | ||
isSorted: true, | ||
}, | ||
{ | ||
columnName: 'content_view', | ||
title: __('Content view'), | ||
wrapper: (hostDetails) => { | ||
const contentView = | ||
hostDetails?.content_facet_attributes?.content_view?.name; | ||
return contentView || __('None'); | ||
}, | ||
weight: 500, | ||
isSorted: false, | ||
}, | ||
{ | ||
columnName: 'lifecycle_environment', | ||
title: __('Lifecycle environment'), | ||
wrapper: (hostDetails) => { | ||
const lifecycleEnvironment = | ||
hostDetails?.content_facet_attributes?.lifecycle_environment?.name; | ||
return lifecycleEnvironment || __('None'); | ||
}, | ||
weight: 600, | ||
isSorted: false, | ||
}, | ||
{ | ||
columnName: 'content_source', | ||
title: __('Content source'), | ||
wrapper: (hostDetails) => { | ||
const contentSource = | ||
hostDetails?.content_facet_attributes?.content_source_name; | ||
return contentSource || __('None'); | ||
}, | ||
weight: 700, | ||
isSorted: false, | ||
}, | ||
{ | ||
columnName: 'registered_at', | ||
title: __('Registered at'), | ||
wrapper: (hostDetails) => { | ||
const registeredAt = hostDetails?.subscription_facet_attributes?.registered_at; | ||
return <RelativeDateTime defaultValue={'—'} date={registeredAt} />; | ||
}, | ||
}, | ||
]; | ||
|
||
hostsIndexColumnExtensions.forEach((column) => { | ||
column.tableName = 'hosts'; | ||
column.categoryName = 'Content'; | ||
column.categoryKey = 'content'; | ||
}); | ||
|
||
export default hostsIndexColumnExtensions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters