From 81b29750f04382af8da44ad7a7469ea074f52bfa Mon Sep 17 00:00:00 2001 From: Partha Aji Date: Wed, 18 Oct 2023 16:24:42 -0400 Subject: [PATCH] Refs #36822 - Added the slot fill for hosts index --- .../extensions/Hosts/ActionsBar/index.js | 39 +++++++++++++++++++ .../components/extensions/Hosts/constants.js | 2 + webpack/global_index.js | 13 ++++++- .../scenes/Hosts/ChangeContentSource/index.js | 5 ++- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 webpack/components/extensions/Hosts/ActionsBar/index.js create mode 100644 webpack/components/extensions/Hosts/constants.js diff --git a/webpack/components/extensions/Hosts/ActionsBar/index.js b/webpack/components/extensions/Hosts/ActionsBar/index.js new file mode 100644 index 00000000000..1feeb9b1354 --- /dev/null +++ b/webpack/components/extensions/Hosts/ActionsBar/index.js @@ -0,0 +1,39 @@ +import React, { useContext } from 'react'; +import { DropdownItem } from '@patternfly/react-core'; +import { CubeIcon } from '@patternfly/react-icons'; +import { translate as __ } from 'foremanReact/common/I18n'; +import { foremanUrl } from 'foremanReact/common/helpers'; +import { ForemanHostsIndexActionsBarContext } from 'foremanReact/components/HostsIndex'; + +const HostActionsBar = () => { + const { + fetchBulkParams, + selectedCount, + selectAllMode, + } = useContext(ForemanHostsIndexActionsBarContext); + + let href = ''; + if (selectAllMode) { + const query = fetchBulkParams({ selectAllQuery: 'created_at < "1 second ago"' }); + href = foremanUrl(`/change_host_content_source?search=${query}`); + } else if (selectedCount > 0) { + href = foremanUrl(`/change_host_content_source?search=${fetchBulkParams({})}`); + } + + const title = __('Change content source'); + return ( + <> + + {title} + + + ); +}; + +export default HostActionsBar; diff --git a/webpack/components/extensions/Hosts/constants.js b/webpack/components/extensions/Hosts/constants.js new file mode 100644 index 00000000000..6a2d1d94ae4 --- /dev/null +++ b/webpack/components/extensions/Hosts/constants.js @@ -0,0 +1,2 @@ +const HOSTS_INDEX = 'HOSTS'; +export default HOSTS_INDEX; diff --git a/webpack/global_index.js b/webpack/global_index.js index 958b2932cfa..f90d05c0362 100644 --- a/webpack/global_index.js +++ b/webpack/global_index.js @@ -25,7 +25,8 @@ import { SystemPropertiesCardVirtualization, SystemPropertiesCardTracer, } from './components/extensions/HostDetails/DetailsTabCards/SystemPropertiesCardExtensions'; -import HostActionsBar from './components/extensions/HostDetails/ActionsBar'; +import HostDetailsActionsBar from './components/extensions/HostDetails/ActionsBar'; +import HostsIndexActionsBar from './components/extensions/Hosts/ActionsBar'; import RecentCommunicationCardExtensions from './components/extensions/HostDetails/DetailsTabCards/RecentCommunicationCardExtensions'; import SystemPurposeCard from './components/extensions/HostDetails/Cards/SystemPurposeCard/SystemPurposeCard'; @@ -67,7 +68,15 @@ addGlobalFill('host-details-tab-properties-3', 'Virtualization', , + , 100, ); + +addGlobalFill( + 'hosts-index-kebab', + 'katello-hosts-index-kebab', + , + 100, +); + addGlobalFill('host-tab-details-cards', 'HW properties', , 200); diff --git a/webpack/scenes/Hosts/ChangeContentSource/index.js b/webpack/scenes/Hosts/ChangeContentSource/index.js index ebff1f73e70..dfbf2d5346a 100644 --- a/webpack/scenes/Hosts/ChangeContentSource/index.js +++ b/webpack/scenes/Hosts/ChangeContentSource/index.js @@ -8,6 +8,7 @@ import { foremanUrl } from 'foremanReact/common/helpers'; import { STATUS } from 'foremanReact/constants'; import BreadcrumbBar from 'foremanReact/components/BreadcrumbBar'; import Head from 'foremanReact/components/Head'; +import { useForemanHostsPageUrl } from 'foremanReact/Root/Context/ForemanContext'; import { selectApiDataStatus, selectApiContentViewStatus, @@ -96,14 +97,14 @@ const ChangeContentSourcePage = () => { setShouldShowTemplate(true); }; + const hostIndexUrl = useForemanHostsPageUrl(); const breadcrumbItems = () => { - const linkHosts = { caption: __('Hosts'), url: foremanUrl('/hosts') }; + const linkHosts = { caption: __('Hosts'), url: hostIndexUrl }; const linkContent = { caption: __('Change host content source') }; if (urlParams.host_id) { const hostName = contentHosts.concat(hostsWithoutContent) .find(h => `${h.id}` === urlParams.host_id)?.name; - return ([linkHosts, { caption: hostName, url: foremanUrl(`/new/hosts/${hostName}`) }, linkContent]); } return ([linkHosts, linkContent]);