mirror of
https://github.com/ansible/awx.git
synced 2026-01-24 07:51:23 -03:30
Only render subform if cred type inputs.fields exists. This fixes a bug where an error was thrown when a custom credential type without an input configuration existed in the database.
This commit is contained in:
parent
7fefea31c0
commit
d5578d9744
@ -26,9 +26,9 @@ function CredentialAdd({ me }) {
|
||||
} = useRequest(
|
||||
useCallback(
|
||||
async (values, credentialTypesMap) => {
|
||||
const {
|
||||
inputs: { fields: possibleFields },
|
||||
} = credentialTypesMap[values.credential_type];
|
||||
const { inputs: credentialTypeInputs } = credentialTypesMap[
|
||||
values.credential_type
|
||||
];
|
||||
|
||||
const {
|
||||
inputs,
|
||||
@ -39,6 +39,7 @@ function CredentialAdd({ me }) {
|
||||
|
||||
const nonPluginInputs = {};
|
||||
const pluginInputs = {};
|
||||
const possibleFields = credentialTypeInputs.fields || [];
|
||||
|
||||
possibleFields.forEach(field => {
|
||||
const input = inputs[field.id];
|
||||
|
||||
@ -22,9 +22,9 @@ function CredentialEdit({ credential, me }) {
|
||||
const { error: submitError, request: submitRequest, result } = useRequest(
|
||||
useCallback(
|
||||
async (values, credentialTypesMap, inputSourceMap) => {
|
||||
const {
|
||||
inputs: { fields: possibleFields },
|
||||
} = credentialTypesMap[values.credential_type];
|
||||
const { inputs: credentialTypeInputs } = credentialTypesMap[
|
||||
values.credential_type
|
||||
];
|
||||
|
||||
const {
|
||||
inputs,
|
||||
@ -35,6 +35,7 @@ function CredentialEdit({ credential, me }) {
|
||||
|
||||
const nonPluginInputs = {};
|
||||
const pluginInputs = {};
|
||||
const possibleFields = credentialTypeInputs.fields || [];
|
||||
|
||||
possibleFields.forEach(field => {
|
||||
const input = inputs[field.id];
|
||||
|
||||
@ -35,7 +35,8 @@ function CredentialFormFields({
|
||||
.sort((a, b) => (a.label > b.label ? 1 : -1));
|
||||
|
||||
const resetSubFormFields = (newCredentialType, form) => {
|
||||
credentialTypes[newCredentialType].inputs.fields.forEach(
|
||||
const fields = credentialTypes[newCredentialType].inputs.fields || [];
|
||||
fields.forEach(
|
||||
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
||||
if (
|
||||
parseInt(newCredentialType, 10) === form.initialValues.credential_type
|
||||
@ -124,11 +125,13 @@ function CredentialFormFields({
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
{credTypeField.value !== undefined && credTypeField.value !== '' && (
|
||||
<TypeInputsSubForm
|
||||
credentialType={credentialTypes[credTypeField.value]}
|
||||
/>
|
||||
)}
|
||||
{credTypeField.value !== undefined &&
|
||||
credTypeField.value !== '' &&
|
||||
credentialTypes[credTypeField.value]?.inputs?.fields && (
|
||||
<TypeInputsSubForm
|
||||
credentialType={credentialTypes[credTypeField.value]}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@ -152,7 +155,8 @@ function CredentialForm({
|
||||
};
|
||||
|
||||
Object.values(credentialTypes).forEach(credentialType => {
|
||||
credentialType.inputs.fields.forEach(
|
||||
const fields = credentialType.inputs.fields || [];
|
||||
fields.forEach(
|
||||
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
||||
if (credential?.inputs && credential.inputs[id]) {
|
||||
if (ask_at_runtime) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user