import React from 'react'; import PropTypes from 'prop-types'; import { translate as __ } from 'foremanReact/common/I18n'; import { Route, Link } from 'react-router-dom'; import Pagination from 'foremanReact/components/Pagination'; import { TableComposable, Thead, Tbody, Tr, Th, Td, } from '@patternfly/react-table'; import { Flex, FlexItem, Button } from '@patternfly/react-core'; import EditRolesModal from './EditRolesModal'; import withLoading from '../../../withLoading'; import AllRolesModal from './AllRolesModal'; const RolesTable = ({ totalCount, history, ansibleRoles, hostId, hostGlobalId, canEditHost, }) => { const columns = [__('Name'), __('Variables')]; const editBtn = canEditHost ? ( {__('Edit Ansible roles')} ) : null; return ( {__('Ansible roles assigned directly to host')} {' - '} {__('view all assigned roles')} {editBtn} {columns.map(col => ( {col} ))} {ansibleRoles.map(role => ( {role.name} {role.ansibleVariables.totalCount} ))} history.goBack()} isOpen assignedRoles={ansibleRoles} hostId={hostId} canEditHost={canEditHost} /> history.push('/Ansible/roles')} isOpen hostGlobalId={hostGlobalId} history={history} /> ); }; RolesTable.propTypes = { ansibleRoles: PropTypes.array.isRequired, hostId: PropTypes.number.isRequired, hostGlobalId: PropTypes.string.isRequired, history: PropTypes.object.isRequired, totalCount: PropTypes.number.isRequired, canEditHost: PropTypes.bool.isRequired, }; export default withLoading(RolesTable);