import React from 'react'; import PropTypes from 'prop-types'; import { Form, FormGroup, Radio, Divider } from '@patternfly/react-core'; import { translate as __ } from 'foremanReact/common/I18n'; import { WIZARD_TITLES, SCHEDULE_TYPES, repeatTypes, } from '../../JobWizardConstants'; import { WizardTitle } from '../form/WizardTitle'; import { QueryType } from './QueryType'; export const ScheduleType = ({ scheduleType, isTypeStatic, setScheduleValue, setValid, }) => (
{ setScheduleValue(current => ({ ...current, scheduleType: SCHEDULE_TYPES.NOW, repeatType: repeatTypes.noRepeat, startsAt: null, startsBefore: null, })); setValid(true); }} label={__('Immediate execution')} body={__('Execute the job now.')} /> { setScheduleValue(current => ({ ...current, startsAt: new Date().toISOString(), scheduleType: SCHEDULE_TYPES.FUTURE, repeatType: repeatTypes.noRepeat, })); setValid(true); }} name="schedule-type-future" id="schedule-type-future" label={__('Future execution')} body={__('Execute the job later, at a scheduled time.')} /> { setScheduleValue(current => ({ ...current, scheduleType: SCHEDULE_TYPES.RECURRING, repeatType: repeatTypes.daily, repeatData: { at: '12:00' }, })); setValid(true); }} name="schedule-type-recurring" id="schedule-type-recurring" label={__('Recurring execution')} body={__('Execute the job on a repeating schedule.')} /> { setScheduleValue(current => ({ ...current, isTypeStatic: newValue })); }} />
); ScheduleType.propTypes = { isTypeStatic: PropTypes.bool.isRequired, scheduleType: PropTypes.string.isRequired, setScheduleValue: PropTypes.func.isRequired, setValid: PropTypes.func.isRequired, };