Skip to content

WIP: Add more actions to categories#256

Closed
elie222 wants to merge 5 commits intomainfrom
category-actions
Closed

WIP: Add more actions to categories#256
elie222 wants to merge 5 commits intomainfrom
category-actions

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Nov 6, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced the GroupedTable component with a dropdown menu for editing, auto archiving, and labeling options.
    • Introduced new icons for improved visual representation.
    • Integrated user label management through the LabelsSubMenu.
  • Bug Fixes

    • Improved control flow for better user experience in managing email categories.

@vercel
Copy link

vercel bot commented Nov 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview Dec 21, 2024 8:01pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes in the GroupedTable.tsx component focus on enhancing its functionality and user interface. New icons are imported to provide visual options, and a dropdown menu replaces the previous edit button, allowing users to edit, auto archive, and label entries. The GroupedTable function retrieves user labels through a hook and passes them to the GroupRow component, which now accepts an updated set of props. The overall structure remains intact, but the control flow is adjusted to improve user interaction with email categories.

Changes

File Change Summary
apps/web/components/GroupedTable.tsx - Added imports for MoreVerticalIcon, TagIcon, TagsIcon, and various dropdown menu components.
- Updated GroupedTable and GroupRow function signatures to accept a new labels: UserLabel[] prop.
- Replaced edit button with a dropdown menu for editing, auto archiving, and labeling.
- Integrated useLabels hook to retrieve user labels for dynamic interaction.

Poem

In the meadow where the tables grow,
New icons dance, putting on a show.
A dropdown menu, sleek and bright,
Makes editing a pure delight.
With labels close, we hop and play,
Organizing joy in a bunny way! 🐇✨


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 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

📥 Commits

Reviewing files that changed from the base of the PR and between 89b2f0b and 49f6ff0.

📒 Files selected for processing (1)
  • apps/web/components/GroupedTable.tsx (6 hunks)
🔇 Additional comments (3)
apps/web/components/GroupedTable.tsx (3)

15-22: LGTM: New imports are well-organized

The new imports for icons and dropdown menu components are properly organized and align with the new dropdown menu feature.

Also applies to: 51-61


193-194: LGTM: Labels integration is clean

The integration of the labels feature through the useLabels hook and prop passing is clean and follows React best practices.

Also applies to: 227-227


340-348: LGTM: Props interface is well-typed

The addition of the labels prop to the GroupRow component is properly typed with UserLabel[].

Comment on lines +372 to +409
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="xs">
<MoreVerticalIcon className="size-4" />
<span className="sr-only">More</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={onEditCategory}>
<PencilIcon className="mr-2 size-4" />
Edit Prompt
</DropdownMenuItem>
<DropdownMenuItem>
<ArchiveIcon className="mr-2 size-4" />
Auto archive
</DropdownMenuItem>

<DropdownMenuSub>
<DropdownMenuSubTrigger>
<TagsIcon className="mr-2 size-4" />
<span>Auto archive and label</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<LabelsSubMenu labels={labels} onClick={(labelId) => {}} />
</DropdownMenuPortal>
</DropdownMenuSub>

<DropdownMenuSub>
<DropdownMenuSubTrigger>
<TagIcon className="mr-2 size-4" />
<span>Auto label</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<LabelsSubMenu labels={labels} onClick={(labelId) => {}} />
</DropdownMenuPortal>
</DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Based on the gathered information, I can now provide the final response:

Implementation incomplete: Missing click handlers can be implemented using existing functionality

The empty click handlers should be implemented using the existing createFilterAction function, similar to how it's used in the bulk-unsubscribe feature. Here's how to fix:

             <DropdownMenuSub>
               <DropdownMenuSubTrigger>
                 <TagsIcon className="mr-2 size-4" />
                 <span>Auto archive and label</span>
               </DropdownMenuSubTrigger>
               <DropdownMenuPortal>
