import React from 'react'; import PropTypes from 'prop-types'; import { translate as __ } from 'foremanReact/common/I18n'; import { usePaginationOptions } from 'foremanReact/components/Pagination/PaginationHooks'; import RelativeDateTime from 'foremanReact/components/common/dates/RelativeDateTime'; import { TableComposable, Thead, Tbody, Tr, Th, Td, } from '@patternfly/react-table'; import { Flex, FlexItem, Pagination } from '@patternfly/react-core'; import { decodeId } from '../../../../globalIdHelper'; import withLoading from '../../../withLoading'; import { readableCron, readablePurpose } from './JobsTabHelper'; import { preparePerPageOptions, refreshPage, } from '../../../../helpers/paginationHelper'; const PreviousJobsTable = ({ history, totalCount, jobs, pagination }) => { const columns = [ __('Description'), __('Result'), __('State'), __('Executed at'), __('Schedule'), ]; const handlePerPageSelected = (event, perPage) => { refreshPage(history, { page: 1, perPage }); }; const handlePageSelected = (event, page) => { refreshPage(history, { ...pagination, page }); }; const perPageOptions = preparePerPageOptions(usePaginationOptions()); return (

{__('Previously executed jobs')}

{columns.map(col => ( {col} ))} {jobs.map(job => ( window.tfm.nav.pushUrl( `/job_invocations/${decodeId(job.id)}` ) } > {job.description}   {readablePurpose(job.recurringLogic.purpose)} {job.task.result} {job.task.state} {readableCron(job.recurringLogic.cronLine)} ))}
); }; PreviousJobsTable.propTypes = { jobs: PropTypes.array.isRequired, history: PropTypes.object.isRequired, totalCount: PropTypes.number.isRequired, pagination: PropTypes.object.isRequired, }; export default withLoading(PreviousJobsTable);