Add withHeader atribute to EmailThread. Add in EmailViewer so it show…#353
Add withHeader atribute to EmailThread. Add in EmailViewer so it show…#353elie222 merged 1 commit intoelie222:mainfrom
Conversation
|
@RicSala is attempting to deploy a commit to the Inbox Zero Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis pull request introduces an optional boolean prop, Changes
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
Possibly related PRs
Poem
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
apps/web/components/EmailViewer.tsxOops! 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'
apps/web/components/email-list/EmailThread.tsxOops! 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'
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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! ThewithHeaderprop is correctly added.The addition of the
withHeaderprop 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
withHeaderprop is properly added to the component props with the correct optional boolean type.Also applies to: 20-20
| {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> | ||
| )} |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add null check and improve accessibility.
The header implementation needs some improvements:
- Add null check for
messages[0]to prevent potential runtime errors - 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.
| {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> | |
| )} |
|
Thanks! |
This pull request introduces a new attribute to conditionally display a header in the
EmailThreadcomponent, 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
EmailThreadapps/web/components/EmailViewer.tsx: Added thewithHeaderprop to theThreadContentcomponent to enable conditional rendering of the header.apps/web/components/email-list/EmailThread.tsx:withHeaderprop to theEmailThreadcomponent's props definition.withHeaderprop is true. [1] [2]closes #350
Summary by CodeRabbit