import React from 'react'; import PropTypes from 'prop-types'; import { Formik, Field as FormikField } from 'formik'; import { useMutation } from '@apollo/client'; import { translate as __ } from 'foremanReact/common/I18n'; import { Modal, Button, ModalVariant, Spinner, Form as PfForm, } from '@patternfly/react-core'; import { onSubmit, createValidationSchema, frequencyOpts, rangeValidator, } from './NewRecurringJobHelper'; import { DatePickerField, TimePickerField, SelectField, } from '../../../../formHelper'; import './NewRecurringJobModal.scss'; import { scheduledJobsSearch } from './JobsTabHelper'; import createJobInvocation from '../../../../graphql/mutations/createJobInvocation.gql'; import jobsQuery from '../../../../graphql/queries/recurringJobs.gql'; const NewRecurringJobModal = props => { const { onClose, resourceId, resourceName } = props; const [callMutation] = useMutation(createJobInvocation, { refetchQueries: [ { query: jobsQuery, variables: { search: scheduledJobsSearch(resourceName, resourceId) }, }, ], }); return ( {formProps => { const actions = [ , , ]; if (formProps.isSubmitting) { actions.push(); } return ( ); }} ); }; NewRecurringJobModal.propTypes = { onClose: PropTypes.func.isRequired, resourceId: PropTypes.number.isRequired, resourceName: PropTypes.string.isRequired, isOpen: PropTypes.bool.isRequired, }; export default NewRecurringJobModal;