/* eslint-disable camelcase */ import PropTypes from 'prop-types'; import React from 'react'; import Skeleton from 'react-loading-skeleton'; import ElipsisWithTooltip from 'react-ellipsis-with-tooltip'; import { Grid, GridItem } from '@patternfly/react-core'; import { OkIcon, ErrorCircleOIcon, } from '@patternfly/react-icons/dist/js/icons'; import { PropertiesSidePanel, PropertyItem, } from '@patternfly/react-catalog-view-extension'; import { ArrowIcon } from '@patternfly/react-icons'; import { useAPI } from 'foremanReact/common/hooks/API/APIHooks'; import CardItem from 'foremanReact/components/HostDetails/Templates/CardItem/CardTemplate'; import RelativeDateTime from 'foremanReact/components/common/dates/RelativeDateTime'; import { translate as __ } from 'foremanReact/common/I18n'; import './styles.css'; const RecentJobsCard = ({ hostDetails: { name } }) => { const jobsUrl = name && `/api/job_invocations?search=host%3D${name}&per_page=3`; const { response: { results: jobs }, } = useAPI('get', jobsUrl); const iconMarkup = status => { if (status === 1) return ; return ; }; return ( {__('Recent Jobs')}{' '} } > {jobs?.map(({ status, status_label, id, start_at, description }) => ( {description} {iconMarkup(status)} {status_label} ) : ( ) } value={ start_at ? ( ) : ( ) } /> ))} ); }; export default RecentJobsCard; RecentJobsCard.propTypes = { hostDetails: PropTypes.shape({ name: PropTypes.string, }).isRequired, };