-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Bulk Archive #1198
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
Merged
Merged
Bulk Archive #1198
Changes from 37 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
5902c4e
Cleaning up the UI/UX of the smart categories page
jshwrnr ff331d9
Add tabs
jshwrnr 5fa78db
Split pages
jshwrnr 547d5a3
Comment out bulk archive and quick bulk archive from early access page
jshwrnr 3b4b8cf
Add automatic sender categorization
jshwrnr 3791f29
Merge branch 'main' into feat/bulk-archive
jshwrnr 486e797
fix: address PR review comments
jshwrnr d93dc93
fix: address additional PR review comments
jshwrnr 80ef765
Merge branch 'main' into feat/bulk-archive
jshwrnr 22e00b0
Fixes
jshwrnr caa93a7
fix: restore marketing submodule reference
jshwrnr 03bb4cc
refactor: extract getCategoryIcon to separate module
jshwrnr 41f8011
Add rel
jshwrnr b580311
Refactor BulkCategorizeSendersAction
jshwrnr 07f0f7d
Add tests
jshwrnr b2e6fc2
Fix
jshwrnr 66d8556
Use both gmail and outlook providers for bulk archiving
jshwrnr 61c0cab
Fix error not being used in catch
jshwrnr b6eda9e
Remove unused code
jshwrnr 590854d
Rename
jshwrnr aef53b0
Fix
jshwrnr 0c39c6f
Fix
jshwrnr 823d56f
Merge branch 'main' into feat/bulk-archive
elie222 714aa6b
Remove unnecessary test
jshwrnr a9645ce
Merge branch 'feat/bulk-archive' of https://github.com/jshwrnr/inbox-…
jshwrnr 60a0d4f
Remove copy from bottom of bulk archive, add onboarding query param f…
jshwrnr 99d7330
Use proper layout plus other styling changes
jshwrnr 81d570b
Remove the gray bar in each bulk archive category
jshwrnr d02d560
Remove menu and modals from bulk archive categories
jshwrnr 72ff54a
Clean up setup flow for bulk archive
jshwrnr 3868dfe
Reduce sender categories down to only four
jshwrnr f68d0b8
Fix up bulk archive setup and content
jshwrnr c4acb68
Fix
jshwrnr 16bc1b3
Fixes
jshwrnr 809035e
Fix
jshwrnr d2fc9d6
Fix
jshwrnr f5939e0
Add shrink-0 to icons in bulk archive list
jshwrnr eec04d0
Fix
jshwrnr 0f4d4c2
Fix
jshwrnr 54f8768
Fix
jshwrnr 7097c53
Fix
jshwrnr 6508671
Fix
jshwrnr b86508f
Add to bulk archive a description tooltip, colored icons, and a notif…
jshwrnr 9de966d
Swap colors of notification and other categories in bulk archive
jshwrnr 91168da
Use TooltipExplanation in bulk archive
jshwrnr ab99c67
Fix
jshwrnr 661ca1b
Fix
jshwrnr 175e377
Merge branch 'main' into feat/bulk-archive
elie222 b44eaf4
remove popsy next config
elie222 76e5e8f
Simplify categories to 5 primary only, refactor to SWR pattern
elie222 2713406
Fix: Replace useMemo with useEffect for side effects in BulkArchiveTab
elie222 de86725
Merge branch 'main' into feat/bulk-archive
elie222 75234fb
copy
elie222 a77f6a9
setup card dialog
elie222 7824f59
Refactor BulkArchive component layout and integrate CategorizeWithAiB…
elie222 a289dee
Merge branch 'main' into feat/bulk-archive
elie222 c5b3627
Add error handling for Qstash queue publishing
elie222 08d37d0
Enhance internal API URL handling
elie222 3dbab3b
styling
elie222 0810ea4
Show caret
elie222 d638572
Merge branch 'main' into feat/bulk-archive
elie222 ae9d724
feat(bulk-archive): allow expanding archived categories and add sende…
elie222 63d82e6
faster onboarding
elie222 8074688
await
elie222 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { redirectToEmailAccountPath } from "@/utils/account"; | ||
|
|
||
| export default async function BulkArchivePage() { | ||
| await redirectToEmailAccountPath("/bulk-archive"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { redirectToEmailAccountPath } from "@/utils/account"; | ||
|
|
||
| export default async function QuickBulkArchivePage() { | ||
| await redirectToEmailAccountPath("/quick-bulk-archive"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
apps/web/app/(app)/[emailAccountId]/bulk-archive/AutoCategorizationSetup.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| "use client"; | ||
|
|
||
| import { useState, useCallback } from "react"; | ||
| import { toast } from "sonner"; | ||
| import { ArchiveIcon, TagsIcon, ZapIcon } from "lucide-react"; | ||
| import { SetupCard } from "@/components/SetupCard"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { bulkCategorizeSendersAction } from "@/utils/actions/categorize"; | ||
| import { useAccount } from "@/providers/EmailAccountProvider"; | ||
| import { useCategorizeProgress } from "@/app/(app)/[emailAccountId]/smart-categories/CategorizeProgress"; | ||
|
|
||
| const features = [ | ||
| { | ||
| icon: <TagsIcon className="size-4 text-blue-500" />, | ||
| title: "Smart categorization", | ||
| description: | ||
| "Automatically group senders into categories like Newsletters, Receipts, and Marketing", | ||
| }, | ||
| { | ||
| icon: <ArchiveIcon className="size-4 text-blue-500" />, | ||
| title: "Bulk actions", | ||
| description: "Archive entire categories at once instead of email by email", | ||
| }, | ||
| { | ||
| icon: <ZapIcon className="size-4 text-blue-500" />, | ||
| title: "Instant cleanup", | ||
| description: "Clear hundreds of emails in seconds, not hours", | ||
| }, | ||
| ]; | ||
|
|
||
| export function AutoCategorizationSetup() { | ||
| const { emailAccountId } = useAccount(); | ||
| const { setIsBulkCategorizing } = useCategorizeProgress(); | ||
|
|
||
| const [isEnabling, setIsEnabling] = useState(false); | ||
|
|
||
| const enableFeature = useCallback(async () => { | ||
| setIsEnabling(true); | ||
| setIsBulkCategorizing(true); | ||
|
|
||
| try { | ||
| const result = await bulkCategorizeSendersAction(emailAccountId); | ||
|
|
||
| if (result?.serverError) { | ||
| throw new Error(result.serverError); | ||
| } | ||
|
|
||
| toast.success( | ||
| result?.data?.totalUncategorizedSenders | ||
| ? `Categorizing ${result.data.totalUncategorizedSenders} senders... This may take a few minutes.` | ||
| : "No uncategorized senders found.", | ||
| ); | ||
jshwrnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } catch (error) { | ||
| toast.error( | ||
| `Failed to enable feature: ${error instanceof Error ? error.message : "Unknown error"}`, | ||
| ); | ||
| setIsBulkCategorizing(false); | ||
| } finally { | ||
| setIsEnabling(false); | ||
| } | ||
| }, [emailAccountId, setIsBulkCategorizing]); | ||
|
|
||
| return ( | ||
| <SetupCard | ||
| imageSrc="/images/illustrations/working-vacation.svg" | ||
| imageAlt="Bulk Archive" | ||
| title="Bulk Archive" | ||
| description="Clean up your inbox by archiving emails in bulk by category." | ||
| features={features} | ||
| > | ||
| <Button onClick={enableFeature} loading={isEnabling}> | ||
| Get Started | ||
| </Button> | ||
| </SetupCard> | ||
| ); | ||
| } | ||
72 changes: 72 additions & 0 deletions
72
apps/web/app/(app)/[emailAccountId]/bulk-archive/BulkArchive.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| "use client"; | ||
|
|
||
| import { useMemo, useCallback } from "react"; | ||
| import useSWR from "swr"; | ||
| import { AutoCategorizationSetup } from "@/app/(app)/[emailAccountId]/bulk-archive/AutoCategorizationSetup"; | ||
| import { BulkArchiveProgress } from "@/app/(app)/[emailAccountId]/bulk-archive/BulkArchiveProgress"; | ||
| import { BulkArchiveCards } from "@/components/BulkArchiveCards"; | ||
| import { useCategorizeProgress } from "@/app/(app)/[emailAccountId]/smart-categories/CategorizeProgress"; | ||
| import type { CategorizedSendersResponse } from "@/app/api/user/categorize/senders/categorized/route"; | ||
| import type { CategoryWithRules } from "@/utils/category.server"; | ||
| import { PageWrapper } from "@/components/PageWrapper"; | ||
| import { PageHeader } from "@/components/PageHeader"; | ||
|
|
||
| type Sender = { | ||
| id: string; | ||
| email: string; | ||
| category: { id: string; description: string | null; name: string } | null; | ||
| }; | ||
|
|
||
| export function BulkArchive({ | ||
| initialSenders, | ||
| initialCategories, | ||
| autoCategorizeSenders, | ||
| }: { | ||
| initialSenders: Sender[]; | ||
| initialCategories: CategoryWithRules[]; | ||
| autoCategorizeSenders: boolean; | ||
| }) { | ||
| const { isBulkCategorizing } = useCategorizeProgress(); | ||
|
|
||
| // Poll for updates while categorization is in progress | ||
| const { data, mutate } = useSWR<CategorizedSendersResponse>( | ||
| "/api/user/categorize/senders/categorized", | ||
| { | ||
| refreshInterval: isBulkCategorizing ? 2000 : undefined, | ||
| fallbackData: { senders: initialSenders, categories: initialCategories }, | ||
| }, | ||
| ); | ||
jshwrnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Use SWR data if available, otherwise fall back to initial server data | ||
| const senders = data?.senders ?? initialSenders; | ||
| const categories = data?.categories ?? initialCategories; | ||
|
|
||
| const emailGroups = useMemo( | ||
| () => | ||
| senders.map((sender) => ({ | ||
| address: sender.email, | ||
| category: categories.find((c) => c.id === sender.category?.id) || null, | ||
| })), | ||
| [senders, categories], | ||
| ); | ||
|
|
||
| const handleProgressComplete = useCallback(() => { | ||
| mutate(); | ||
| }, [mutate]); | ||
|
|
||
| const shouldShowSetup = !autoCategorizeSenders && !isBulkCategorizing; | ||
|
|
||
| return ( | ||
| <> | ||
| {shouldShowSetup ? ( | ||
| <AutoCategorizationSetup /> | ||
| ) : ( | ||
| <PageWrapper> | ||
| <PageHeader title="Bulk Archive" /> | ||
| <BulkArchiveProgress onComplete={handleProgressComplete} /> | ||
| <BulkArchiveCards emailGroups={emailGroups} categories={categories} /> | ||
| </PageWrapper> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.