@open-workspace/email 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -22
- package/alchemy/index.ts +273 -0
- package/drizzle/mailbox/0000_puzzling_dracula.sql +149 -0
- package/drizzle/mailbox/0001_mute_jack_flag.sql +12 -0
- package/drizzle/mailbox/meta/0000_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/0001_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/_journal.json +20 -0
- package/drizzle/mailbox/migrations.js +12 -0
- package/index.ts +3 -1
- package/migrations/{0000_email.sql → 0000_dry_moon_knight.sql} +26 -20
- package/migrations/meta/0000_snapshot.json +125 -109
- package/migrations/meta/_journal.json +2 -2
- package/package.json +74 -68
- package/shared/attachment-preview.ts +37 -27
- package/shared/folder-order.ts +106 -0
- package/shared/mail-authentication.ts +8 -3
- package/shared/mail-feedback.ts +18 -25
- package/shared/mail-headers.ts +114 -39
- package/shared/mail-import.ts +38 -0
- package/shared/mail-path.ts +42 -0
- package/shared/mail-received.ts +174 -31
- package/shared/mail-remote.ts +59 -2
- package/shared/mail-sender-intel.ts +22 -4
- package/shared/mail.ts +77 -28
- package/shared/module.ts +33 -0
- package/shared/office-preview.ts +14 -2
- package/shared/pdfjs-assets.ts +35 -0
- package/shared/permissions.ts +73 -0
- package/shared/webhooks.ts +41 -0
- package/src/admin/blocked-senders.tsx +189 -0
- package/src/client.tsx +97 -0
- package/src/lib/mail-api.ts +9 -0
- package/src/mail/attachment-preview-dialog.tsx +161 -0
- package/src/mail/blocked-senders.tsx +138 -0
- package/src/mail/compose-window-chrome.tsx +194 -0
- package/src/mail/compose-window.tsx +486 -0
- package/src/mail/composer-asset-bookmarks.ts +409 -0
- package/src/mail/composer-asset.tsx +229 -0
- package/src/mail/composer-attachment-list.tsx +138 -0
- package/src/mail/composer-editor-document.ts +65 -0
- package/src/mail/composer-editor.tsx +284 -0
- package/src/mail/composer-linked-attachment-text.ts +12 -0
- package/src/mail/composer-recipient-fields.tsx +165 -0
- package/src/mail/composer-recipients.ts +208 -0
- package/src/mail/composer-session.ts +562 -0
- package/src/mail/composer-toolbar.tsx +303 -0
- package/src/mail/composer-upload-client.ts +105 -0
- package/src/mail/composer-upload-progress.ts +53 -0
- package/src/mail/conversation-list.tsx +550 -0
- package/src/mail/conversation-loading-skeleton.tsx +119 -0
- package/src/mail/conversation-message.tsx +346 -0
- package/src/mail/conversation-reply.tsx +470 -0
- package/src/mail/conversation-selection-toolbar.tsx +322 -0
- package/src/mail/conversation-view.tsx +437 -0
- package/src/mail/delivery-indicator.tsx +272 -0
- package/src/mail/email-html-body.tsx +203 -0
- package/src/mail/folder-glyph.tsx +46 -0
- package/src/mail/folder-manager.tsx +532 -0
- package/src/mail/format-bytes.ts +7 -0
- package/src/mail/mail-app-bar.tsx +253 -0
- package/src/mail/mail-background.tsx +12 -0
- package/src/mail/mail-dock.tsx +137 -0
- package/src/mail/mail-folders.ts +44 -0
- package/src/mail/mail-layout.css +236 -0
- package/src/mail/mail-location.ts +73 -0
- package/src/mail/mail-mailbox-sheet.tsx +275 -0
- package/src/mail/mail-nav-rail.tsx +129 -0
- package/src/mail/mail-nav.tsx +324 -0
- package/src/mail/mail-prefetch.ts +59 -0
- package/src/mail/mail-primitives.tsx +66 -0
- package/src/mail/mail-queries.ts +209 -0
- package/src/mail/mail-query-cache.ts +486 -0
- package/src/mail/mail-seed.ts +47 -0
- package/src/mail/mail-shell.tsx +126 -0
- package/src/mail/mailbox-ai-settings.tsx +185 -0
- package/src/mail/mailbox-realtime.tsx +251 -0
- package/src/mail/mailbox-route.tsx +15 -0
- package/src/mail/message-actions.tsx +353 -0
- package/src/mail/message-attachments.tsx +200 -0
- package/src/mail/message-format.ts +75 -0
- package/src/mail/message-header.tsx +260 -0
- package/src/mail/message-translation.tsx +225 -0
- package/src/mail/original-message-sheet.tsx +619 -0
- package/src/mail/original-message.ts +191 -0
- package/src/mail/outbound-notification.ts +53 -0
- package/src/mail/pane-splitter.tsx +117 -0
- package/src/mail/pdf-preview-toolbar.tsx +152 -0
- package/src/mail/pdf-preview.css +44 -0
- package/src/mail/pdf-preview.tsx +156 -0
- package/src/mail/pdf-translation-layout.ts +95 -0
- package/src/mail/print-message.ts +92 -0
- package/src/mail/reader-pane.tsx +535 -0
- package/src/mail/recipient-combobox.tsx +335 -0
- package/src/mail/recipient-field-row.tsx +34 -0
- package/src/mail/reply-to-warning.tsx +50 -0
- package/src/mail/sanitize-email-html.ts +430 -0
- package/src/mail/sender-actions.tsx +149 -0
- package/src/mail/sender-authentication.tsx +485 -0
- package/src/mail/sender-dialogs.tsx +384 -0
- package/src/mail/sender-security.tsx +545 -0
- package/src/mail/toolbar-tooltip.tsx +29 -0
- package/src/mail/translation-html.ts +49 -0
- package/src/mail/translation-language.ts +21 -0
- package/src/mail/types.ts +53 -0
- package/src/mail/unread-document-indicator.tsx +60 -0
- package/src/mail/use-compose-submission.ts +208 -0
- package/src/mail/use-composer-attachment-preflight.ts +184 -0
- package/src/mail/use-composer-submission.ts +117 -0
- package/src/mail/use-conversation-selection.ts +186 -0
- package/src/mail/use-mail-controller.ts +427 -0
- package/src/mail/use-mail-data.ts +279 -0
- package/src/mail/use-mail-safety.ts +155 -0
- package/src/mail/use-mail-send.ts +142 -0
- package/src/mail/use-pdf-translation-overlay.ts +156 -0
- package/src/mail/use-pdf-translation.ts +100 -0
- package/src/mail/use-pdf-viewer.ts +215 -0
- package/src/mail/use-reply-submission.ts +114 -0
- package/src/mail/use-sanitized-email-html.ts +20 -0
- package/src/mail/use-visible-message-read.ts +138 -0
- package/src/pwa/push-subscription.ts +151 -0
- package/src/settings/mail-apps-page.tsx +235 -0
- package/src/settings/notifications-page.tsx +291 -0
- package/worker/admin/blocked-sender-routes.ts +166 -0
- package/worker/admin/schemas.ts +11 -0
- package/worker/bindings.d.ts +14 -10
- package/worker/db/schema.ts +63 -40
- package/worker/jmap/eventsource.ts +84 -16
- package/worker/jmap/methods.ts +1630 -524
- package/worker/jmap/push-types.ts +27 -0
- package/worker/jmap/push.ts +140 -56
- package/worker/jmap/routes.ts +366 -105
- package/worker/mail/access.ts +258 -21
- package/worker/mail/ai-classification.ts +36 -20
- package/worker/mail/ai-translation.ts +13 -6
- package/worker/mail/auth-headers.ts +395 -137
- package/worker/mail/bimi.ts +200 -73
- package/worker/mail/bootstrap.ts +79 -0
- package/worker/mail/capped-body.ts +36 -0
- package/worker/mail/classification-signals.ts +35 -25
- package/worker/mail/conversation-cursor.ts +30 -19
- package/worker/mail/delivery-events.ts +88 -62
- package/worker/mail/delivery-facts.ts +46 -10
- package/worker/mail/demo-routes.ts +34 -10
- package/worker/mail/doh.ts +62 -23
- package/worker/mail/downloads.ts +75 -40
- package/worker/mail/edge-cache.ts +155 -0
- package/worker/mail/header-metadata.ts +88 -22
- package/worker/mail/impersonation.ts +160 -38
- package/worker/mail/import-routes.ts +313 -0
- package/worker/mail/inbound-delivery.ts +19 -9
- package/worker/mail/inbound-threading.ts +18 -8
- package/worker/mail/inbound.ts +82 -40
- package/worker/mail/ip-intel.ts +110 -27
- package/worker/mail/isolate-cache.ts +35 -0
- package/worker/mail/link-domains.ts +29 -7
- package/worker/mail/mailbox-deletion.ts +10 -4
- package/worker/mail/mailbox-directory.ts +16 -6
- package/worker/mail/mailing-list.ts +94 -39
- package/worker/mail/message-security.ts +90 -15
- package/worker/mail/message-view.ts +18 -6
- package/worker/mail/office-conversion.ts +31 -9
- package/worker/mail/office-preview-container.ts +40 -13
- package/worker/mail/office-preview-queue.ts +76 -32
- package/worker/mail/org-domain.ts +8 -1
- package/worker/mail/outbound-content.ts +71 -26
- package/worker/mail/outbound-delivery.ts +31 -17
- package/worker/mail/outbound-service.ts +48 -30
- package/worker/mail/outbound-threading.ts +30 -17
- package/worker/mail/outbound.ts +97 -70
- package/worker/mail/outgoing-context.ts +25 -15
- package/worker/mail/participants.ts +44 -29
- package/worker/mail/push-notifications.ts +271 -173
- package/worker/mail/quote-parser.ts +21 -10
- package/worker/mail/r2-presigned-urls.ts +31 -25
- package/worker/mail/receive.ts +23 -11
- package/worker/mail/recipients.ts +6 -1
- package/worker/mail/remote-proxy.ts +187 -31
- package/worker/mail/remote-routes.ts +87 -0
- package/worker/mail/remote-token.ts +104 -0
- package/worker/mail/repeat.ts +19 -0
- package/worker/mail/reply-plan.ts +62 -33
- package/worker/mail/rfc.ts +32 -7
- package/worker/mail/routes.ts +870 -541
- package/worker/mail/safety-routes.ts +328 -200
- package/worker/mail/schemas.ts +84 -105
- package/worker/mail/search.ts +1 -0
- package/worker/mail/security-settings.ts +41 -9
- package/worker/mail/sender-intel.ts +206 -51
- package/worker/mail/spamhaus.ts +92 -45
- package/worker/mail/unsubscribe.ts +76 -18
- package/worker/mail/uploads.ts +126 -93
- package/worker/mail/webhook-source.ts +35 -12
- package/worker/mail/workspace-safety.ts +97 -38
- package/worker/mailbox/demo-html.ts +7 -7
- package/worker/mailbox/demo-seed.ts +10 -44
- package/worker/mailbox/demo.ts +595 -225
- package/worker/mailbox/email-index.ts +53 -0
- package/worker/mailbox/folder-model.ts +53 -17
- package/worker/mailbox/import-placement.ts +88 -0
- package/worker/mailbox/inbox-counts.ts +106 -0
- package/worker/mailbox/index.ts +1734 -721
- package/worker/mailbox/jmap-store.ts +139 -35
- package/worker/mailbox/model.ts +8 -6
- package/worker/mailbox/office-preview-jobs.ts +56 -25
- package/worker/mailbox/schema.ts +87 -66
- package/worker/mailbox/senders.ts +176 -70
- package/worker/mcp/mail-action-tools.ts +128 -87
- package/worker/mcp/mail-compose-tools.ts +133 -82
- package/worker/mcp/mail-query-tools.ts +120 -71
- package/worker/mcp/mail-safety-tools.ts +321 -248
- package/worker/mcp/schemas.ts +43 -0
- package/worker/mcp/tools.ts +13 -10
- package/worker/module.ts +43 -18
- package/worker/sql.d.ts +8 -0
- package/alchemy.ts +0 -142
- package/containers/office-preview/Dockerfile +0 -10
- package/shared/mail-rules.ts +0 -156
- package/worker/admin/report-routes.ts +0 -164
- package/worker/mail/reported-messages.ts +0 -68
- package/worker/mailbox/migrations.ts +0 -10
- package/worker/mailbox/rules.ts +0 -110
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { apiFetch } from "@open-workspace/core/ui";
|
|
2
|
+
import { hc } from "hono/client";
|
|
3
|
+
|
|
4
|
+
import type { MailAppType } from "../../worker/module";
|
|
5
|
+
|
|
6
|
+
/** Typed client for the mail module's routes. */
|
|
7
|
+
export const mailApi = hc<MailAppType>(window.location.origin, {
|
|
8
|
+
fetch: apiFetch,
|
|
9
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buttonVariants,
|
|
3
|
+
DialogContent,
|
|
4
|
+
DialogDescription,
|
|
5
|
+
DialogTitle,
|
|
6
|
+
} from "@open-workspace/core/ui";
|
|
7
|
+
import { Download, LoaderCircle } from "lucide-react";
|
|
8
|
+
import { lazy, Suspense, useState } from "react";
|
|
9
|
+
|
|
10
|
+
import type { attachmentPreview } from "../../shared/attachment-preview";
|
|
11
|
+
import type { PdfPreviewStatus } from "../../shared/office-preview";
|
|
12
|
+
import { formatBytes } from "./format-bytes";
|
|
13
|
+
import type { MessageAttachment } from "./types";
|
|
14
|
+
|
|
15
|
+
const PdfPreview = lazy(() => import("./pdf-preview"));
|
|
16
|
+
|
|
17
|
+
export function AttachmentPreviewDialog({
|
|
18
|
+
attachment,
|
|
19
|
+
preview,
|
|
20
|
+
previewUrl,
|
|
21
|
+
downloadUrl,
|
|
22
|
+
messageId,
|
|
23
|
+
mailboxId,
|
|
24
|
+
}: {
|
|
25
|
+
attachment: MessageAttachment;
|
|
26
|
+
preview: NonNullable<ReturnType<typeof attachmentPreview>>;
|
|
27
|
+
previewUrl: string;
|
|
28
|
+
downloadUrl: string;
|
|
29
|
+
messageId: string;
|
|
30
|
+
mailboxId: string;
|
|
31
|
+
}) {
|
|
32
|
+
return (
|
|
33
|
+
<DialogContent className="flex h-[90dvh] max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-7xl">
|
|
34
|
+
<div className="flex min-w-0 items-center gap-3 border-b px-4 py-3 pr-12">
|
|
35
|
+
<div className="min-w-0 flex-1">
|
|
36
|
+
<DialogTitle
|
|
37
|
+
className="truncate leading-6"
|
|
38
|
+
title={attachment.filename}
|
|
39
|
+
>
|
|
40
|
+
{attachment.filename}
|
|
41
|
+
</DialogTitle>
|
|
42
|
+
<DialogDescription className="text-xs">
|
|
43
|
+
{formatBytes(attachment.size)}
|
|
44
|
+
</DialogDescription>
|
|
45
|
+
</div>
|
|
46
|
+
<a
|
|
47
|
+
className={buttonVariants({ variant: "outline", size: "sm" })}
|
|
48
|
+
href={downloadUrl}
|
|
49
|
+
download={attachment.filename}
|
|
50
|
+
>
|
|
51
|
+
<Download /> Download
|
|
52
|
+
</a>
|
|
53
|
+
</div>
|
|
54
|
+
<AttachmentPreviewContent
|
|
55
|
+
filename={attachment.filename}
|
|
56
|
+
kind={preview.kind}
|
|
57
|
+
url={previewUrl}
|
|
58
|
+
status={attachment.pdfPreviewStatus}
|
|
59
|
+
messageId={messageId}
|
|
60
|
+
mailboxId={mailboxId}
|
|
61
|
+
/>
|
|
62
|
+
</DialogContent>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function AttachmentPreviewContent({
|
|
67
|
+
filename,
|
|
68
|
+
kind,
|
|
69
|
+
url,
|
|
70
|
+
status,
|
|
71
|
+
messageId,
|
|
72
|
+
mailboxId,
|
|
73
|
+
}: {
|
|
74
|
+
filename: string;
|
|
75
|
+
kind: "pdf" | "image" | "text";
|
|
76
|
+
url: string;
|
|
77
|
+
status?: PdfPreviewStatus | null;
|
|
78
|
+
messageId: string;
|
|
79
|
+
mailboxId: string;
|
|
80
|
+
}) {
|
|
81
|
+
const [loading, setLoading] = useState(true);
|
|
82
|
+
const [failed, setFailed] = useState(false);
|
|
83
|
+
const unavailable = failed || status === "failed";
|
|
84
|
+
|
|
85
|
+
if (status === "pending") {
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
role="status"
|
|
89
|
+
className="text-muted-foreground grid min-h-0 flex-1 place-content-center justify-items-center gap-3"
|
|
90
|
+
>
|
|
91
|
+
<LoaderCircle className="size-6 animate-spin" />
|
|
92
|
+
<span>Generating preview</span>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (kind === "pdf" && !unavailable) {
|
|
98
|
+
return (
|
|
99
|
+
<Suspense
|
|
100
|
+
fallback={
|
|
101
|
+
<div role="status" className="grid flex-1 place-items-center">
|
|
102
|
+
<LoaderCircle className="size-6 animate-spin" />
|
|
103
|
+
<span className="sr-only">Loading PDF</span>
|
|
104
|
+
</div>
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
<PdfPreview
|
|
108
|
+
key={url}
|
|
109
|
+
url={url}
|
|
110
|
+
filename={filename}
|
|
111
|
+
messageId={messageId}
|
|
112
|
+
mailboxId={mailboxId}
|
|
113
|
+
/>
|
|
114
|
+
</Suspense>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="bg-surface-sunken relative min-h-0 flex-1">
|
|
120
|
+
{unavailable ? (
|
|
121
|
+
<p
|
|
122
|
+
role="status"
|
|
123
|
+
className="text-muted-foreground grid h-full place-items-center p-6 text-sm"
|
|
124
|
+
>
|
|
125
|
+
Preview unavailable
|
|
126
|
+
</p>
|
|
127
|
+
) : (
|
|
128
|
+
<>
|
|
129
|
+
{loading && (
|
|
130
|
+
<div
|
|
131
|
+
role="status"
|
|
132
|
+
className="pointer-events-none absolute inset-0 grid place-items-center"
|
|
133
|
+
>
|
|
134
|
+
<LoaderCircle className="text-muted-foreground size-6 animate-spin" />
|
|
135
|
+
<span className="sr-only">Loading preview</span>
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
{kind === "image" ? (
|
|
139
|
+
<img
|
|
140
|
+
src={url}
|
|
141
|
+
alt={filename}
|
|
142
|
+
className="h-full w-full object-contain p-4"
|
|
143
|
+
onLoad={() => setLoading(false)}
|
|
144
|
+
onError={() => setFailed(true)}
|
|
145
|
+
/>
|
|
146
|
+
) : (
|
|
147
|
+
<iframe
|
|
148
|
+
src={url}
|
|
149
|
+
title={`Preview of ${filename}`}
|
|
150
|
+
className="h-full w-full border-0 bg-white"
|
|
151
|
+
sandbox=""
|
|
152
|
+
referrerPolicy="no-referrer"
|
|
153
|
+
onLoad={() => setLoading(false)}
|
|
154
|
+
onError={() => setFailed(true)}
|
|
155
|
+
/>
|
|
156
|
+
)}
|
|
157
|
+
</>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Button, Input, Skeleton } from "@open-workspace/core/ui";
|
|
2
|
+
import { Building2, LoaderCircle, ShieldBan } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import type { FormEvent } from "react";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
|
|
7
|
+
import { normalizeBlockPattern } from "../../shared/mail-feedback";
|
|
8
|
+
import {
|
|
9
|
+
useBlockedSenders,
|
|
10
|
+
useBlockSender,
|
|
11
|
+
useUnblockSender,
|
|
12
|
+
} from "./use-mail-safety";
|
|
13
|
+
|
|
14
|
+
/** Blocked tab: per-mailbox blocks with unblock, and the administrator's blocks read-only. */
|
|
15
|
+
export function BlockedSendersManager({
|
|
16
|
+
mailboxId,
|
|
17
|
+
active,
|
|
18
|
+
}: {
|
|
19
|
+
mailboxId: string;
|
|
20
|
+
active: boolean;
|
|
21
|
+
}) {
|
|
22
|
+
const blocked = useBlockedSenders(mailboxId, active);
|
|
23
|
+
const block = useBlockSender();
|
|
24
|
+
const unblock = useUnblockSender();
|
|
25
|
+
const [value, setValue] = useState("");
|
|
26
|
+
const pattern = normalizeBlockPattern(value);
|
|
27
|
+
|
|
28
|
+
function submit(event: FormEvent) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
|
|
31
|
+
if (!pattern) return;
|
|
32
|
+
block.mutate(
|
|
33
|
+
{ mailboxId, pattern, moveExisting: false },
|
|
34
|
+
{
|
|
35
|
+
onSuccess: (result) => {
|
|
36
|
+
setValue("");
|
|
37
|
+
toast.success(`Blocked ${result.block.pattern}`);
|
|
38
|
+
},
|
|
39
|
+
onError: (error) => toast.error(error.message),
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const items = blocked.data?.blocked ?? [];
|
|
45
|
+
const workspace = blocked.data?.workspace ?? [];
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="space-y-3">
|
|
49
|
+
<form className="flex gap-2" onSubmit={submit}>
|
|
50
|
+
<Input
|
|
51
|
+
aria-label="Address or domain to block"
|
|
52
|
+
placeholder="name@example.com or example.com"
|
|
53
|
+
value={value}
|
|
54
|
+
onChange={(event) => setValue(event.target.value)}
|
|
55
|
+
/>
|
|
56
|
+
<Button
|
|
57
|
+
type="submit"
|
|
58
|
+
variant="outline"
|
|
59
|
+
disabled={!pattern || block.isPending}
|
|
60
|
+
>
|
|
61
|
+
{block.isPending ? (
|
|
62
|
+
<LoaderCircle className="animate-spin" />
|
|
63
|
+
) : (
|
|
64
|
+
<ShieldBan />
|
|
65
|
+
)}
|
|
66
|
+
Block
|
|
67
|
+
</Button>
|
|
68
|
+
</form>
|
|
69
|
+
<div className="border-border/70 max-h-[min(23rem,50vh)] overflow-y-auto border-y">
|
|
70
|
+
{blocked.isLoading ? (
|
|
71
|
+
<div className="space-y-2 py-3">
|
|
72
|
+
<Skeleton className="h-10" />
|
|
73
|
+
<Skeleton className="h-10" />
|
|
74
|
+
</div>
|
|
75
|
+
) : items.length || workspace.length ? (
|
|
76
|
+
<ul aria-label="Blocked senders">
|
|
77
|
+
{items.map((item) => (
|
|
78
|
+
<li
|
|
79
|
+
key={item.pattern}
|
|
80
|
+
className="border-border/60 flex min-h-12 items-center gap-3 border-b px-2 py-2 last:border-b-0"
|
|
81
|
+
>
|
|
82
|
+
<ShieldBan className="text-muted-foreground size-4 shrink-0" />
|
|
83
|
+
<div className="min-w-0 flex-1">
|
|
84
|
+
<p className="truncate text-sm font-medium">{item.pattern}</p>
|
|
85
|
+
<p className="text-muted-foreground text-xs">
|
|
86
|
+
{item.scope === "domain" ? "Whole domain" : "Address"} ·
|
|
87
|
+
blocked{" "}
|
|
88
|
+
{new Date(item.blockedAt).toLocaleDateString("en", {
|
|
89
|
+
dateStyle: "medium",
|
|
90
|
+
})}
|
|
91
|
+
</p>
|
|
92
|
+
</div>
|
|
93
|
+
<Button
|
|
94
|
+
type="button"
|
|
95
|
+
variant="ghost"
|
|
96
|
+
size="sm"
|
|
97
|
+
aria-label={`Unblock ${item.pattern}`}
|
|
98
|
+
disabled={unblock.isPending}
|
|
99
|
+
onClick={() =>
|
|
100
|
+
unblock.mutate(
|
|
101
|
+
{ mailboxId, pattern: item.pattern },
|
|
102
|
+
{
|
|
103
|
+
onSuccess: () =>
|
|
104
|
+
toast.success(`Unblocked ${item.pattern}`),
|
|
105
|
+
onError: (error) => toast.error(error.message),
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
>
|
|
110
|
+
Unblock
|
|
111
|
+
</Button>
|
|
112
|
+
</li>
|
|
113
|
+
))}
|
|
114
|
+
{workspace.map((item) => (
|
|
115
|
+
<li
|
|
116
|
+
key={`workspace-${item.pattern}`}
|
|
117
|
+
className="border-border/60 flex min-h-12 items-center gap-3 border-b px-2 py-2 last:border-b-0"
|
|
118
|
+
>
|
|
119
|
+
<Building2 className="text-muted-foreground size-4 shrink-0" />
|
|
120
|
+
<div className="min-w-0 flex-1">
|
|
121
|
+
<p className="truncate text-sm font-medium">{item.pattern}</p>
|
|
122
|
+
<p className="text-muted-foreground text-xs">
|
|
123
|
+
Blocked for everyone by an administrator
|
|
124
|
+
</p>
|
|
125
|
+
</div>
|
|
126
|
+
</li>
|
|
127
|
+
))}
|
|
128
|
+
</ul>
|
|
129
|
+
) : (
|
|
130
|
+
<div className="text-muted-foreground grid min-h-28 place-items-center px-6 text-center text-sm">
|
|
131
|
+
Blocked senders go straight to Spam. Block one from a message's More
|
|
132
|
+
menu, or add it here.
|
|
133
|
+
</div>
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Button, cn } from "@open-workspace/core/ui";
|
|
2
|
+
import {
|
|
3
|
+
ChevronUp,
|
|
4
|
+
ImagePlus,
|
|
5
|
+
LoaderCircle,
|
|
6
|
+
Minus,
|
|
7
|
+
Paperclip,
|
|
8
|
+
Send,
|
|
9
|
+
X,
|
|
10
|
+
} from "lucide-react";
|
|
11
|
+
import type { Ref, RefObject } from "react";
|
|
12
|
+
|
|
13
|
+
import type { ComposerAsset } from "./composer-session";
|
|
14
|
+
import { formatBytes } from "./format-bytes";
|
|
15
|
+
import type { MessageDetail } from "./types";
|
|
16
|
+
|
|
17
|
+
export function MinimizedComposer({
|
|
18
|
+
subject,
|
|
19
|
+
restoreRef,
|
|
20
|
+
onRestore,
|
|
21
|
+
onClose,
|
|
22
|
+
}: {
|
|
23
|
+
subject: string;
|
|
24
|
+
restoreRef?: Ref<HTMLButtonElement>;
|
|
25
|
+
onRestore: () => void;
|
|
26
|
+
onClose: () => void;
|
|
27
|
+
}) {
|
|
28
|
+
return (
|
|
29
|
+
<section
|
|
30
|
+
aria-label="Minimized message composer"
|
|
31
|
+
className="animate-rise bg-surface ring-border fixed right-6 bottom-6 z-50 flex h-13 w-[min(380px,calc(100vw-2rem))] items-center gap-1 rounded-xl pr-1.5 pl-4 shadow-2xl ring-1"
|
|
32
|
+
>
|
|
33
|
+
<button
|
|
34
|
+
ref={restoreRef}
|
|
35
|
+
type="button"
|
|
36
|
+
className="focus-visible:ring-ring min-w-0 flex-1 truncate rounded-sm text-left text-sm font-semibold outline-none focus-visible:ring-2"
|
|
37
|
+
onClick={onRestore}
|
|
38
|
+
>
|
|
39
|
+
{subject || "New message"}
|
|
40
|
+
</button>
|
|
41
|
+
<Button variant="ghost" size="icon-sm" onClick={onRestore}>
|
|
42
|
+
<ChevronUp />
|
|
43
|
+
<span className="sr-only">Restore composer</span>
|
|
44
|
+
</Button>
|
|
45
|
+
<Button variant="ghost" size="icon-sm" onClick={onClose}>
|
|
46
|
+
<X />
|
|
47
|
+
<span className="sr-only">Close composer</span>
|
|
48
|
+
</Button>
|
|
49
|
+
</section>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function ComposeWindowHeader({
|
|
54
|
+
from,
|
|
55
|
+
minimizeRef,
|
|
56
|
+
onMinimize,
|
|
57
|
+
onClose,
|
|
58
|
+
}: {
|
|
59
|
+
from: string;
|
|
60
|
+
minimizeRef?: Ref<HTMLButtonElement>;
|
|
61
|
+
onMinimize: () => void;
|
|
62
|
+
onClose: () => void;
|
|
63
|
+
}) {
|
|
64
|
+
return (
|
|
65
|
+
<header className="border-border/70 bg-surface-sunken/70 flex h-12 shrink-0 items-center gap-1 border-b pr-1.5 pl-4 sm:rounded-t-xl">
|
|
66
|
+
<div className="min-w-0 flex-1">
|
|
67
|
+
<p className="truncate text-sm font-semibold">New message</p>
|
|
68
|
+
<p className="text-muted-foreground truncate text-[11px]">
|
|
69
|
+
From {from}
|
|
70
|
+
</p>
|
|
71
|
+
</div>
|
|
72
|
+
<Button
|
|
73
|
+
ref={minimizeRef}
|
|
74
|
+
className="hidden sm:inline-flex"
|
|
75
|
+
type="button"
|
|
76
|
+
variant="ghost"
|
|
77
|
+
size="icon-sm"
|
|
78
|
+
onClick={onMinimize}
|
|
79
|
+
>
|
|
80
|
+
<Minus />
|
|
81
|
+
<span className="sr-only">Minimize composer</span>
|
|
82
|
+
</Button>
|
|
83
|
+
<Button type="button" variant="ghost" size="icon-sm" onClick={onClose}>
|
|
84
|
+
<X />
|
|
85
|
+
<span className="sr-only">Close composer</span>
|
|
86
|
+
</Button>
|
|
87
|
+
</header>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function ForwardedMessageNotice({
|
|
92
|
+
message,
|
|
93
|
+
}: {
|
|
94
|
+
message: Pick<
|
|
95
|
+
MessageDetail,
|
|
96
|
+
"fromAddress" | "fromName" | "preview" | "subject"
|
|
97
|
+
>;
|
|
98
|
+
}) {
|
|
99
|
+
return (
|
|
100
|
+
<div className="border-border/70 bg-primary/8 shrink-0 border-b px-4 py-2.5 text-xs">
|
|
101
|
+
<p className="font-semibold">
|
|
102
|
+
Forwarding {message.fromName || message.fromAddress}
|
|
103
|
+
</p>
|
|
104
|
+
<p className="text-muted-foreground mt-0.5 truncate">
|
|
105
|
+
{message.subject} · {message.preview}
|
|
106
|
+
</p>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function ComposeWindowFooter({
|
|
112
|
+
fileInput,
|
|
113
|
+
inlineFileInput,
|
|
114
|
+
uploads,
|
|
115
|
+
error,
|
|
116
|
+
sending,
|
|
117
|
+
sendDisabled,
|
|
118
|
+
onAddAttachments,
|
|
119
|
+
onAddInlineImages,
|
|
120
|
+
}: {
|
|
121
|
+
fileInput: RefObject<HTMLInputElement | null>;
|
|
122
|
+
inlineFileInput: RefObject<HTMLInputElement | null>;
|
|
123
|
+
uploads: readonly ComposerAsset[];
|
|
124
|
+
error: string | null;
|
|
125
|
+
sending: boolean;
|
|
126
|
+
sendDisabled: boolean;
|
|
127
|
+
onAddAttachments: (files: File[]) => void;
|
|
128
|
+
onAddInlineImages: (files: File[]) => void;
|
|
129
|
+
}) {
|
|
130
|
+
return (
|
|
131
|
+
<footer className="border-border/70 bg-surface-sunken/70 flex min-h-14 shrink-0 items-center gap-2 border-t px-3 py-2 sm:rounded-b-xl">
|
|
132
|
+
<input
|
|
133
|
+
ref={fileInput}
|
|
134
|
+
className="sr-only"
|
|
135
|
+
type="file"
|
|
136
|
+
disabled={sending}
|
|
137
|
+
multiple
|
|
138
|
+
onChange={(event) => {
|
|
139
|
+
onAddAttachments(Array.from(event.target.files ?? []));
|
|
140
|
+
event.target.value = "";
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
<input
|
|
144
|
+
ref={inlineFileInput}
|
|
145
|
+
className="sr-only"
|
|
146
|
+
type="file"
|
|
147
|
+
accept="image/png,image/jpeg,image/gif,image/webp"
|
|
148
|
+
multiple
|
|
149
|
+
disabled={sending}
|
|
150
|
+
onChange={(event) => {
|
|
151
|
+
onAddInlineImages(Array.from(event.target.files ?? []));
|
|
152
|
+
event.target.value = "";
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
<Button type="submit" disabled={sendDisabled}>
|
|
156
|
+
{sending ? <LoaderCircle className="animate-spin" /> : <Send />}
|
|
157
|
+
Send
|
|
158
|
+
</Button>
|
|
159
|
+
<Button
|
|
160
|
+
type="button"
|
|
161
|
+
variant="ghost"
|
|
162
|
+
size="icon-sm"
|
|
163
|
+
aria-label="Add attachments"
|
|
164
|
+
disabled={sending}
|
|
165
|
+
onClick={() => fileInput.current?.click()}
|
|
166
|
+
>
|
|
167
|
+
<Paperclip />
|
|
168
|
+
</Button>
|
|
169
|
+
<Button
|
|
170
|
+
type="button"
|
|
171
|
+
variant="ghost"
|
|
172
|
+
size="icon-sm"
|
|
173
|
+
aria-label="Insert inline image"
|
|
174
|
+
disabled={sending}
|
|
175
|
+
onClick={() => inlineFileInput.current?.click()}
|
|
176
|
+
>
|
|
177
|
+
<ImagePlus />
|
|
178
|
+
</Button>
|
|
179
|
+
<span
|
|
180
|
+
className={cn(
|
|
181
|
+
"text-muted-foreground min-w-0 flex-1 truncate text-[11px]",
|
|
182
|
+
error && "text-destructive"
|
|
183
|
+
)}
|
|
184
|
+
>
|
|
185
|
+
{error ||
|
|
186
|
+
(uploads.length
|
|
187
|
+
? `${uploads.length} files · ${formatBytes(
|
|
188
|
+
uploads.reduce((total, upload) => total + upload.size, 0)
|
|
189
|
+
)}`
|
|
190
|
+
: "Drop files into message · up to 500 MB")}
|
|
191
|
+
</span>
|
|
192
|
+
</footer>
|
|
193
|
+
);
|
|
194
|
+
}
|