mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Fixes bug where cred password fiield was displaying ASK
This commit is contained in:
parent
29d57ea403
commit
f4bc69d5f7
@ -245,37 +245,42 @@ function CredentialForm({
|
||||
};
|
||||
|
||||
Object.values(credentialTypes).forEach(credentialType => {
|
||||
const fields = credentialType.inputs.fields || [];
|
||||
fields.forEach(
|
||||
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
||||
if (credential?.inputs && id in credential.inputs) {
|
||||
if (ask_at_runtime) {
|
||||
initialValues.passwordPrompts[id] =
|
||||
credential.inputs[id] === 'ASK' || false;
|
||||
}
|
||||
initialValues.inputs[id] = credential.inputs[id];
|
||||
} else {
|
||||
switch (type) {
|
||||
case 'string':
|
||||
initialValues.inputs[id] = defaultValue || '';
|
||||
break;
|
||||
case 'boolean':
|
||||
initialValues.inputs[id] = defaultValue || false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!credential.id || credential.credential_type === credentialType.id) {
|
||||
const fields = credentialType.inputs.fields || [];
|
||||
fields.forEach(
|
||||
({ ask_at_runtime, type, id, choices, default: defaultValue }) => {
|
||||
if (credential?.inputs && id in credential.inputs) {
|
||||
if (ask_at_runtime) {
|
||||
initialValues.passwordPrompts[id] =
|
||||
credential.inputs[id] === 'ASK' || false;
|
||||
initialValues.inputs[id] =
|
||||
credential.inputs[id] === 'ASK' ? '' : credential.inputs[id];
|
||||
} else {
|
||||
initialValues.inputs[id] = credential.inputs[id];
|
||||
}
|
||||
} else {
|
||||
switch (type) {
|
||||
case 'string':
|
||||
initialValues.inputs[id] = defaultValue || '';
|
||||
break;
|
||||
case 'boolean':
|
||||
initialValues.inputs[id] = defaultValue || false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (choices) {
|
||||
initialValues.inputs[id] = defaultValue;
|
||||
}
|
||||
if (choices) {
|
||||
initialValues.inputs[id] = defaultValue;
|
||||
}
|
||||
|
||||
if (ask_at_runtime) {
|
||||
initialValues.passwordPrompts[id] = false;
|
||||
if (ask_at_runtime) {
|
||||
initialValues.passwordPrompts[id] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Object.values(inputSources).forEach(inputSource => {
|
||||
|
||||
@ -30,13 +30,15 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
|
||||
const [fileName, setFileName] = useState('');
|
||||
const [fileIsUploading, setFileIsUploading] = useState(false);
|
||||
const [subFormField, meta, helpers] = useField(`inputs.${fieldOptions.id}`);
|
||||
const [passwordPromptsField] = useField(`passwordPrompts.${fieldOptions.id}`);
|
||||
const isValid = !(meta.touched && meta.error);
|
||||
|
||||
const RevertReplaceButton = (
|
||||
<>
|
||||
{meta.initialValue &&
|
||||
meta.initialValue !== '' &&
|
||||
!meta.initialValue.credential && (
|
||||
!meta.initialValue.credential &&
|
||||
!passwordPromptsField.value && (
|
||||
<Tooltip
|
||||
id={`credential-${fieldOptions.id}-replace-tooltip`}
|
||||
content={meta.value !== meta.initialValue ? t`Revert` : t`Replace`}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user