Merge pull request #8282 from marshmalien/8044-inventory-file-bug

Fix inventory file dropdown placeholder value

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-10-02 20:35:08 +00:00 committed by GitHub
commit bd224a75db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -47,6 +47,7 @@ const InventorySourceFormFields = ({ source, sourceOptions, i18n }) => {
values,
initialValues,
resetForm,
setFieldTouched,
setFieldValue,
} = useFormikContext();
const [sourceField, sourceMeta] = useField({
@ -92,6 +93,7 @@ const InventorySourceFormFields = ({ source, sourceOptions, i18n }) => {
};
Object.keys(defaults).forEach(label => {
setFieldValue(label, defaults[label]);
setFieldTouched(label, false);
});
}
};
@ -255,7 +257,7 @@ const InventorySourceForm = ({
overwrite: source?.overwrite || false,
overwrite_vars: source?.overwrite_vars || false,
source: source?.source || '',
source_path: source?.source_path === '' ? '/ (project root)' : '',
source_path: source?.source_path || '',
source_project: source?.summary_fields?.source_project || null,
source_script: source?.summary_fields?.source_script || null,
source_vars: source?.source_vars || '---\n',

View File

@ -21,7 +21,7 @@ import {
} from './SharedFields';
const SCMSubForm = ({ autoPopulateProject, i18n }) => {
const { setFieldValue } = useFormikContext();
const { setFieldValue, setFieldTouched } = useFormikContext();
const [credentialField] = useField('credential');
const [projectField, projectMeta, projectHelpers] = useField({
name: 'source_project',
@ -47,16 +47,20 @@ const SCMSubForm = ({ autoPopulateProject, i18n }) => {
useEffect(() => {
if (projectMeta.initialValue) {
fetchSourcePath(projectMeta.initialValue.id);
}
if (sourcePathField.value === '') {
sourcePathHelpers.setValue('/ (project root)');
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetchSourcePath, projectMeta.initialValue]);
const handleProjectUpdate = useCallback(
value => {
setFieldValue('source_path', '');
setFieldValue('source_project', value);
setFieldValue('source_path', '');
setFieldTouched('source_path', false);
fetchSourcePath(value.id);
},
[fetchSourcePath, setFieldValue]
[fetchSourcePath, setFieldValue, setFieldTouched]
);
const handleCredentialUpdate = useCallback(