Merge pull request #6368 from marshmalien/fix-jt-bugs

Fix job template form bugs r/t saving without an inventory

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-03-23 14:08:32 +00:00
committed by GitHub
2 changed files with 14 additions and 9 deletions

View File

@@ -57,7 +57,7 @@ function Template({ i18n, me, setBreadcrumb }) {
);
useEffect(() => {
loadTemplateAndRoles();
}, [loadTemplateAndRoles]);
}, [loadTemplateAndRoles, location.pathname]);
const loadScheduleOptions = () => {
return JobTemplatesAPI.readScheduleOptions(templateId);

View File

@@ -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}
@@ -632,9 +635,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,
@@ -649,7 +654,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 || '',