Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI for including additional headers #60

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 54 additions & 19 deletions src/formSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ const messages = defineMessages({
id: 'captcha',
defaultMessage: 'Captcha provider',
},

headers: {
id: 'Headers',
defaultMessage: 'Headers',
},
headersDescription: {
id: 'Headers Description',
defaultMessage: "These headers aren't included in the sent email by default. Use this dropdown to include them in the sent email",
},
store: {
id: 'form_save_persistent_data',
defaultMessage: 'Store compiled data',
Expand All @@ -49,28 +56,38 @@ const messages = defineMessages({
},
});

export default () => {
export default (formData) => {
var intl = useIntl();

const fieldsets = [
{
id: 'default',
title: 'Default',
fields: [
'title',
'description',
'default_to',
'default_from',
'default_subject',
'submit_label',
'captcha',
'store',
'send',
],
},
];

if (formData?.send) {
fieldsets.push({
id: 'sendingOptions',
title: 'Sending options',
fields: ['httpHeaders'],
});
}

return {
title: intl.formatMessage(messages.form),
fieldsets: [
{
id: 'default',
title: 'Default',
fields: [
'title',
'description',
'default_to',
'default_from',
'default_subject',
'submit_label',
'captcha',
'store',
'send',
],
},
],
fieldsets: fieldsets,
properties: {
title: {
title: intl.formatMessage(messages.title),
Expand Down Expand Up @@ -107,6 +124,24 @@ export default () => {
type: 'boolean',
title: intl.formatMessage(messages.send),
},
httpHeaders: {
type: 'boolean',
title: intl.formatMessage(messages.headers),
description: intl.formatMessage(messages.headersDescription),
type: 'string',
factory: 'Choice',
default: '',
isMulti: true,
noValueOption: false,
choices: [
['HTTP_X_FORWARDED_FOR','HTTP_X_FORWARDED_FOR'],
['HTTP_X_FORWARDED_PORT','HTTP_X_FORWARDED_PORT'],
['REMOTE_ADDR','REMOTE_ADDR'],
['PATH_INFO','PATH_INFO'],
['HTTP_USER_AGENT','HTTP_USER_AGENT'],
['HTTP_REFERER','HTTP_REFERER'],
],
},
},
required: ['default_to', 'default_from', 'default_subject'],
};
Expand Down