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

fix(user-notification): Fix email layout for outlook client #15460

Merged
merged 5 commits into from
Jul 9, 2024

Conversation

GunnlaugurG
Copy link
Member

@GunnlaugurG GunnlaugurG commented Jul 8, 2024

What

Email layout is a bit off in old outlook versions since it uses Word to render HTML.
Using images instead of highly css-ed components allows them to look them same on all email clients

Why

To make emails look the same on all email clients

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced ImageWithLink component for enhanced email templates with dynamic image sources and hyperlinks.
  • Improvements

    • Updated image handling to support new image types and dynamic sources.
    • Enhanced CSS styles for better email layout and readability on various screen sizes.
  • Bug Fixes

    • Adjusted CSS properties for consistent padding, margin, and alignment across different sections in email templates.

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Walkthrough

The updates primarily involve enhancing the handling and rendering of image components in a notification and email service framework. Key changes include the introduction of an ImageWithLink component, updates to CSS for better responsiveness and layout, and adjustments in types and service methods to accommodate the new image component functionalities.

Changes

Files Change Summary
...ation/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts Changed the component property from 'Button' to 'ImageWithLink' in multiple sections.
...s/notificationsWorker/notificationsWorker.service.ts Updated the src attribute in the Image component and introduced ImageWithLink component with dynamic image source and text.
libs/email-service/src/tools/adapter.service.ts Added logic to handle 'imagewithlink' component type alongside 'image'.
libs/email-service/src/tools/design/foundation.hbs Restructured CSS styles for email templates to enhance readability and responsiveness, including padding, margin, alignment, and font size adjustments.
libs/email-service/src/tools/design/image.hbs Removed a <div> and updated the <img> styling to include a fixed height of 24px.
libs/email-service/src/tools/design/imagewithlink.hbs Introduced a new template that renders an image wrapped in a hyperlink, with dynamic attributes for URL, image source, alt text, and height.
libs/email-service/src/tools/design/styles.hbs Adjusted CSS properties for .segment, .section, and .cta-button classes to improve layout consistency across different screen sizes.
libs/email-service/src/types/index.ts Added ImageWithLinkComponent interface to the Body type, expanding the range of components usable in email templates.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NotificationService
    participant AdapterService
    participant EmailTemplate
    User->>NotificationService: Initiates notification with image or button
    NotificationService->> AdapterService: Request to process component
    AdapterService->> AdapterService: Checks component type
    AdapterService->> EmailTemplate: Use `imagewithlink.hbs` if component is 'imagewithlink'
    EmailTemplate->> AdapterService: Return rendered template
    AdapterService->> NotificationService: Processed template
    NotificationService-->User: Sends final notification output
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.90%. Comparing base (a992d04) to head (c324c79).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15460      +/-   ##
==========================================
- Coverage   37.02%   36.90%   -0.13%     
==========================================
  Files        6557     6542      -15     
  Lines      134015   134339     +324     
  Branches    38367    38530     +163     
==========================================
- Hits        49623    49577      -46     
- Misses      84392    84762     +370     
Flag Coverage Δ
api 3.44% <ø> (ø)
api-domains-communications 40.56% <0.00%> (+<0.01%) ⬆️
application-system-api 41.82% <0.00%> (-0.02%) ⬇️
application-template-api-modules 23.94% <0.00%> (-0.02%) ⬇️
email-service 61.42% <100.00%> (ø)
financial-aid-backend 56.56% <0.00%> (ø)
judicial-system-backend 56.04% <0.00%> (ø)
services-auth-ids-api 54.67% <ø> (-0.02%) ⬇️
services-endorsements-api 55.49% <0.00%> (ø)
services-user-notification 48.01% <66.66%> (-0.04%) ⬇️
services-user-profile 62.48% <0.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...notificationsWorker/notificationsWorker.service.ts 93.28% <100.00%> (+0.04%) ⬆️
libs/email-service/src/tools/adapter.service.ts 86.66% <100.00%> (ø)