-                <LabelsSubMenu labels={labels} onClick={(labelId) => {}} />
+                <LabelsSubMenu 
+                  labels={labels} 
+                  onClick={async (label) => {
+                    const res = await createFilterAction(category, label.id, true);
+                    if (isActionError(res)) {
+                      toastError({
+                        title: "Error",
+                        description: `Failed to set up auto-archive and label. ${res.error}`,
+                      });
+                    } else {
+                      toastSuccess({
+                        title: "Success",
+                        description: "Auto-archive and label rule created",
+                      });
+                    }
+                  }} 
+                />
               </DropdownMenuPortal>
             </DropdownMenuSub>

             <DropdownMenuSub>
               <DropdownMenuSubTrigger>
                 <TagIcon className="mr-2 size-4" />
                 <span>Auto label</span>
               </DropdownMenuSubTrigger>
               <DropdownMenuPortal>
-                <LabelsSubMenu labels={labels} onClick={(labelId) => {}} />
+                <LabelsSubMenu 
+                  labels={labels} 
+                  onClick={async (label) => {
+                    const res = await createFilterAction(category, label.id);
+                    if (isActionError(res)) {
+                      toastError({
+                        title: "Error",
+                        description: `Failed to set up auto-label. ${res.error}`,
+                      });
+                    } else {
+                      toastSuccess({
+                        title: "Success",
+                        description: "Auto-label rule created",
+                      });
+                    }
+                  }} 
+                />
               </DropdownMenuPortal>
             </DropdownMenuSub>

The "Auto archive" menu item should use the existing onArchiveAll handler that's already defined and used elsewhere in the component:

-            <DropdownMenuItem>
+            <DropdownMenuItem onClick={onArchiveAll}>
               <ArchiveIcon className="mr-2 size-4" />
               Auto archive
             </DropdownMenuItem>
🔗 Analysis chain

Implementation incomplete: Missing click handlers

Several interactive elements are missing their click handlers:

  1. The "Auto archive" menu item has no onClick handler
  2. Both LabelsSubMenu components have empty onClick handlers

Consider implementing the handlers like this:

-            <DropdownMenuItem>
+            <DropdownMenuItem onClick={onArchiveAll}>
               <ArchiveIcon className="mr-2 size-4" />
               Auto archive
             </DropdownMenuItem>

             <DropdownMenuSub>
               <DropdownMenuSubTrigger>
                 <TagsIcon className="mr-2 size-4" />
                 <span>Auto archive and label</span>
               </DropdownMenuSubTrigger>
               <DropdownMenuPortal>
-                <LabelsSubMenu labels={labels} onClick={(labelId) => {}} />
+                <LabelsSubMenu 
+                  labels={labels} 
+                  onClick={(labelId) => {
+                    // TODO: Implement archive and label logic
+                  }} 
+                />
               </DropdownMenuPortal>
             </DropdownMenuSub>

             <DropdownMenuSub>
               <DropdownMenuSubTrigger>
                 <TagIcon className="mr-2 size-4" />
                 <span>Auto label</span>
               </DropdownMenuSubTrigger>
               <DropdownMenuPortal>
-                <LabelsSubMenu labels={labels} onClick={(labelId) => {}} />
+                <LabelsSubMenu 
+                  labels={labels} 
+                  onClick={(labelId) => {
+                    // TODO: Implement label logic
+                  }} 
+                />
               </DropdownMenuPortal>
             </DropdownMenuSub>

Let's verify if there are any existing label-related actions we can reuse:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for label-related action implementations
rg -g '!*.test.*' -g '!*.spec.*' "label.*action" ./apps/web/

Length of output: 1185


Script:

#!/bin/bash
# Let's check for any existing handlers or functions related to archiving and labeling
rg -g '!*.test.*' -g '!*.spec.*' -A 5 "onArchive|handleArchive|handleLabel" ./apps/web/

# Also search for any existing implementations of LabelsSubMenu
ast-grep --pattern 'const LabelsSubMenu = $_'

Length of output: 14792


Script:

#!/bin/bash
# Let's check for the LabelsSubMenu component implementation and any label-related handlers
rg -g '!*.test.*' -g '!*.spec.*' "LabelsSubMenu" -A 10 ./apps/web/

# Also search for any label-related mutations or handlers
rg -g '!*.test.*' -g '!*.spec.*' "addLabel|applyLabel|handleLabel" ./apps/web/

Length of output: 6730

@elie222
Copy link
Owner Author

elie222 commented Dec 21, 2024

Handled via #275 instead

@elie222 elie222 closed this Dec 21, 2024
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.

1 participant

Comments