import React from 'react'; import PropTypes from 'prop-types'; import URI from 'urijs'; import { Alert, Divider, Skeleton, Button } from '@patternfly/react-core'; import { sprintf, translate as __ } from 'foremanReact/common/I18n'; import { useAPI } from 'foremanReact/common/hooks/API/APIHooks'; import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout'; import { STATUS } from 'foremanReact/constants'; import { useForemanOrganization, useForemanLocation, } from 'foremanReact/Root/Context/ForemanContext'; import { JobWizard } from './JobWizard'; import { JOB_API_KEY } from './JobWizardConstants'; const JobWizardPageRerun = ({ match: { params: { id }, }, location: { search }, }) => { const uri = new URI(search); const { failed_only: failedOnly } = uri.search(true); const { response, status } = useAPI( 'get', `/ui_job_wizard/job_invocation?id=${id}${ failedOnly ? '&failed_only=1' : '' }`, JOB_API_KEY ); const title = __('Run job'); const breadcrumbOptions = { breadcrumbItems: [ { caption: __('Jobs'), url: `/job_invocations` }, { caption: title }, ], }; const jobOrganization = response.job_organization; const jobLocation = response.job_location; const currentOrganization = useForemanOrganization(); const currentLocation = useForemanLocation(); return ( {__('Use old form')} } > {!status || status === STATUS.PENDING ? (
) : ( {jobOrganization?.id !== currentOrganization?.id && ( )} {jobLocation?.id !== currentLocation?.id && ( )} )}
); }; JobWizardPageRerun.propTypes = { match: PropTypes.shape({ params: PropTypes.shape({ id: PropTypes.string.isRequired, }), }).isRequired, location: PropTypes.shape({ search: PropTypes.string, }), }; JobWizardPageRerun.defaultProps = { location: { search: '' }, }; export default JobWizardPageRerun;