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 #36862 - Added the slot fill for hosts index #10771

Merged
merged 1 commit into from
Oct 28, 2023
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
40 changes: 40 additions & 0 deletions webpack/components/extensions/Hosts/ActionsBar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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 (
<>
<DropdownItem
ouiaId="change-content-s-dropdown-item"
key="change-content-source-dropdown-item"
title={title}
href={href}
isDisabled={selectedCount === 0}
icon={<CubeIcon />}
>
{title}
</DropdownItem>
</>
);
};

export default HostActionsBar;
2 changes: 2 additions & 0 deletions webpack/components/extensions/Hosts/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const HOSTS_INDEX = 'HOSTS';
export default HOSTS_INDEX;
13 changes: 11 additions & 2 deletions webpack/global_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -67,7 +68,15 @@ addGlobalFill('host-details-tab-properties-3', 'Virtualization', <SystemProperti
addGlobalFill(
'host-details-kebab',
'katello-host-details-kebab',
<HostActionsBar key="katello-host-details-kebab" />,
<HostDetailsActionsBar key="katello-host-details-kebab" />,
100,
);

addGlobalFill(
'hosts-index-kebab',
'katello-hosts-index-kebab',
<HostsIndexActionsBar key="katello-hosts-index-kebab" />,
100,
);

addGlobalFill('host-tab-details-cards', 'HW properties', <HwPropertiesCard key="hw-properties" />, 200);
5 changes: 3 additions & 2 deletions webpack/scenes/Hosts/ChangeContentSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]);
Expand Down
Loading