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