mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 21:21:21 -03:30
Fix JT form edit save bug when inventory has no value
This commit is contained in:
parent
e17ff3e03a
commit
53c8c80f7f
@ -57,7 +57,7 @@ function Template({ i18n, me, setBreadcrumb }) {
|
||||
);
|
||||
useEffect(() => {
|
||||
loadTemplateAndRoles();
|
||||
}, [loadTemplateAndRoles]);
|
||||
}, [loadTemplateAndRoles, location.pathname]);
|
||||
|
||||
const loadScheduleOptions = () => {
|
||||
return JobTemplatesAPI.readScheduleOptions(templateId);
|
||||
|
||||
@ -109,12 +109,15 @@ function JobTemplateForm({
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const handleProjectUpdate = newProject => {
|
||||
setProject(newProject);
|
||||
setFieldValue('project', newProject.id);
|
||||
setFieldValue('playbook', 0);
|
||||
setFieldValue('scm_branch', '');
|
||||
};
|
||||
const handleProjectUpdate = useCallback(
|
||||
newProject => {
|
||||
setProject(newProject);
|
||||
setFieldValue('project', newProject.id);
|
||||
setFieldValue('playbook', 0);
|
||||
setFieldValue('scm_branch', '');
|
||||
},
|
||||
[setFieldValue, setProject]
|
||||
);
|
||||
|
||||
const jobTypeOptions = [
|
||||
{
|
||||
@ -245,7 +248,7 @@ function JobTemplateForm({
|
||||
)}
|
||||
</Field>
|
||||
</FieldWithPrompt>
|
||||
<Field name="project" validate={() => handleProjectValidation()}>
|
||||
<Field name="project" validate={handleProjectValidation}>
|
||||
{({ form }) => (
|
||||
<ProjectLookup
|
||||
value={project}
|
||||
@ -631,9 +634,11 @@ const FormikApp = withFormik({
|
||||
inventory: { organization: null },
|
||||
},
|
||||
} = template;
|
||||
|
||||
const hasInventory = summary_fields.inventory
|
||||
? summary_fields.inventory.organization_id
|
||||
: null;
|
||||
|
||||
return {
|
||||
ask_credential_on_launch: template.ask_credential_on_launch || false,
|
||||
ask_diff_mode_on_launch: template.ask_diff_mode_on_launch || false,
|
||||
@ -648,7 +653,7 @@ const FormikApp = withFormik({
|
||||
name: template.name || '',
|
||||
description: template.description || '',
|
||||
job_type: template.job_type || 'run',
|
||||
inventory: template.inventory || '',
|
||||
inventory: template.inventory || null,
|
||||
project: template.project || '',
|
||||
scm_branch: template.scm_branch || '',
|
||||
playbook: template.playbook || '',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user