import React, { useCallback, useState } from 'react'; import { useSelector } from 'react-redux'; import { Link } from 'react-router-dom'; import { translate as __ } from 'foremanReact/common/I18n'; import { urlBuilder } from 'foremanReact/common/urlHelpers'; import PropTypes from 'prop-types'; import { Grid, GridItem, Modal, ModalVariant, Button, Flex, FlexItem } from '@patternfly/react-core'; import { TableVariant, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table'; import { RegistryIcon } from '@patternfly/react-icons'; import TableWrapper from '../../../components/Table/TableWrapper'; import { getContentViewComponents } from '../Details/ContentViewDetailActions'; import { selectCVComponents, selectCVComponentsError, selectCVComponentsStatus, } from '../Details/ContentViewDetailSelectors'; const RelatedContentViewsModal = ({ cvName, cvId, relatedCVCount }) => { const response = useSelector(state => selectCVComponents(state, cvId)); const status = useSelector(state => selectCVComponentsStatus(state, cvId)); const error = useSelector(state => selectCVComponentsError(state, cvId)); const { results, ...metadata } = response; const [isOpen, setIsOpen] = useState(false); const [searchQuery, updateSearchQuery] = useState(''); const description = () => ( {` ${cvName}`} {__(' content view is used in listed content views. For more information, ')} {__('view content view tabs.')} ); const handleModalToggle = () => { setIsOpen(!isOpen); }; return ( <> {relatedCVCount} { setIsOpen(false); }} appendTo={document.body} > getContentViewComponents(cvId, params, 'Added'), [cvId])} variant={TableVariant.compact} autocompleteEndpoint="/katello/api/v2/content_views" emptyContentTitle={__('You currently don\'t have any related content views.')} emptySearchTitle={__('No matching content views found')} emptyContentBody={__('Related content views will appear here when created.')} emptySearchBody={__('Try changing your search settings.')} > {__('Name')} {results?.map(details => ( {details.content_view.name} )) } > ); }; export default RelatedContentViewsModal; RelatedContentViewsModal.propTypes = { cvName: PropTypes.string.isRequired, cvId: PropTypes.number.isRequired, relatedCVCount: PropTypes.number.isRequired, };