... and 145 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a992d04...c324c79. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jul 8, 2024

Datadog Report

All test runs 379588d 🔗

11 Total Test Services: 0 Failed, 11 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 1 increased (+0.04%), 17 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.02s 1 no change Link
api-domains-communications 0 0 0 5 0 32.07s 1 no change Link
application-system-api 0 0 0 111 2 3m 20.03s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 54.8s 1 no change Link
email-service 0 0 0 2 0 11.84s 1 no change Link
financial-aid-backend 0 0 0 219 0 58.86s 1 no change Link
judicial-system-backend 0 0 0 19805 0 17m 27.68s 1 no change Link
services-auth-ids-api 0 0 0 215 0 1m 20.09s 1 no change Link
services-endorsements-api 0 0 0 42 0 42.74s 1 no change Link
services-user-notification 0 0 0 48 0 1m 37.83s 1 decreased (-0.01%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-user-notification - jest 71.13% (-0.01%) - Details

@GunnlaugurG GunnlaugurG marked this pull request as ready for review July 8, 2024 14:33
@GunnlaugurG GunnlaugurG requested review from a team as code owners July 8, 2024 14:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 541f51b and 75e2f16.

Files ignored due to path filters (3)
  • apps/services/user-notification/src/assets/images/en-button-open.png is excluded by !**/*.png
  • apps/services/user-notification/src/assets/images/is-button-open.png is excluded by !**/*.png
  • apps/services/user-notification/src/assets/images/island-2x-logo.png is excluded by !**/*.png
Files selected for processing (8)
  • apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts (6 hunks)
  • apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.ts (2 hunks)
  • libs/email-service/src/tools/adapter.service.ts (1 hunks)
  • libs/email-service/src/tools/design/foundation.hbs (1 hunks)
  • libs/email-service/src/tools/design/image.hbs (1 hunks)
  • libs/email-service/src/tools/design/imagewithlink.hbs (1 hunks)
  • libs/email-service/src/tools/design/styles.hbs (3 hunks)
  • libs/email-service/src/types/index.ts (2 hunks)
Files skipped from review due to trivial changes (4)
  • apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts
  • libs/email-service/src/tools/design/foundation.hbs
  • libs/email-service/src/tools/design/image.hbs
  • libs/email-service/src/tools/design/imagewithlink.hbs
Additional context used
Path-based instructions (4)
libs/email-service/src/types/index.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/email-service/src/tools/adapter.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/email-service/src/tools/design/styles.hbs (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (6)
libs/email-service/src/types/index.ts (2)

83-91: Addition of ImageWithLinkComponent interface looks good.

The new interface is well-defined and consistent with the existing component interfaces.


103-103: Inclusion of ImageWithLinkComponent in Body type looks good.

This change ensures that the new component type can be used within the email template body.

libs/email-service/src/tools/adapter.service.ts (1)

81-81: Modification of buildBody method to handle imagewithlink component type looks good.

The change is consistent with the existing logic for handling image components.

libs/email-service/src/tools/design/styles.hbs (1)

292-292: Update to .tag class looks good.

The addition of justify-content: center; ensures that the content within the .tag class is centered horizontally.

apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.ts (2)

146-148: Update to use ImageWithLink component looks good.

The component property has been updated to use the new ImageWithLink component with a dynamic image source based on the language and corresponding button text.


174-182: Dynamic image source based on language looks good.

The dynamic image source based on the language (en or is) and corresponding button text is correctly implemented.

@GunnlaugurG GunnlaugurG added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jul 9, 2024
@kodiakhq kodiakhq bot merged commit 0d93cc9 into main Jul 9, 2024
51 checks passed
@kodiakhq kodiakhq bot deleted the fix/outlook-email branch July 9, 2024 09:47
oskarjs pushed a commit that referenced this pull request Aug 20, 2024
* image with link instead of button cta

* remove tag-bg

* fix horizontal spacing on email

* fix tests
@coderabbitai coderabbitai bot mentioned this pull request Nov 18, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants