-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor): ✨ Add send email integration
- Loading branch information
1 parent
f4336b8
commit d6238b3
Showing
48 changed files
with
2,133 additions
and
2,620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...raph/Nodes/StepNode/SettingsPopoverContent/bodies/SendEmailSettings/SendEmailSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Stack, useDisclosure, Text } from '@chakra-ui/react' | ||
import { CredentialsDropdown } from 'components/shared/CredentialsDropdown' | ||
import { | ||
InputWithVariableButton, | ||
TextareaWithVariableButton, | ||
} from 'components/shared/TextboxWithVariableButton' | ||
import { CredentialsType, SendEmailOptions } from 'models' | ||
import React from 'react' | ||
import { SmtpConfigModal } from './SmtpConfigModal' | ||
|
||
type Props = { | ||
options: SendEmailOptions | ||
onOptionsChange: (options: SendEmailOptions) => void | ||
} | ||
|
||
export const SendEmailSettings = ({ options, onOptionsChange }: Props) => { | ||
const { isOpen, onOpen, onClose } = useDisclosure() | ||
const handleCredentialsSelect = (credentialsId: string) => | ||
onOptionsChange({ | ||
...options, | ||
credentialsId, | ||
}) | ||
|
||
const handleToChange = (recipientsStr: string) => { | ||
const recipients: string[] = recipientsStr | ||
.split(',') | ||
.map((str) => str.trim()) | ||
onOptionsChange({ | ||
...options, | ||
recipients, | ||
}) | ||
} | ||
|
||
const handleSubjectChange = (subject: string) => | ||
onOptionsChange({ | ||
...options, | ||
subject, | ||
}) | ||
|
||
const handleBodyChange = (body: string) => | ||
onOptionsChange({ | ||
...options, | ||
body, | ||
}) | ||
|
||
return ( | ||
<Stack spacing={4}> | ||
<Stack> | ||
<Text>From: </Text> | ||
<CredentialsDropdown | ||
type={CredentialsType.SMTP} | ||
currentCredentialsId={options.credentialsId} | ||
onCredentialsSelect={handleCredentialsSelect} | ||
onCreateNewClick={onOpen} | ||
defaultCredentialLabel={ | ||
process.env.NEXT_PUBLIC_EMAIL_NOTIFICATIONS_FROM_EMAIL | ||
} | ||
/> | ||
</Stack> | ||
<Stack> | ||
<Text>To: </Text> | ||
<InputWithVariableButton | ||
onChange={handleToChange} | ||
initialValue={options.recipients.join(', ')} | ||
placeholder="email1@gmail.com, email2@gmail.com" | ||
/> | ||
</Stack> | ||
<Stack> | ||
<Text>Subject: </Text> | ||
<InputWithVariableButton | ||
data-testid="subject-input" | ||
onChange={handleSubjectChange} | ||
initialValue={options.subject ?? ''} | ||
/> | ||
</Stack> | ||
<Stack> | ||
<Text>Body: </Text> | ||
<TextareaWithVariableButton | ||
data-testid="body-input" | ||
minH="300px" | ||
onChange={handleBodyChange} | ||
initialValue={options.body ?? ''} | ||
/> | ||
</Stack> | ||
<SmtpConfigModal | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
onNewCredentials={handleCredentialsSelect} | ||
/> | ||
</Stack> | ||
) | ||
} |
88 changes: 88 additions & 0 deletions
88
...d/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/SendEmailSettings/SmtpConfigForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { FormControl, FormLabel, HStack, Stack } from '@chakra-ui/react' | ||
import { isDefined } from '@udecode/plate-common' | ||
import { DebouncedInput } from 'components/shared/DebouncedInput' | ||
import { SmartNumberInput } from 'components/shared/SmartNumberInput' | ||
import { SwitchWithLabel } from 'components/shared/SwitchWithLabel' | ||
import { SmtpCredentialsData } from 'models' | ||
import React from 'react' | ||
|
||
type Props = { | ||
config: SmtpCredentialsData | ||
onConfigChange: (config: SmtpCredentialsData) => void | ||
} | ||
|
||
export const SmtpConfigForm = ({ config, onConfigChange }: Props) => { | ||
const handleFromEmailChange = (email: string) => | ||
onConfigChange({ ...config, from: { ...config.from, email } }) | ||
const handleFromNameChange = (name: string) => | ||
onConfigChange({ ...config, from: { ...config.from, name } }) | ||
const handleHostChange = (host: string) => onConfigChange({ ...config, host }) | ||
const handleUsernameChange = (username: string) => | ||
onConfigChange({ ...config, username }) | ||
const handlePasswordChange = (password: string) => | ||
onConfigChange({ ...config, password }) | ||
const handleTlsCheck = (isTlsEnabled: boolean) => | ||
onConfigChange({ ...config, isTlsEnabled }) | ||
const handlePortNumberChange = (port?: number) => | ||
isDefined(port) && onConfigChange({ ...config, port }) | ||
|
||
return ( | ||
<Stack as="form" spacing={4}> | ||
<FormControl isRequired> | ||
<FormLabel>From email:</FormLabel> | ||
<DebouncedInput | ||
initialValue={config.from.email ?? ''} | ||
onChange={handleFromEmailChange} | ||
placeholder="notifications@provider.com" | ||
/> | ||
</FormControl> | ||
<FormControl isRequired> | ||
<FormLabel>From name:</FormLabel> | ||
<DebouncedInput | ||
initialValue={config.from.name ?? ''} | ||
onChange={handleFromNameChange} | ||
placeholder="John Smith" | ||
/> | ||
</FormControl> | ||
<FormControl isRequired> | ||
<FormLabel>Host:</FormLabel> | ||
<DebouncedInput | ||
initialValue={config.host ?? ''} | ||
onChange={handleHostChange} | ||
placeholder="mail.provider.com" | ||
/> | ||
</FormControl> | ||
<FormControl isRequired> | ||
<FormLabel>Username / Email:</FormLabel> | ||
<DebouncedInput | ||
type="email" | ||
initialValue={config.username ?? ''} | ||
onChange={handleUsernameChange} | ||
placeholder="user@provider.com" | ||
/> | ||
</FormControl> | ||
<FormControl isRequired> | ||
<FormLabel>Password:</FormLabel> | ||
<DebouncedInput | ||
type="password" | ||
initialValue={config.password ?? ''} | ||
onChange={handlePasswordChange} | ||
/> | ||
</FormControl> | ||
<SwitchWithLabel | ||
id="Tls" | ||
label={'Use TLS?'} | ||
initialValue={config.isTlsEnabled ?? false} | ||
onCheckChange={handleTlsCheck} | ||
/> | ||
<FormControl as={HStack} justifyContent="space-between"> | ||
<FormLabel mb="0">Port number:</FormLabel> | ||
<SmartNumberInput | ||
placeholder="25" | ||
value={config.port} | ||
onValueChange={handlePortNumberChange} | ||
/> | ||
</FormControl> | ||
</Stack> | ||
) | ||
} |
Oops, something went wrong.