mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02: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:
@@ -26,9 +26,9 @@ function CredentialAdd({ me }) {
|
|||||||
} = useRequest(
|
} = useRequest(
|
||||||
useCallback(
|
useCallback(
|
||||||
async (values, credentialTypesMap) => {
|
async (values, credentialTypesMap) => {
|
||||||
const {
|
const { inputs: credentialTypeInputs } = credentialTypesMap[
|
||||||
inputs: { fields: possibleFields },
|
values.credential_type
|
||||||
} = credentialTypesMap[values.credential_type];
|
];
|
||||||
|
|
||||||
const {
|
const {
|
||||||
inputs,
|
inputs,
|
||||||
@@ -39,6 +39,7 @@ function CredentialAdd({ me }) {
|
|||||||
|
|
||||||
const nonPluginInputs = {};
|
const nonPluginInputs = {};
|
||||||
const pluginInputs = {};
|
const pluginInputs = {};
|
||||||
|
const possibleFields = credentialTypeInputs.fields || [];
|
||||||
|
|
||||||
possibleFields.forEach(field => {
|
possibleFields.forEach(field => {
|
||||||
const input = inputs[field.id];
|
const input = inputs[field.id];
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ function CredentialEdit({ credential, me }) {
|
|||||||
const { error: submitError, request: submitRequest, result } = useRequest(
|
const { error: submitError, request: submitRequest, result } = useRequest(
|
||||||
useCallback(
|
useCallback(
|
||||||
async (values, credentialTypesMap, inputSourceMap) => {
|
async (values, credentialTypesMap, inputSourceMap) => {
|
||||||
const {
|
const { inputs: credentialTypeInputs } = credentialTypesMap[
|
||||||
inputs: { fields: possibleFields },
|
values.credential_type
|
||||||
} = credentialTypesMap[values.credential_type];
|
];
|
||||||
|
|
||||||
const {
|
const {
|
||||||
inputs,
|
inputs,
|
||||||
@@ -35,6 +35,7 @@ function CredentialEdit({ credential, me }) {
|
|||||||
|
|
||||||
const nonPluginInputs = {};
|
const nonPluginInputs = {};
|
||||||
const pluginInputs = {};
|
const pluginInputs = {};
|
||||||
|
const possibleFields = credentialTypeInputs.fields || [];
|
||||||
|
|
||||||
possibleFields.forEach(field => {
|
possibleFields.forEach(field => {
|
||||||
const input = inputs[field.id];
|
const input = inputs[field.id];
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ function CredentialFormFields({
|
|||||||
.sort((a, b) => (a.label > b.label ? 1 : -1));
|
.sort((a, b) => (a.label > b.label ? 1 : -1));
|
||||||
|
|
||||||
const resetSubFormFields = (newCredentialType, form) => {
|
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 }) => {
|
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
||||||
if (
|
if (
|
||||||
parseInt(newCredentialType, 10) === form.initialValues.credential_type
|
parseInt(newCredentialType, 10) === form.initialValues.credential_type
|
||||||
@@ -124,11 +125,13 @@ function CredentialFormFields({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
{credTypeField.value !== undefined && credTypeField.value !== '' && (
|
{credTypeField.value !== undefined &&
|
||||||
<TypeInputsSubForm
|
credTypeField.value !== '' &&
|
||||||
credentialType={credentialTypes[credTypeField.value]}
|
credentialTypes[credTypeField.value]?.inputs?.fields && (
|
||||||
/>
|
<TypeInputsSubForm
|
||||||
)}
|
credentialType={credentialTypes[credTypeField.value]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -152,7 +155,8 @@ function CredentialForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
Object.values(credentialTypes).forEach(credentialType => {
|
Object.values(credentialTypes).forEach(credentialType => {
|
||||||
credentialType.inputs.fields.forEach(
|
const fields = credentialType.inputs.fields || [];
|
||||||
|
fields.forEach(
|
||||||
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
||||||
if (credential?.inputs && credential.inputs[id]) {
|
if (credential?.inputs && credential.inputs[id]) {
|
||||||
if (ask_at_runtime) {
|
if (ask_at_runtime) {
|
||||||
|
|||||||
Reference in New Issue
Block a user