-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-25240] Send Access OTP email in MJML format #6411
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
base: main
Are you sure you want to change the base?
Conversation
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6411 +/- ##
==========================================
- Coverage 50.72% 50.71% -0.01%
==========================================
Files 1866 1866
Lines 82702 82734 +32
Branches 7319 7320 +1
==========================================
+ Hits 41949 41958 +9
- Misses 39150 39172 +22
- Partials 1603 1604 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent documentation, thank you! 🥳
…ate-otp-email-mjml
…com/bitwarden/server into auth/pm-25240/update-otp-email-mjml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly typo fixes and questions!
|
||
There is no change on how we interact with our view models. | ||
|
||
The new comes in when we compile the `*.mjml` to `*.html.hbs`. This is the format we use so the handlebars service can apply the variables. This build pipeline process is in progress and may need to be manual done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I can't turn off the editor side of my brain 😂
The new comes in when we compile the `*.mjml` to `*.html.hbs`. This is the format we use so the handlebars service can apply the variables. This build pipeline process is in progress and may need to be manual done. | |
The new comes in when we compile the `*.mjml` to `*.html.hbs`. This is the format we use so the handlebars service can apply the variables. This build pipeline process is in progress and may need to be manually done. |
The new comes in when we compile the `*.mjml` to `*.html.hbs`. This is the format we use so the handlebars service can apply the variables. This build pipeline process is in progress and may need to be manual done. | ||
|
||
### `txt.hbs` | ||
There is no change to how we create the `txt.hbs`. MJML does not impact how we create these artifacts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this documentation is not temporary, I would suggest documenting the existing behavior here (or pointing to where it exists). Right now it reads like a changelog, which is useful if you already know how it works, but this readme looks like it is the permanent documentation for MJML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll see about adding some documentation about how we handle the text files.
I am trying to keep this readme as much about MJML as possible without muddying the waters with other flows, which is why it's vague here. It might be worth adding a README.md
one directory up from this and reference the txt.hbs
pattern there since it's a more general code area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to run text.hbs through mjml since there's significantly less complexity there. But I might be wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.txt.hbs
is not used at all in the mjml build flows. Those are maintained in the same way as before.
This PR is stale please look at this one for more up-to-date docs.
``` | ||
This command will parse the email directory for all mjml files and attempt to compile them into `*html.hbs` files and output them into the `out/` directory. This command maintains the structure of the input directories. Meaning if an mjml template is located in `email/auth` then the compiled version will be in `out/auth`. | ||
|
||
The script was generated and works as expected. It is more fully featured than it's usage here. If interested take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script was generated and works as expected. It is more fully featured than it's usage here. If interested take a look. | |
The script was generated and works as expected. It is more fully featured than its usage here. If interested take a look. |
Not all MJML tags have the same attributes, it is highly recommended to review the documentation on the official MJML website to understand the usages of each of the tags. | ||
|
||
### Custom Tags | ||
There is currently a `mj-bw-hero` tag that you can use from within your `*.mjml` templates. This is a good example of how to create a component that takes in attribute values allowing us to be more DRY in our development of emails. Since the attributes input is a string we are able to define whatever we need into the component, in this case `mj-bw-hero`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is currently a `mj-bw-hero` tag that you can use from within your `*.mjml` templates. This is a good example of how to create a component that takes in attribute values allowing us to be more DRY in our development of emails. Since the attributes input is a string we are able to define whatever we need into the component, in this case `mj-bw-hero`. | |
There is currently a `mj-bw-hero` tag that you can use from within your `*.mjml` templates. This is a good example of how to create a component that takes in attribute values allowing us to be more DRY in our development of emails. Since the attribute's input is a string we are able to define whatever we need into the component, in this case `mj-bw-hero`. |
/> | ||
``` | ||
|
||
Attributes in Custom Components are defined by the developer. They can be required or optional depending on implementation. See the documentation for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does documentation
here refer to MJML official docs or what the dev has documented in a specific component?
The script was generated and works as expected. It is more fully featured than it's usage here. If interested take a look. | ||
|
||
## Development | ||
MJML supports components and you can create your own components by adding them to `.mjmlconfig`. Components are simple JavaScipt that return HTML based on the attributes assigned. (see components/mj-bw-hero.js) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MJML supports components and you can create your own components by adding them to `.mjmlconfig`. Components are simple JavaScipt that return HTML based on the attributes assigned. (see components/mj-bw-hero.js) | |
MJML supports components and you can create your own components by adding them to `.mjmlconfig`. Components are simple JavaScript that return HTML based on the attributes assigned. (see components/mj-bw-hero.js) |
|
||
MJML supports components and you can create your own components by adding them to `.mjmlconfig`. | ||
## Implementation Considerations | ||
We will be using the mjml templates to be generating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it got cut off?
</mj-style> | ||
|
||
<!-- Responsive icon visibility --> | ||
<mj-style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is this file used in all emails, or will other emails have to add this same css selector to get the responsive behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a mjml tempate wishes to use the styling in the head.mjml
template, then it would need to be referenced like this:
<mjml>
<mj-head>
<mj-include path="../components/head.mjml" />
</mj-head>
...
</mjml>
Then the class would be applied to tags using the css-class
attribute. In mj-bw-hero.js
we use it to hide the logo in the blue header area.
<mj-image
src="${this.getAttribute("img-src")}"
alt=""
width="140px"
height="140px"
padding="0px"
css-class="hide-small-img" /> <!-- here -->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the hide-small-img
class wouldn't do anything if the template doesn't include the head.mjml
template, right? I guess I'm trying to think if having the styling separate from the class usage could cause sneaky bugs if the styling isn't included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my recommendation would be to always include the head.mjml
as a matter of practice. Which should avoid that issue? Not sure if that's the best approach or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's expected to always be included then that seems fine to me. Can we document that somewhere?
…ate-otp-email-mjml
Added information about build script definitions for MJML.
…ate-otp-email-mjml
<mj-section border-radius="0px 0px 4px 4px" background-color="#f6f6f6" padding="5px 20px 10px 20px"> | ||
<mj-column width="70%"> | ||
<mj-text line-height="24px"> | ||
<h3 style="font-size: 20px; margin: 0; line-height: 28px"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a header element? I think it will be hard to ensure that heading levels are in the correct order / not being skipped with the way the templates are joined together.
Edit -- I see this is pulled from an existing email, so totally fine if we want to defer that problem to solve later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A non-blocking observation below. If this is even worth mentioning, should it be an update considered to .editorconfig
or similar?
|
||
</body> | ||
</html> | ||
No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ This is only mentioned in contrib specifically in reference to C# files, which this is not to be fair, but I notice this file is marked with no newline.
This code can only be used once and expires in {{Expiry}} minutes. After that you'll need to verify your email again. | ||
|
||
Bitwarden Send transmits sensitive, temporary information to others easily and securely. Learn more about Bitwarden Send or sign up to try it today. | ||
{{/BasicTextLayout}} No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Same as the other .hbs file comment re: newline.
🎟️ Tracking
PM-25240
📔 Objective
This work supports the building of
*.html.hbs
artifacts for the Send Access OTP email using theMJML
templating library.MJML templating is not standard in our code base yet, a feature flag is added in the
SendEmailOtpRequestValidator
.Since the
HandlebarsMailService
is registered as aSingleton
we cannot inject theFeatureService
since theFeatureService
is registered asScoped
. This means we had to update the call site of the email rather than in theHandlebarsMailService
.📸 Screenshots
Responsive email
Full email
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes