mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Add cache timeout and inventory file validation
This commit is contained in:
@@ -38,9 +38,9 @@ const SCMSubForm = ({ i18n }) => {
|
|||||||
|
|
||||||
const handleProjectUpdate = useCallback(
|
const handleProjectUpdate = useCallback(
|
||||||
value => {
|
value => {
|
||||||
|
sourcePathHelpers.setValue('');
|
||||||
projectHelpers.setValue(value);
|
projectHelpers.setValue(value);
|
||||||
fetchSourcePath(value.id);
|
fetchSourcePath(value.id);
|
||||||
sourcePathHelpers.setValue('');
|
|
||||||
},
|
},
|
||||||
[] // eslint-disable-line react-hooks/exhaustive-deps
|
[] // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
);
|
);
|
||||||
@@ -67,9 +67,8 @@ const SCMSubForm = ({ i18n }) => {
|
|||||||
fieldId="source_path"
|
fieldId="source_path"
|
||||||
helperTextInvalid={sourcePathError?.message || sourcePathMeta.error}
|
helperTextInvalid={sourcePathError?.message || sourcePathMeta.error}
|
||||||
isValid={
|
isValid={
|
||||||
!sourcePathError?.message ||
|
(!sourcePathMeta.error || !sourcePathMeta.touched) &&
|
||||||
!sourcePathMeta.error ||
|
!sourcePathError?.message
|
||||||
!sourcePathMeta.touched
|
|
||||||
}
|
}
|
||||||
isRequired
|
isRequired
|
||||||
label={i18n._(t`Inventory file`)}
|
label={i18n._(t`Inventory file`)}
|
||||||
@@ -82,7 +81,10 @@ const SCMSubForm = ({ i18n }) => {
|
|||||||
<AnsibleSelect
|
<AnsibleSelect
|
||||||
{...sourcePathField}
|
{...sourcePathField}
|
||||||
id="source_path"
|
id="source_path"
|
||||||
isValid={!sourcePathMeta.touched || !sourcePathMeta.error}
|
isValid={
|
||||||
|
(!sourcePathMeta.error || !sourcePathMeta.touched) &&
|
||||||
|
!sourcePathError?.message
|
||||||
|
}
|
||||||
data={[
|
data={[
|
||||||
{
|
{
|
||||||
value: '',
|
value: '',
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
|
import { minMaxValue } from '@util/validators';
|
||||||
import { FormGroup } from '@patternfly/react-core';
|
import { FormGroup } from '@patternfly/react-core';
|
||||||
import AnsibleSelect from '@components/AnsibleSelect';
|
import AnsibleSelect from '@components/AnsibleSelect';
|
||||||
import { VariablesField } from '@components/CodeMirrorInput';
|
import { VariablesField } from '@components/CodeMirrorInput';
|
||||||
@@ -36,7 +37,7 @@ export const VerbosityField = withI18n()(({ i18n }) => {
|
|||||||
label={i18n._(t`Verbosity`)}
|
label={i18n._(t`Verbosity`)}
|
||||||
>
|
>
|
||||||
<FieldTooltip
|
<FieldTooltip
|
||||||
content={i18n._(t`Control the level of output ansible
|
content={i18n._(t`Control the level of output Ansible
|
||||||
will produce for inventory source update jobs.`)}
|
will produce for inventory source update jobs.`)}
|
||||||
/>
|
/>
|
||||||
<AnsibleSelect
|
<AnsibleSelect
|
||||||
@@ -51,6 +52,14 @@ export const VerbosityField = withI18n()(({ i18n }) => {
|
|||||||
|
|
||||||
export const OptionsField = withI18n()(({ i18n }) => {
|
export const OptionsField = withI18n()(({ i18n }) => {
|
||||||
const [updateOnLaunchField] = useField('update_on_launch');
|
const [updateOnLaunchField] = useField('update_on_launch');
|
||||||
|
const [, , updateCacheTimeoutHelper] = useField('update_cache_timeout');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!updateOnLaunchField.value) {
|
||||||
|
updateCacheTimeoutHelper.setValue(0);
|
||||||
|
}
|
||||||
|
}, [updateOnLaunchField.value]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormFullWidthLayout>
|
<FormFullWidthLayout>
|
||||||
@@ -123,6 +132,8 @@ export const OptionsField = withI18n()(({ i18n }) => {
|
|||||||
name="update_cache_timeout"
|
name="update_cache_timeout"
|
||||||
type="number"
|
type="number"
|
||||||
min="0"
|
min="0"
|
||||||
|
max="2147483647"
|
||||||
|
validate={minMaxValue(0, 2147483647, i18n)}
|
||||||
label={i18n._(t`Cache timeout (seconds)`)}
|
label={i18n._(t`Cache timeout (seconds)`)}
|
||||||
tooltip={i18n._(t`Time in seconds to consider an inventory sync
|
tooltip={i18n._(t`Time in seconds to consider an inventory sync
|
||||||
to be current. During job runs and callbacks the task system will
|
to be current. During job runs and callbacks the task system will
|
||||||
|
|||||||
Reference in New Issue
Block a user