Skip to content

Add withHeader atribute to EmailThread. Add in EmailViewer so it show…#353

Merged
elie222 merged 1 commit intoelie222:mainfrom
RicSala:email-header-toggle
Feb 23, 2025
Merged

Add withHeader atribute to EmailThread. Add in EmailViewer so it show…#353
elie222 merged 1 commit intoelie222:mainfrom
RicSala:email-header-toggle

Conversation

@RicSala
Copy link
Contributor

@RicSala RicSala commented Feb 23, 2025

This pull request introduces a new attribute to conditionally display a header in the EmailThread component, rendering the header conditionally to this attribute (defaults to false). Then it pass it on EmailViewer so Reply Zero keeps showing it.

Conditional Header in EmailThread

  • apps/web/components/EmailViewer.tsx: Added the withHeader prop to the ThreadContent component to enable conditional rendering of the header.

  • apps/web/components/email-list/EmailThread.tsx:

    • Added the withHeader prop to the EmailThread component's props definition.
    • Included conditional rendering logic to display the header if the withHeader prop is true. [1] [2]

closes #350

Summary by CodeRabbit

  • New Features
    • Introduced an option to display a header within email threads. When enabled, users can see additional contextual details, such as the email subject and related information, enhancing clarity and navigation during email viewing.

@vercel
Copy link

vercel bot commented Feb 23, 2025

@RicSala is attempting to deploy a commit to the Inbox Zero Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Feb 23, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2025

Walkthrough

This pull request introduces an optional boolean prop, withHeader, to manage the conditional rendering of a header section in the EmailThread component. In the EmailViewer.tsx file, the withHeader prop is passed to the EmailThread component within the ThreadContent function. In the EmailThread.tsx file, the component’s prop types are updated with the optional withHeader property, and a conditional block renders a header containing the subject and a top-right component when withHeader is true.

Changes

File(s) Change Summary
apps/.../EmailViewer.tsx Added withHeader prop in the call to EmailThread within the ThreadContent function.
apps/.../email-list/EmailThread.tsx Introduced optional withHeader prop to the component’s props, updated TypeScript definitions, and added conditional rendering for a header section displaying subject and topRightComponent.

Sequence Diagram(s)

sequenceDiagram
    participant Viewer as EmailViewer
    participant Thread as EmailThread
    Viewer->>Thread: Render EmailThread(withHeader flag)
    alt withHeader is true
        Thread->>Thread: Render header (subject & topRightComponent)
    else
        Thread->>Thread: Omit header rendering
    end
Loading

Possibly related PRs

Poem

I'm a rabbit in the code burrow, hopping with cheer,
With a new withHeader prop, our emails now appear clear.
A header lights up like a carrot in the sun,
Simple changes make our rendering fun!
Leaping over bugs—hop, skip, and run! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/components/EmailViewer.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in 'apps/web/.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /apps/web/.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
apps/web/components/email-list/EmailThread.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in 'apps/web/.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /apps/web/.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd1de7a and 54c7ef0.

📒 Files selected for processing (2)
  • apps/web/components/EmailViewer.tsx (1 hunks)
  • apps/web/components/email-list/EmailThread.tsx (2 hunks)
🔇 Additional comments (2)
apps/web/components/EmailViewer.tsx (1)

69-69: LGTM! The withHeader prop is correctly added.

The addition of the withHeader prop aligns with the PR objectives, enabling header visibility in the EmailThread component.

apps/web/components/email-list/EmailThread.tsx (1)

12-12: LGTM! Props are correctly defined.

The withHeader prop is properly added to the component props with the correct optional boolean type.

Also applies to: 20-20

Comment on lines +55 to +64
{withHeader && (
<div className="flex items-center justify-between">
<div className="text-2xl font-semibold text-foreground">
{messages[0]?.headers.subject}
</div>
{topRightComponent && (
<div className="flex items-center gap-2">{topRightComponent}</div>
)}
</div>
{topRightComponent && (
<div className="flex items-center gap-2">{topRightComponent}</div>
)}
</div>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add null check and improve accessibility.

The header implementation needs some improvements:

  1. Add null check for messages[0] to prevent potential runtime errors
  2. Add semantic HTML and ARIA attributes for better accessibility

Apply this diff to improve the implementation:

-      {withHeader && (
+      {withHeader && messages.length > 0 && (
-        <div className="flex items-center justify-between">
+        <header role="banner" className="flex items-center justify-between">
           <div className="text-2xl font-semibold text-foreground">
-            {messages[0]?.headers.subject}
+            <h1>{messages[0].headers.subject}</h1>
           </div>
           {topRightComponent && (
             <div className="flex items-center gap-2">{topRightComponent}</div>
           )}
-        </div>
+        </header>
       )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{withHeader && (
<div className="flex items-center justify-between">
<div className="text-2xl font-semibold text-foreground">
{messages[0]?.headers.subject}
</div>
{topRightComponent && (
<div className="flex items-center gap-2">{topRightComponent}</div>
)}
</div>
{topRightComponent && (
<div className="flex items-center gap-2">{topRightComponent}</div>
)}
</div>
)}
{withHeader && messages.length > 0 && (
<header role="banner" className="flex items-center justify-between">
<div className="text-2xl font-semibold text-foreground">
<h1>{messages[0].headers.subject}</h1>
</div>
{topRightComponent && (
<div className="flex items-center gap-2">{topRightComponent}</div>
)}
</header>
)}

@elie222 elie222 merged commit b4db1b9 into elie222:main Feb 23, 2025
2 of 3 checks passed
@elie222
Copy link
Owner

elie222 commented Feb 23, 2025

Thanks!

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.

Mail: don't show subject line twice

3 participants

Comments