Skip to content

Commit

Permalink
throw error if resources are missing in schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
jerabekjiri committed Jun 20, 2024
1 parent 83906c3 commit 5f674b8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions frontend/awx/views/schedules/wizard/ScheduleAddWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { RESOURCE_TYPE } from '../../../resources/templates/WorkflowVisualizer/c
import { useProcessSchedule } from '../hooks/useProcessSchedules';
import { useNavigate } from 'react-router-dom';
import { Schedule } from '../../../interfaces/Schedule';
import { JobTemplate } from '../../../interfaces/JobTemplate';
import { WorkflowJobTemplate } from '../../../interfaces/WorkflowJobTemplate';
import { RequestError } from '../../../../common/crud/RequestError';
import { RULES_DEFAULT_VALUES } from './constants';
import { ScheduleReviewStep } from './ScheduleReviewStep';
Expand Down Expand Up @@ -74,6 +76,21 @@ export function ScheduleAddWizard() {
id: 'details',
label: t('Details'),
inputs: <ScheduleSelectStep />,
validate: (formData: Partial<ScheduleFormWizard>) => {
const resource = formData.resource as JobTemplate | WorkflowJobTemplate;
const { inventory, project, organization } = resource.summary_fields;

if (
(resource?.type === 'job_template' && (!inventory || !project || !organization)) ||
(resource?.type === 'workflow_job_template' && (!inventory || !organization))
) {
const errors = {
__all__: [t('Resources are missing from this template.')],
};

throw new RequestError('', '', 400, '', errors);
}
},
},
{
id: 'nodePromptsStep',
Expand Down

0 comments on commit 5f674b8

Please sign in to comment.