mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
correct form submission errors for credential form
This commit is contained in:
parent
3d7420959e
commit
16e672dd38
@ -12,6 +12,7 @@ function CredentialAdd({ me }) {
|
||||
const [error, setError] = useState(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [credentialTypes, setCredentialTypes] = useState(null);
|
||||
const [formSubmitError, setFormSubmitError] = useState(null);
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
@ -36,6 +37,7 @@ function CredentialAdd({ me }) {
|
||||
|
||||
const handleSubmit = async values => {
|
||||
const { organization, ...remainingValues } = values;
|
||||
setFormSubmitError(null);
|
||||
try {
|
||||
const {
|
||||
data: { id: credentialId },
|
||||
@ -47,7 +49,7 @@ function CredentialAdd({ me }) {
|
||||
const url = `/credentials/${credentialId}/details`;
|
||||
history.push(`${url}`);
|
||||
} catch (err) {
|
||||
setError(err);
|
||||
setFormSubmitError(err);
|
||||
}
|
||||
};
|
||||
|
||||
@ -73,6 +75,7 @@ function CredentialAdd({ me }) {
|
||||
onCancel={handleCancel}
|
||||
onSubmit={handleSubmit}
|
||||
credentialTypes={credentialTypes}
|
||||
submitError={formSubmitError}
|
||||
/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
@ -12,6 +12,7 @@ function CredentialEdit({ credential, me }) {
|
||||
const [error, setError] = useState(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [credentialTypes, setCredentialTypes] = useState(null);
|
||||
const [formSubmitError, setFormSubmitError] = useState(null);
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
@ -38,6 +39,7 @@ function CredentialEdit({ credential, me }) {
|
||||
|
||||
const handleSubmit = async values => {
|
||||
const { organization, ...remainingValues } = values;
|
||||
setFormSubmitError(null);
|
||||
try {
|
||||
const {
|
||||
data: { id: credentialId },
|
||||
@ -49,7 +51,7 @@ function CredentialEdit({ credential, me }) {
|
||||
const url = `/credentials/${credentialId}/details`;
|
||||
history.push(`${url}`);
|
||||
} catch (err) {
|
||||
setError(err);
|
||||
setFormSubmitError(err);
|
||||
}
|
||||
};
|
||||
|
||||
@ -68,6 +70,7 @@ function CredentialEdit({ credential, me }) {
|
||||
onSubmit={handleSubmit}
|
||||
credential={credential}
|
||||
credentialTypes={credentialTypes}
|
||||
submitError={formSubmitError}
|
||||
/>
|
||||
</CardBody>
|
||||
);
|
||||
|
||||
@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { func, shape } from 'prop-types';
|
||||
import { Form, FormGroup, Title } from '@patternfly/react-core';
|
||||
import FormField from '@components/FormField';
|
||||
import FormField, { FormSubmitError } from '@components/FormField';
|
||||
import FormActionGroup from '@components/FormActionGroup/FormActionGroup';
|
||||
import AnsibleSelect from '@components/AnsibleSelect';
|
||||
import { required } from '@util/validators';
|
||||
@ -118,6 +118,7 @@ function CredentialForm({
|
||||
credentialTypes,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
submitError,
|
||||
...rest
|
||||
}) {
|
||||
const initialValues = {
|
||||
@ -193,6 +194,7 @@ function CredentialForm({
|
||||
sshCredentialTypeId={sshCredentialTypeId}
|
||||
{...rest}
|
||||
/>
|
||||
<FormSubmitError error={submitError} />
|
||||
<FormActionGroup
|
||||
onCancel={onCancel}
|
||||
onSubmit={formik.handleSubmit}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user