diff --git a/frontend/public/services/mailgun.png b/frontend/public/services/mailgun.png new file mode 100644 index 0000000000000..e255b15587508 Binary files /dev/null and b/frontend/public/services/mailgun.png differ diff --git a/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx b/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx index 77e3dce5c3132..5c08c30d2fb84 100644 --- a/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx +++ b/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx @@ -16,6 +16,7 @@ export type LemonPureFieldProps = { help?: React.ReactNode /** Error message to be displayed */ error?: React.ReactNode + renderError?: (error: string) => React.ReactNode className?: string children?: React.ReactNode onClick?: () => void @@ -37,6 +38,7 @@ const LemonPureField = ({ children, inline, onClick, + renderError, }: LemonPureFieldProps): JSX.Element => { return (
{help}
: null} - {error ? ( -
- {error} -
+ {typeof error === 'string' ? ( + renderError ? ( + renderError(error) + ) : ( +
+ {error} +
+ ) ) : null} ) @@ -83,6 +89,7 @@ export const LemonField = ({ showOptional, inline, info, + renderError, ...keaFieldProps }: LemonFieldProps): JSX.Element => { const template: KeaFieldProps['template'] = ({ label, kids, error }) => { @@ -95,6 +102,7 @@ export const LemonField = ({ showOptional={showOptional} inline={inline} info={info} + renderError={renderError} > {kids} diff --git a/frontend/src/lib/monaco/CodeEditor.scss b/frontend/src/lib/monaco/CodeEditor.scss index 2fdacb435eaa4..5c7ebadabfde0 100644 --- a/frontend/src/lib/monaco/CodeEditor.scss +++ b/frontend/src/lib/monaco/CodeEditor.scss @@ -15,6 +15,11 @@ .CodeEditorResizeable, .CodeEditorInline { .monaco-editor { + /* stylelint-disable custom-property-pattern */ + --vscode-textLink-foreground: transparent; + --vscode-focusBorder: transparent; + /* stylelint-enable custom-property-pattern */ + border-radius: var(--radius); .overflow-guard { diff --git a/frontend/src/lib/monaco/CodeEditorInline.tsx b/frontend/src/lib/monaco/CodeEditorInline.tsx index 1bac239f7720a..57dfa1c15f53b 100644 --- a/frontend/src/lib/monaco/CodeEditorInline.tsx +++ b/frontend/src/lib/monaco/CodeEditorInline.tsx @@ -1,7 +1,7 @@ -import { CodeEditorProps } from 'lib/monaco/CodeEditor' -import { CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable' +import clsx from 'clsx' +import { CodeEditorResizableProps, CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable' -export interface CodeEditorInlineProps extends Omit { +export interface CodeEditorInlineProps extends Omit { minHeight?: string } export function CodeEditorInline(props: CodeEditorInlineProps): JSX.Element { @@ -9,6 +9,7 @@ export function CodeEditorInline(props: CodeEditorInlineProps): JSX.Element { lineNumbers: 'off', diff --git a/frontend/src/lib/monaco/CodeEditorResizable.tsx b/frontend/src/lib/monaco/CodeEditorResizable.tsx index cb7454a4ef60c..8d686b0f97a05 100644 --- a/frontend/src/lib/monaco/CodeEditorResizable.tsx +++ b/frontend/src/lib/monaco/CodeEditorResizable.tsx @@ -8,6 +8,7 @@ export interface CodeEditorResizableProps extends Omit void @@ -67,6 +68,22 @@ function JsonConfigField(props: { ) } +function EmailTemplateField({ schema }: { schema: HogFunctionInputSchemaType }): JSX.Element { + const { exampleInvocationGlobalsWithInputs, logicProps } = useValues(hogFunctionConfigurationLogic) + + return ( + <> + + + ) +} + function HogFunctionTemplateInput(props: Omit): JSX.Element { const { exampleInvocationGlobalsWithInputs } = useValues(hogFunctionConfigurationLogic) return @@ -165,6 +182,8 @@ export function HogFunctionInputRenderer({ value, onChange, schema, disabled }: return case 'integration_field': return + case 'email': + return default: return ( diff --git a/frontend/src/scenes/pipeline/hogfunctions/email-templater/EmailTemplater.tsx b/frontend/src/scenes/pipeline/hogfunctions/email-templater/EmailTemplater.tsx new file mode 100644 index 0000000000000..2211f94c55298 --- /dev/null +++ b/frontend/src/scenes/pipeline/hogfunctions/email-templater/EmailTemplater.tsx @@ -0,0 +1,108 @@ +import { LemonButton, LemonLabel, LemonModal } from '@posthog/lemon-ui' +import { useActions, useValues } from 'kea' +import { Form } from 'kea-forms' +import { LemonField } from 'lib/lemon-ui/LemonField' +import { CodeEditorInline } from 'lib/monaco/CodeEditorInline' +import { capitalizeFirstLetter } from 'lib/utils' +import EmailEditor from 'react-email-editor' + +import { emailTemplaterLogic, EmailTemplaterLogicProps } from './emailTemplaterLogic' + +function EmailTemplaterForm({ + mode, + ...props +}: EmailTemplaterLogicProps & { + mode: 'full' | 'preview' +}): JSX.Element { + const { setEmailEditorRef, emailEditorReady, setIsModalOpen } = useActions(emailTemplaterLogic(props)) + + return ( +
+ {['from', 'to', 'subject'].map((field) => ( + null} + > + {({ value, onChange, error }) => ( +
+ + {capitalizeFirstLetter(field)} + + +
+ )} +
+ ))} + + {mode === 'full' ? ( + setEmailEditorRef(r)} onReady={() => emailEditorReady()} /> + ) : ( + + {({ value }) => ( + <> +
+
+ setIsModalOpen(true)}> + Click to modify content + +
+ +