import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import SearchBar from 'foremanReact/components/SearchBar';
import { translate as __ } from 'foremanReact/common/I18n';
import {
Grid,
GridItem,
Dropdown,
DropdownItem,
KebabToggle,
} from '@patternfly/react-core';
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
import InsightsTable from '../InsightsCloudSync/Components/InsightsTable';
import RemediationModal from '../InsightsCloudSync/Components/RemediationModal';
import Pagination from '../InsightsCloudSync/Components/InsightsTable/Pagination';
import { INSIGHTS_SEARCH_PROPS } from '../InsightsCloudSync/InsightsCloudSyncConstants';
import { fetchInsights } from '../InsightsCloudSync/Components/InsightsTable/InsightsTableActions';
import {
selectSearch,
selectHits,
} from '../InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors';
import './InsightsTab.scss';
import { redHatAdvisorSystems } from '../InsightsCloudSync/InsightsCloudSyncHelpers';
const NewHostDetailsTab = ({ hostName, router }) => {
const dispatch = useDispatch();
const query = useSelector(selectSearch);
const hits = useSelector(selectHits);
useEffect(() => () => router.replace({ search: null }), [router]);
const onSearch = q => dispatch(fetchInsights({ query: q, page: 1 }));
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const onSatInsightsClick = () =>
router.push({ pathname: '/foreman_rh_cloud/insights_cloud' });
const dropdownItems = [
{__('Go to Satellite Insights page')}
,
];
if (hits.length) {
const { host_uuid: uuid } = hits[0];
dropdownItems.push(
{__('View in Red Hat Insights')}
{' '}
);
}
return (
setIsDropdownOpen(false)}
toggle={
setIsDropdownOpen(isOpen)} />
}
isOpen={isDropdownOpen}
isPlain
dropdownItems={dropdownItems}
/>
);
};
NewHostDetailsTab.propTypes = {
hostName: PropTypes.string,
router: PropTypes.object,
};
NewHostDetailsTab.defaultProps = {
hostName: '',
router: {},
};
export default NewHostDetailsTab;