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

Emailer: preview HTML content before sending #324

Merged
merged 4 commits into from
Feb 25, 2024
Merged

Conversation

huang0h
Copy link
Contributor

@huang0h huang0h commented Feb 6, 2024

Checklist

  • 1. Run yarn run check
  • 2. Run yarn run test

Why

Resolves #275

On the emailer page, add a toggle to preview email HTML before sending

This PR

  • Add DOMpurify as a dependency to sanitize HTML
  • Add a switch to toggle between the raw HTML editor and email previewing

Screenshots

Raw view:

image

Preview view:

image

Verification Steps

  • Verified the switch toggles between raw and preview views
  • Verified HTML content is sanitized in the preview view

Copy link
Contributor

@SurabhiKeesara SurabhiKeesara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. To follow up on our conversation, I think that this is good for users who want to write custom HTML. However, we should use this in conjunction with something that just inserts some provided text into the body of a pre-selected template.

Copy link
Contributor

@CerberusLatrans CerberusLatrans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job abstracting the messages using the translation functionality. I Like!

Copy link
Contributor

@CiciLing CiciLing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just have a couple questions on certain implementation.

>
<Input.TextArea rows={6} placeholder="Email Body" />
<Input.TextArea rows={8} placeholder={t('body_placeholder')} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to set the row to 8? if the user has less than 8 lines, would it just show a bunch of white spaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's just making the textbox for the the email body a little bigger (see pic). No real important reason behind this, I just thought it'd be nice to have a little more space to view the email HTML (before/after):

image

image

form={sendEmailForm}
onFinish={onFinishSendEmail}
onValuesChange={(changedValues, _) => {
if (changedValues.emailBody !== undefined)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the emailBody is undefined, would we want to prompt the user to do anything? or just ignore until they input something that's valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! In this case, emailBody would be undefined only when the user edits a field that's not the body, since changedValues only contains fields that were modified when the user inputs something. This check is just to make sure we don't accidentally clear the body when the user modifies the subject.

@huang0h huang0h merged commit e82ef59 into master Feb 25, 2024
4 of 5 checks passed
@huang0h huang0h deleted the AH.EmailPreview branch February 25, 2024 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emailer: Preview email content before sending
4 participants