mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 04:47:44 -02:30
convert http headers field to string for codemirror
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
FormFullWidthLayout,
|
FormFullWidthLayout,
|
||||||
SubFormLayout,
|
SubFormLayout,
|
||||||
} from '../../../components/FormLayout';
|
} from '../../../components/FormLayout';
|
||||||
import { CodeMirrorField } from '../../../components/CodeMirrorInput';
|
import CodeMirrorField from '../../../components/CodeMirrorInput/CodeMirrorField';
|
||||||
|
|
||||||
function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
|
function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
|
||||||
const [useCustomField, , useCustomHelpers] = useField('useCustomMessages');
|
const [useCustomField, , useCustomHelpers] = useField('useCustomMessages');
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ function NotificationTemplateForm({
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { headers } = template?.notification_configuration || {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
@@ -130,6 +132,7 @@ function NotificationTemplateForm({
|
|||||||
notification_configuration: {
|
notification_configuration: {
|
||||||
...initialConfigValues,
|
...initialConfigValues,
|
||||||
...template.notification_configuration,
|
...template.notification_configuration,
|
||||||
|
headers: headers ? JSON.stringify(headers, null, 2) : null,
|
||||||
},
|
},
|
||||||
emailOptions,
|
emailOptions,
|
||||||
organization: template.summary_fields?.organization,
|
organization: template.summary_fields?.organization,
|
||||||
@@ -262,6 +265,9 @@ function normalizeTypeFields(values) {
|
|||||||
stripped.use_ssl = values.emailOptions === 'ssl';
|
stripped.use_ssl = values.emailOptions === 'ssl';
|
||||||
stripped.use_tls = !stripped.use_ssl;
|
stripped.use_tls = !stripped.use_ssl;
|
||||||
}
|
}
|
||||||
|
if (values.notification_type === 'webhook') {
|
||||||
|
stripped.headers = stripped.headers ? JSON.parse(stripped.headers) : {};
|
||||||
|
}
|
||||||
const { emailOptions, ...rest } = values;
|
const { emailOptions, ...rest } = values;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import {
|
|||||||
import FormField, {
|
import FormField, {
|
||||||
PasswordField,
|
PasswordField,
|
||||||
CheckboxField,
|
CheckboxField,
|
||||||
FieldTooltip,
|
|
||||||
ArrayTextField,
|
ArrayTextField,
|
||||||
} from '../../../components/FormField';
|
} from '../../../components/FormField';
|
||||||
import AnsibleSelect from '../../../components/AnsibleSelect';
|
import AnsibleSelect from '../../../components/AnsibleSelect';
|
||||||
import CodeMirrorInput from '../../../components/CodeMirrorInput';
|
import { CodeMirrorField } from '../../../components/CodeMirrorInput';
|
||||||
import {
|
import {
|
||||||
combine,
|
combine,
|
||||||
required,
|
required,
|
||||||
@@ -438,10 +437,6 @@ function TwilioFields({ i18n }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function WebhookFields({ i18n }) {
|
function WebhookFields({ i18n }) {
|
||||||
const [headersField, headersMeta, headersHelpers] = useField({
|
|
||||||
name: 'notification_configuration.headers',
|
|
||||||
validate: required(i18n._(t`Select enter a value for this field`), i18n),
|
|
||||||
});
|
|
||||||
const [methodField, methodMeta] = useField({
|
const [methodField, methodMeta] = useField({
|
||||||
name: 'notification_configuration.http_method',
|
name: 'notification_configuration.http_method',
|
||||||
validate: required(i18n._(t`Select a value for this field`), i18n),
|
validate: required(i18n._(t`Select a value for this field`), i18n),
|
||||||
@@ -473,31 +468,15 @@ function WebhookFields({ i18n }) {
|
|||||||
name="notification_configuration.disable_ssl_verification"
|
name="notification_configuration.disable_ssl_verification"
|
||||||
/>
|
/>
|
||||||
<FormFullWidthLayout>
|
<FormFullWidthLayout>
|
||||||
<FormGroup
|
<CodeMirrorField
|
||||||
fieldId="webhook-headers"
|
id="webhook-headers"
|
||||||
helperTextInvalid={headersMeta.error}
|
name="notification_configuration.headers"
|
||||||
isRequired
|
label={i18n._(t`HTTP Headers`)}
|
||||||
validated={
|
mode="javascript"
|
||||||
!headersMeta.touched || !headersMeta.error ? 'default' : 'error'
|
tooltip={i18n._(t`Specify HTTP Headers in JSON format. Refer to
|
||||||
}
|
the Ansible Tower documentation for example syntax.`)}
|
||||||
label={i18n._(t`HTTP headers`)}
|
rows={5}
|
||||||
labelIcon={
|
/>
|
||||||
<FieldTooltip
|
|
||||||
content={i18n._(t`Specify HTTP Headers in JSON format. Refer to
|
|
||||||
the Ansible Tower documentation for example syntax.`)}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<CodeMirrorInput
|
|
||||||
{...headersField}
|
|
||||||
id="webhook-headers"
|
|
||||||
onChange={value => {
|
|
||||||
headersHelpers.setValue(value);
|
|
||||||
}}
|
|
||||||
mode="javascript"
|
|
||||||
rows={5}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
</FormFullWidthLayout>
|
</FormFullWidthLayout>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
fieldId="webhook-http-method"
|
fieldId="webhook-http-method"
|
||||||
|
|||||||
Reference in New Issue
Block a user