@open-workspace/email 0.4.2 → 0.5.0
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 +9 -4
- package/alchemy/index.ts +130 -2
- package/drizzle/mailbox/0003_after_0_4_2.sql +180 -0
- package/drizzle/mailbox/meta/0003_snapshot.json +1507 -0
- package/drizzle/mailbox/meta/_journal.json +7 -0
- package/drizzle/mailbox/migrations.js +3 -1
- package/migrations/0002_after_0_4_2.sql +35 -0
- package/migrations/meta/0002_snapshot.json +807 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +23 -7
- package/shared/attachment-preview.ts +18 -8
- package/shared/folder-order.ts +31 -6
- package/shared/mail-headers.ts +3 -3
- package/shared/mail-html.ts +25 -0
- package/shared/mail-import.ts +0 -7
- package/shared/mail-received.ts +4 -4
- package/shared/mail-rule-actions.ts +47 -0
- package/shared/mail.ts +70 -4
- package/shared/office-preview.ts +0 -4
- package/shared/pdfjs-assets.ts +1 -3
- package/shared/rich-content.ts +35 -0
- package/shared/signature.ts +15 -0
- package/src/admin/address-auto-reply.tsx +49 -0
- package/src/admin/blocked-senders.tsx +86 -66
- package/src/admin/forward-destinations.tsx +140 -0
- package/src/admin/mail-archive.tsx +134 -0
- package/src/admin/team-signature.tsx +90 -0
- package/src/client.tsx +130 -16
- package/src/mail/attachment-preview-dialog.tsx +13 -5
- package/src/mail/auto-reply-banner.tsx +61 -0
- package/src/mail/blocked-senders.tsx +124 -91
- package/src/mail/compose-window-chrome.tsx +20 -8
- package/src/mail/compose-window.tsx +387 -365
- package/src/mail/composer-asset-bookmarks.ts +47 -12
- package/src/mail/composer-attachment-list.tsx +42 -17
- package/src/mail/composer-editor-document.ts +54 -10
- package/src/mail/composer-editor.tsx +44 -44
- package/src/mail/composer-link-text.ts +42 -0
- package/src/mail/composer-recipient-fields.tsx +25 -16
- package/src/mail/composer-recipients.ts +62 -16
- package/src/mail/composer-session.ts +107 -23
- package/src/mail/composer-toolbar.tsx +15 -1
- package/src/mail/composer-upload-client.ts +29 -1
- package/src/mail/composer-upload-progress.ts +2 -2
- package/src/mail/conversation-actions-model.ts +56 -0
- package/src/mail/conversation-list.tsx +263 -128
- package/src/mail/conversation-loading-skeleton.tsx +165 -90
- package/src/mail/conversation-message.tsx +257 -102
- package/src/mail/conversation-order.ts +12 -0
- package/src/mail/conversation-reply.tsx +313 -189
- package/src/mail/conversation-selection-toolbar.tsx +188 -143
- package/src/mail/conversation-view.tsx +315 -85
- package/src/mail/delivery-indicator.tsx +33 -12
- package/src/mail/draft-attachments.ts +194 -0
- package/src/mail/email-html-body.tsx +97 -53
- package/src/mail/folder-cleanup-bar.tsx +193 -0
- package/src/mail/folder-glyph.tsx +5 -0
- package/src/mail/folder-manager.tsx +71 -38
- package/src/mail/mail-app-bar.tsx +15 -3
- package/src/mail/mail-dock.tsx +19 -3
- package/src/mail/mail-focus.ts +48 -0
- package/src/mail/mail-folders.ts +14 -2
- package/src/mail/mail-layout.css +20 -0
- package/src/mail/mail-mailbox-sheet.tsx +22 -69
- package/src/mail/mail-nav-rail.tsx +7 -4
- package/src/mail/mail-nav.tsx +66 -46
- package/src/mail/mail-prefetch.ts +30 -9
- package/src/mail/mail-primitives.tsx +6 -4
- package/src/mail/mail-queries.ts +122 -20
- package/src/mail/mail-query-cache.ts +1085 -173
- package/src/mail/mail-search-params.ts +35 -0
- package/src/mail/mail-shell.tsx +32 -9
- package/src/mail/mailbox-ai-settings.tsx +56 -42
- package/src/mail/mailbox-realtime.tsx +4 -12
- package/src/mail/mailbox-rules.tsx +898 -0
- package/src/mail/message-actions.tsx +38 -26
- package/src/mail/message-attachments.tsx +20 -12
- package/src/mail/message-body.ts +53 -0
- package/src/mail/message-format.ts +8 -2
- package/src/mail/message-header.tsx +3 -1
- package/src/mail/message-translation.tsx +34 -67
- package/src/mail/original-message-sheet.tsx +63 -50
- package/src/mail/original-message.ts +6 -6
- package/src/mail/pane-splitter.tsx +3 -3
- package/src/mail/pdf-preview.tsx +70 -62
- package/src/mail/plain-message-text.tsx +28 -0
- package/src/mail/print-message.ts +31 -36
- package/src/mail/reader-pane.tsx +134 -103
- package/src/mail/recipient-combobox.tsx +52 -29
- package/src/mail/recipient-field-row.tsx +3 -0
- package/src/mail/rich-content.ts +128 -0
- package/src/mail/sanitize-email-html.ts +53 -32
- package/src/mail/sender-actions.tsx +48 -46
- package/src/mail/sender-authentication.tsx +1 -1
- package/src/mail/sender-dialogs.tsx +67 -43
- package/src/mail/sender-security.tsx +9 -10
- package/src/mail/signature.ts +43 -0
- package/src/mail/translation-html.ts +3 -3
- package/src/mail/types.ts +12 -0
- package/src/mail/use-composer-attachment-preflight.ts +23 -60
- package/src/mail/use-composer-core.ts +286 -0
- package/src/mail/use-composer-navigation.ts +120 -0
- package/src/mail/use-composer-submission.ts +154 -19
- package/src/mail/use-conversation-actions.ts +292 -0
- package/src/mail/use-conversation-position.ts +51 -0
- package/src/mail/use-conversation-selection.ts +192 -89
- package/src/mail/use-draft-autosave.ts +394 -0
- package/src/mail/use-drafts.ts +194 -0
- package/src/mail/use-mail-controller.ts +754 -213
- package/src/mail/use-mail-data.ts +210 -100
- package/src/mail/use-mail-safety.ts +19 -38
- package/src/mail/use-mail-send.ts +18 -6
- package/src/mail/use-pdf-translation.ts +1 -1
- package/src/mail/use-reply-cc.ts +61 -0
- package/src/mail/use-visible-message-read.ts +128 -64
- package/src/pwa/push-key.ts +18 -0
- package/src/pwa/push-subscription.ts +88 -26
- package/src/settings/auto-reply-editor.tsx +454 -0
- package/src/settings/auto-reply-page.tsx +59 -0
- package/src/settings/mail-apps-page.tsx +52 -43
- package/src/settings/notifications-page.tsx +82 -67
- package/src/settings/rich-content-editor.tsx +182 -0
- package/src/settings/settings-queries.ts +57 -0
- package/src/settings/signature-editor.tsx +142 -0
- package/src/settings/signature-page.tsx +70 -0
- package/worker/admin/blocked-sender-routes.ts +10 -16
- package/worker/backups/eml.ts +185 -0
- package/worker/backups/file-parts.ts +140 -0
- package/worker/backups/mail-backup.ts +644 -0
- package/worker/backups/settings-backup.ts +866 -0
- package/worker/backups/stream-eml.ts +73 -0
- package/worker/db/schema.ts +89 -5
- package/worker/jmap/attachment-blobs.ts +113 -0
- package/worker/jmap/blobs.ts +162 -0
- package/worker/jmap/draft-content.ts +42 -0
- package/worker/jmap/drafts.ts +70 -0
- package/worker/jmap/email-body.ts +152 -0
- package/worker/jmap/email-methods.ts +1223 -0
- package/worker/jmap/eventsource.ts +9 -8
- package/worker/jmap/import-methods.ts +205 -0
- package/worker/jmap/mailbox-methods.ts +187 -0
- package/worker/jmap/method-core.ts +379 -0
- package/worker/jmap/methods.ts +108 -1815
- package/worker/jmap/push-subscription-methods.ts +373 -0
- package/worker/jmap/push-types.ts +46 -2
- package/worker/jmap/push.ts +24 -31
- package/worker/jmap/routes.ts +144 -153
- package/worker/jmap/submission-methods.ts +395 -0
- package/worker/mail/access.ts +35 -12
- package/worker/mail/ai-classification.ts +2 -2
- package/worker/mail/archive-object.ts +96 -0
- package/worker/mail/archive-routes.ts +35 -0
- package/worker/mail/archive.ts +682 -0
- package/worker/mail/auth-headers.ts +48 -40
- package/worker/mail/auto-reply-routes.ts +255 -0
- package/worker/mail/auto-reply.ts +243 -0
- package/worker/mail/bimi.ts +53 -36
- package/worker/mail/bootstrap.ts +11 -3
- package/worker/mail/capabilities.ts +69 -0
- package/worker/mail/classification-signals.ts +1 -1
- package/worker/mail/confusables-data.ts +9 -0
- package/worker/mail/conversation-cursor.ts +6 -15
- package/worker/mail/delivery-events.ts +9 -7
- package/worker/mail/delivery-facts.ts +1 -1
- package/worker/mail/demo-routes.ts +3 -3
- package/worker/mail/doh.ts +3 -3
- package/worker/mail/download-links.ts +153 -0
- package/worker/mail/downloads.ts +2 -6
- package/worker/mail/draft-routes.ts +473 -0
- package/worker/mail/draft-sender.ts +54 -0
- package/worker/mail/edge-cache.ts +41 -55
- package/worker/mail/email-routing.ts +123 -0
- package/worker/mail/forward-destinations.ts +114 -0
- package/worker/mail/forward-downloads.ts +115 -0
- package/worker/mail/forward-html.ts +85 -0
- package/worker/mail/header-metadata.ts +2 -5
- package/worker/mail/impersonation.ts +102 -101
- package/worker/mail/import-routes.ts +29 -82
- package/worker/mail/import.ts +130 -0
- package/worker/mail/inbound-delivery.ts +6 -5
- package/worker/mail/inbound.ts +58 -28
- package/worker/mail/ip-intel.ts +8 -17
- package/worker/mail/isolate-cache.ts +1 -1
- package/worker/mail/mailbox-deletion.ts +33 -12
- package/worker/mail/mailbox-directory.ts +39 -65
- package/worker/mail/mailing-list.ts +29 -58
- package/worker/mail/message-security.ts +3 -3
- package/worker/mail/message-view.ts +12 -10
- package/worker/mail/office-conversion.ts +3 -5
- package/worker/mail/office-preview-container.ts +3 -8
- package/worker/mail/outbound-content.ts +139 -65
- package/worker/mail/outbound-delivery.ts +20 -17
- package/worker/mail/outbound-service.ts +34 -9
- package/worker/mail/outbound.ts +146 -75
- package/worker/mail/outgoing-context.ts +60 -30
- package/worker/mail/participants.ts +10 -15
- package/worker/mail/plain-body.ts +39 -0
- package/worker/mail/push-endpoint.ts +17 -0
- package/worker/mail/push-notifications.ts +53 -62
- package/worker/mail/quote-parser.ts +36 -24
- package/worker/mail/receive.ts +146 -39
- package/worker/mail/recipients.ts +1 -1
- package/worker/mail/remote-proxy.ts +3 -3
- package/worker/mail/repeat.ts +1 -1
- package/worker/mail/reply-plan.ts +124 -26
- package/worker/mail/rfc.ts +15 -7
- package/worker/mail/rich-content.ts +207 -0
- package/worker/mail/routes.ts +696 -304
- package/worker/mail/routing.ts +274 -0
- package/worker/mail/rules.ts +230 -0
- package/worker/mail/safety-routes.ts +88 -86
- package/worker/mail/schemas.ts +222 -31
- package/worker/mail/search.ts +25 -2
- package/worker/mail/security-settings.ts +4 -10
- package/worker/mail/send-message.ts +238 -0
- package/worker/mail/sender-intel.ts +12 -20
- package/worker/mail/signature-routes.ts +201 -0
- package/worker/mail/signatures.ts +195 -0
- package/worker/mail/spamhaus.ts +28 -16
- package/worker/mail/storage-keys.ts +35 -0
- package/worker/mail/unsubscribe.ts +19 -41
- package/worker/mail/uploads.ts +192 -80
- package/worker/mail/webhook-source.ts +3 -2
- package/worker/mail/workspace-safety.ts +194 -60
- package/worker/mailbox/demo.ts +13 -15
- package/worker/mailbox/email-index.ts +65 -35
- package/worker/mailbox/folder-model.ts +0 -20
- package/worker/mailbox/import-placement.ts +21 -36
- package/worker/mailbox/inbound-decision.ts +114 -0
- package/worker/mailbox/inbox-counts.ts +45 -25
- package/worker/mailbox/index.ts +756 -3201
- package/worker/mailbox/jmap-change-log.ts +195 -0
- package/worker/mailbox/jmap-email-rows.ts +186 -0
- package/worker/mailbox/jmap-mailboxes.ts +116 -0
- package/worker/mailbox/jmap-placement.ts +139 -0
- package/worker/mailbox/jmap-query-filter.ts +231 -0
- package/worker/mailbox/jmap-store.ts +167 -299
- package/worker/mailbox/mailbox-auto-reply.ts +301 -0
- package/worker/mailbox/mailbox-backup.ts +538 -0
- package/worker/mailbox/mailbox-drafts.ts +417 -0
- package/worker/mailbox/mailbox-folders.ts +242 -0
- package/worker/mailbox/mailbox-import.ts +450 -0
- package/worker/mailbox/mailbox-inbound.ts +934 -0
- package/worker/mailbox/mailbox-jmap.ts +294 -0
- package/worker/mailbox/mailbox-outbound.ts +413 -0
- package/worker/mailbox/mailbox-rules.ts +336 -0
- package/worker/mailbox/mailbox-senders.ts +294 -0
- package/worker/mailbox/mailbox-storage.ts +438 -0
- package/worker/mailbox/mailbox-views.ts +891 -0
- package/worker/mailbox/model.ts +1 -0
- package/worker/mailbox/office-preview-jobs.ts +59 -47
- package/worker/mailbox/placement.ts +933 -0
- package/worker/mailbox/restore-thread.ts +52 -0
- package/worker/mailbox/retention.ts +36 -0
- package/worker/mailbox/schema.ts +200 -1
- package/worker/mailbox/senders.ts +216 -178
- package/worker/mailbox/spam-undo-filing.ts +138 -0
- package/worker/mailbox/spam-undo.ts +240 -0
- package/worker/mailbox/support.ts +416 -0
- package/worker/mcp/mail-action-tools.ts +156 -0
- package/worker/mcp/mail-compose-tools.ts +7 -1
- package/worker/mcp/mail-safety-tools.ts +4 -4
- package/worker/module.ts +23 -4
- package/src/mail/use-compose-submission.ts +0 -208
- package/src/mail/use-reply-submission.ts +0 -114
- package/worker/mail/capped-body.ts +0 -36
package/src/client.tsx
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
import { preloadable } from "@open-workspace/core/ui";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ClientModule,
|
|
4
|
+
TeamAddress,
|
|
5
|
+
UserAddress,
|
|
6
|
+
} from "@open-workspace/core/ui";
|
|
7
|
+
import {
|
|
8
|
+
Archive,
|
|
9
|
+
Bell,
|
|
10
|
+
Mail,
|
|
11
|
+
MonitorSmartphone,
|
|
12
|
+
PenLine,
|
|
13
|
+
Plane,
|
|
14
|
+
ShieldBan,
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
import { lazy, Suspense } from "react";
|
|
5
17
|
|
|
6
18
|
import { MAIL_ROUTE } from "../shared/mail-path";
|
|
7
19
|
import { EMAIL_MODULE } from "../shared/module";
|
|
8
20
|
import { MANAGE_BLOCKED_SENDERS } from "../shared/permissions";
|
|
9
21
|
import { emailWebhookEvents } from "../shared/webhooks";
|
|
22
|
+
import { ForwardDestinations } from "./admin/forward-destinations";
|
|
10
23
|
import { prefetchMail } from "./mail/mail-prefetch";
|
|
11
|
-
import { loadSanitizer } from "./mail/mail-queries";
|
|
24
|
+
import { loadSanitizer, mailboxesQuery } from "./mail/mail-queries";
|
|
12
25
|
import { seedMail } from "./mail/mail-seed";
|
|
26
|
+
import {
|
|
27
|
+
adminBlockedSendersQuery,
|
|
28
|
+
autoReplyMailboxesQuery,
|
|
29
|
+
mailArchiveQuery,
|
|
30
|
+
notificationPreferencesQuery,
|
|
31
|
+
pushConfigQuery,
|
|
32
|
+
signatureQuery,
|
|
33
|
+
} from "./settings/settings-queries";
|
|
13
34
|
|
|
14
35
|
import "./mail/mail-layout.css";
|
|
15
36
|
|
|
@@ -25,6 +46,39 @@ const mailBackground = preloadable(() =>
|
|
|
25
46
|
|
|
26
47
|
const MailboxRoute = mailboxRoute.Component;
|
|
27
48
|
|
|
49
|
+
const TeamSignature = lazy(() =>
|
|
50
|
+
import("./admin/team-signature").then((module) => ({
|
|
51
|
+
default: module.TeamSignature,
|
|
52
|
+
}))
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// Core renders team address sections without a Suspense boundary of their own.
|
|
56
|
+
function TeamSignatureSection({ address }: { address: TeamAddress }) {
|
|
57
|
+
return (
|
|
58
|
+
<Suspense fallback={null}>
|
|
59
|
+
<TeamSignature address={address} />
|
|
60
|
+
</Suspense>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const AddressAutoReply = lazy(() =>
|
|
65
|
+
import("./admin/address-auto-reply").then((module) => ({
|
|
66
|
+
default: module.AddressAutoReply,
|
|
67
|
+
}))
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
function AddressAutoReplySection({
|
|
71
|
+
address,
|
|
72
|
+
}: {
|
|
73
|
+
address: TeamAddress | UserAddress;
|
|
74
|
+
}) {
|
|
75
|
+
return (
|
|
76
|
+
<Suspense fallback={null}>
|
|
77
|
+
<AddressAutoReply address={address} />
|
|
78
|
+
</Suspense>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
28
82
|
const mail: ClientModule = {
|
|
29
83
|
name: EMAIL_MODULE,
|
|
30
84
|
home: { label: "mail", Component: MailboxRoute },
|
|
@@ -36,22 +90,56 @@ const mail: ClientModule = {
|
|
|
36
90
|
label: "Notifications",
|
|
37
91
|
description: "New mail alerts for this device and your mailboxes.",
|
|
38
92
|
Icon: Bell,
|
|
39
|
-
|
|
40
|
-
import("./settings/notifications-page").then(
|
|
41
|
-
|
|
42
|
-
|
|
93
|
+
...preloadable(() =>
|
|
94
|
+
import("./settings/notifications-page").then(
|
|
95
|
+
(module) => module.NotificationsSettings
|
|
96
|
+
)
|
|
97
|
+
),
|
|
98
|
+
prefetch: (queryClient) => {
|
|
99
|
+
void queryClient.prefetchQuery(pushConfigQuery);
|
|
100
|
+
void queryClient.prefetchQuery(notificationPreferencesQuery);
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "signature",
|
|
105
|
+
label: "Signature",
|
|
106
|
+
description: "Added to messages you send from your own mailboxes.",
|
|
107
|
+
Icon: PenLine,
|
|
108
|
+
...preloadable(() =>
|
|
109
|
+
import("./settings/signature-page").then(
|
|
110
|
+
(module) => module.SignatureSettings
|
|
111
|
+
)
|
|
43
112
|
),
|
|
113
|
+
prefetch: (queryClient) => {
|
|
114
|
+
void queryClient.prefetchQuery(signatureQuery);
|
|
115
|
+
void queryClient.prefetchQuery(mailboxesQuery());
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "auto-reply",
|
|
120
|
+
label: "Auto-reply",
|
|
121
|
+
description: "Answer incoming mail automatically while you're away.",
|
|
122
|
+
Icon: Plane,
|
|
123
|
+
...preloadable(() =>
|
|
124
|
+
import("./settings/auto-reply-page").then(
|
|
125
|
+
(module) => module.AutoReplySettings
|
|
126
|
+
)
|
|
127
|
+
),
|
|
128
|
+
prefetch: (queryClient) =>
|
|
129
|
+
void queryClient.prefetchQuery(autoReplyMailboxesQuery),
|
|
44
130
|
},
|
|
45
131
|
{
|
|
46
132
|
id: "mail-apps",
|
|
47
133
|
label: "Mail apps",
|
|
48
134
|
description: "Connect a JMAP mail app with your account.",
|
|
49
135
|
Icon: MonitorSmartphone,
|
|
50
|
-
|
|
51
|
-
import("./settings/mail-apps-page").then(
|
|
52
|
-
|
|
53
|
-
|
|
136
|
+
...preloadable(() =>
|
|
137
|
+
import("./settings/mail-apps-page").then(
|
|
138
|
+
(module) => module.MailAppsSettings
|
|
139
|
+
)
|
|
54
140
|
),
|
|
141
|
+
prefetch: (queryClient) =>
|
|
142
|
+
void queryClient.prefetchQuery(mailboxesQuery()),
|
|
55
143
|
},
|
|
56
144
|
],
|
|
57
145
|
admin: [
|
|
@@ -63,12 +151,38 @@ const mail: ClientModule = {
|
|
|
63
151
|
title: "Blocked senders",
|
|
64
152
|
description:
|
|
65
153
|
"Addresses and domains blocked for every mailbox in the workspace.",
|
|
66
|
-
|
|
67
|
-
import("./admin/blocked-senders").then(
|
|
68
|
-
|
|
69
|
-
|
|
154
|
+
...preloadable(() =>
|
|
155
|
+
import("./admin/blocked-senders").then(
|
|
156
|
+
(module) => module.BlockedSenders
|
|
157
|
+
)
|
|
70
158
|
),
|
|
159
|
+
prefetch: (queryClient) =>
|
|
160
|
+
void queryClient.prefetchQuery(adminBlockedSendersQuery),
|
|
71
161
|
},
|
|
162
|
+
{
|
|
163
|
+
id: "mail-archive",
|
|
164
|
+
label: "Mail archive",
|
|
165
|
+
Icon: Archive,
|
|
166
|
+
// Administrators only, like Backups.
|
|
167
|
+
title: "Mail archive",
|
|
168
|
+
description:
|
|
169
|
+
"A write-once copy of every message the workspace receives and sends.",
|
|
170
|
+
...preloadable(() =>
|
|
171
|
+
import("./admin/mail-archive").then((module) => module.MailArchive)
|
|
172
|
+
),
|
|
173
|
+
prefetch: (queryClient) =>
|
|
174
|
+
void queryClient.prefetchQuery(mailArchiveQuery),
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
teamAddress: [
|
|
178
|
+
{ id: "signature", Component: TeamSignatureSection },
|
|
179
|
+
{ id: "auto-reply", Component: AddressAutoReplySection },
|
|
180
|
+
// A forward's destinations, Confirmed or Waiting, in both address editors.
|
|
181
|
+
{ id: "forward-destinations", Component: ForwardDestinations },
|
|
182
|
+
],
|
|
183
|
+
userAddress: [
|
|
184
|
+
{ id: "auto-reply", Component: AddressAutoReplySection },
|
|
185
|
+
{ id: "forward-destinations", Component: ForwardDestinations },
|
|
72
186
|
],
|
|
73
187
|
webhookEvents: emailWebhookEvents,
|
|
74
188
|
background: mailBackground.Component,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buttonVariants,
|
|
3
|
+
DelayedFallback,
|
|
3
4
|
DialogContent,
|
|
4
5
|
DialogDescription,
|
|
5
6
|
DialogTitle,
|
|
7
|
+
useDelayedPending,
|
|
6
8
|
} from "@open-workspace/core/ui";
|
|
7
9
|
import { Download, LoaderCircle } from "lucide-react";
|
|
8
10
|
import { lazy, Suspense, useState } from "react";
|
|
@@ -80,6 +82,8 @@ function AttachmentPreviewContent({
|
|
|
80
82
|
}) {
|
|
81
83
|
const [loading, setLoading] = useState(true);
|
|
82
84
|
const [failed, setFailed] = useState(false);
|
|
85
|
+
// Over the preview as it loads: gone the moment it shows, held no longer.
|
|
86
|
+
const spinner = useDelayedPending(loading, { min: 0 });
|
|
83
87
|
const unavailable = failed || status === "failed";
|
|
84
88
|
|
|
85
89
|
if (status === "pending") {
|
|
@@ -98,10 +102,14 @@ function AttachmentPreviewContent({
|
|
|
98
102
|
return (
|
|
99
103
|
<Suspense
|
|
100
104
|
fallback={
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
<DelayedFallback
|
|
106
|
+
fallback={
|
|
107
|
+
<div role="status" className="grid flex-1 place-items-center">
|
|
108
|
+
<LoaderCircle className="size-6 animate-spin" />
|
|
109
|
+
<span className="sr-only">Loading PDF</span>
|
|
110
|
+
</div>
|
|
111
|
+
}
|
|
112
|
+
/>
|
|
105
113
|
}
|
|
106
114
|
>
|
|
107
115
|
<PdfPreview
|
|
@@ -126,7 +134,7 @@ function AttachmentPreviewContent({
|
|
|
126
134
|
</p>
|
|
127
135
|
) : (
|
|
128
136
|
<>
|
|
129
|
-
{loading && (
|
|
137
|
+
{loading && spinner && (
|
|
130
138
|
<div
|
|
131
139
|
role="status"
|
|
132
140
|
className="pointer-events-none absolute inset-0 grid place-items-center"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Button, responseJson } from "@open-workspace/core/ui";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { LoaderCircle, Plane } from "lucide-react";
|
|
4
|
+
import { Link } from "react-router";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
|
|
7
|
+
import { mailApi } from "../lib/mail-api";
|
|
8
|
+
import { autoReplyQuery } from "../settings/settings-queries";
|
|
9
|
+
import type { Mailbox } from "./types";
|
|
10
|
+
|
|
11
|
+
/** Shown while one of your own mailboxes answers mail automatically, with a quick way out. */
|
|
12
|
+
export function AutoReplyBanner({ mailbox }: { mailbox: Mailbox }) {
|
|
13
|
+
const client = useQueryClient();
|
|
14
|
+
|
|
15
|
+
const query = useQuery({
|
|
16
|
+
...autoReplyQuery(mailbox.id),
|
|
17
|
+
staleTime: 60_000,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const turnOff = useMutation({
|
|
21
|
+
mutationFn: async (mailboxId: string) =>
|
|
22
|
+
responseJson(
|
|
23
|
+
await mailApi.api.mail.mailboxes[":id"]["auto-reply"].$patch({
|
|
24
|
+
param: { id: mailboxId },
|
|
25
|
+
json: { enabled: false },
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
onSuccess: (result, mailboxId) => {
|
|
29
|
+
client.setQueryData(autoReplyQuery(mailboxId).queryKey, result);
|
|
30
|
+
toast.success("Auto-reply turned off");
|
|
31
|
+
},
|
|
32
|
+
onError: (error) => toast.error(error.message),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (query.data?.status !== "active") return null;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="border-border bg-primary/10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border px-3.5 py-2 text-sm">
|
|
39
|
+
<Plane className="text-primary size-4 shrink-0" />
|
|
40
|
+
<span className="min-w-0 flex-1">
|
|
41
|
+
Automatic replies are on for {mailbox.address}.{" "}
|
|
42
|
+
<Link
|
|
43
|
+
to="/settings/auto-reply"
|
|
44
|
+
className="underline underline-offset-2"
|
|
45
|
+
>
|
|
46
|
+
Edit
|
|
47
|
+
</Link>
|
|
48
|
+
</span>
|
|
49
|
+
<Button
|
|
50
|
+
type="button"
|
|
51
|
+
size="sm"
|
|
52
|
+
variant="outline"
|
|
53
|
+
disabled={turnOff.isPending}
|
|
54
|
+
onClick={() => turnOff.mutate(mailbox.id)}
|
|
55
|
+
>
|
|
56
|
+
{turnOff.isPending && <LoaderCircle className="animate-spin" />}
|
|
57
|
+
Turn off
|
|
58
|
+
</Button>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
DelayedFallback,
|
|
4
|
+
Input,
|
|
5
|
+
Skeleton,
|
|
6
|
+
} from "@open-workspace/core/ui";
|
|
2
7
|
import { Building2, LoaderCircle, ShieldBan } from "lucide-react";
|
|
3
|
-
import {
|
|
4
|
-
import type { FormEvent } from "react";
|
|
8
|
+
import { useForm, useWatch } from "react-hook-form";
|
|
5
9
|
import { toast } from "sonner";
|
|
6
10
|
|
|
7
11
|
import { normalizeBlockPattern } from "../../shared/mail-feedback";
|
|
@@ -15,123 +19,152 @@ import {
|
|
|
15
19
|
export function BlockedSendersManager({
|
|
16
20
|
mailboxId,
|
|
17
21
|
active,
|
|
22
|
+
canOrganize,
|
|
18
23
|
}: {
|
|
19
24
|
mailboxId: string;
|
|
20
25
|
active: boolean;
|
|
26
|
+
canOrganize: boolean;
|
|
21
27
|
}) {
|
|
22
28
|
const blocked = useBlockedSenders(mailboxId, active);
|
|
23
29
|
const block = useBlockSender();
|
|
24
30
|
const unblock = useUnblockSender();
|
|
25
|
-
const [value, setValue] = useState("");
|
|
26
|
-
const pattern = normalizeBlockPattern(value);
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
const { control, handleSubmit, register, reset } = useForm({
|
|
33
|
+
defaultValues: { value: "" },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const pattern = normalizeBlockPattern(useWatch({ control, name: "value" }));
|
|
30
37
|
|
|
38
|
+
const submit = handleSubmit(() => {
|
|
31
39
|
if (!pattern) return;
|
|
32
40
|
block.mutate(
|
|
33
41
|
{ mailboxId, pattern, moveExisting: false },
|
|
34
42
|
{
|
|
35
43
|
onSuccess: (result) => {
|
|
36
|
-
|
|
44
|
+
reset();
|
|
37
45
|
toast.success(`Blocked ${result.block.pattern}`);
|
|
38
46
|
},
|
|
39
47
|
onError: (error) => toast.error(error.message),
|
|
40
48
|
}
|
|
41
49
|
);
|
|
42
|
-
}
|
|
50
|
+
});
|
|
43
51
|
|
|
44
52
|
const items = blocked.data?.blocked ?? [];
|
|
45
53
|
const workspace = blocked.data?.workspace ?? [];
|
|
46
54
|
|
|
47
55
|
return (
|
|
48
56
|
<div className="space-y-3">
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
{canOrganize && (
|
|
58
|
+
<form className="flex gap-2" onSubmit={submit}>
|
|
59
|
+
<Input
|
|
60
|
+
aria-label="Address or domain to block"
|
|
61
|
+
placeholder="name@example.com or example.com"
|
|
62
|
+
{...register("value")}
|
|
63
|
+
/>
|
|
64
|
+
<Button
|
|
65
|
+
type="submit"
|
|
66
|
+
variant="outline"
|
|
67
|
+
disabled={!pattern || block.isPending}
|
|
68
|
+
>
|
|
69
|
+
{block.isPending ? (
|
|
70
|
+
<LoaderCircle className="animate-spin" />
|
|
71
|
+
) : (
|
|
72
|
+
<ShieldBan />
|
|
73
|
+
)}
|
|
74
|
+
Block
|
|
75
|
+
</Button>
|
|
76
|
+
</form>
|
|
77
|
+
)}
|
|
69
78
|
<div className="border-border/70 max-h-[min(23rem,50vh)] overflow-y-auto border-y">
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
<DelayedFallback
|
|
80
|
+
pending={blocked.isLoading}
|
|
81
|
+
fallback={
|
|
82
|
+
<div className="space-y-2 py-3">
|
|
83
|
+
<Skeleton className="h-10" />
|
|
84
|
+
<Skeleton className="h-10" />
|
|
85
|
+
</div>
|
|
86
|
+
}
|
|
87
|
+
>
|
|
88
|
+
{blocked.isError ? (
|
|
89
|
+
<div className="grid min-h-28 place-items-center gap-2 px-6 py-4 text-center text-sm">
|
|
90
|
+
<p className="text-destructive">
|
|
91
|
+
Blocked senders couldn't be loaded.
|
|
92
|
+
</p>
|
|
93
|
+
<Button
|
|
94
|
+
type="button"
|
|
95
|
+
variant="outline"
|
|
96
|
+
size="sm"
|
|
97
|
+
onClick={() => void blocked.refetch()}
|
|
81
98
|
>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
Retry
|
|
100
|
+
</Button>
|
|
101
|
+
</div>
|
|
102
|
+
) : items.length || workspace.length ? (
|
|
103
|
+
<ul aria-label="Blocked senders">
|
|
104
|
+
{items.map((item) => (
|
|
105
|
+
<li
|
|
106
|
+
key={item.pattern}
|
|
107
|
+
className="border-border/60 flex min-h-12 items-center gap-3 border-b px-2 py-2 last:border-b-0"
|
|
108
|
+
>
|
|
109
|
+
<ShieldBan className="text-muted-foreground size-4 shrink-0" />
|
|
110
|
+
<div className="min-w-0 flex-1">
|
|
111
|
+
<p className="truncate text-sm font-medium">
|
|
112
|
+
{item.pattern}
|
|
113
|
+
</p>
|
|
114
|
+
<p className="text-muted-foreground text-xs">
|
|
115
|
+
{item.scope === "domain" ? "Whole domain" : "Address"} ·
|
|
116
|
+
blocked{" "}
|
|
117
|
+
{new Date(item.blockedAt).toLocaleDateString("en", {
|
|
118
|
+
dateStyle: "medium",
|
|
119
|
+
})}
|
|
120
|
+
</p>
|
|
121
|
+
</div>
|
|
122
|
+
{canOrganize && (
|
|
123
|
+
<Button
|
|
124
|
+
type="button"
|
|
125
|
+
variant="ghost"
|
|
126
|
+
size="sm"
|
|
127
|
+
aria-label={`Unblock ${item.pattern}`}
|
|
128
|
+
disabled={unblock.isPending}
|
|
129
|
+
onClick={() =>
|
|
130
|
+
unblock.mutate(
|
|
131
|
+
{ mailboxId, pattern: item.pattern },
|
|
132
|
+
{
|
|
133
|
+
onSuccess: () =>
|
|
134
|
+
toast.success(`Unblocked ${item.pattern}`),
|
|
135
|
+
onError: (error) => toast.error(error.message),
|
|
136
|
+
}
|
|
137
|
+
)
|
|
106
138
|
}
|
|
107
|
-
|
|
108
|
-
|
|
139
|
+
>
|
|
140
|
+
Unblock
|
|
141
|
+
</Button>
|
|
142
|
+
)}
|
|
143
|
+
</li>
|
|
144
|
+
))}
|
|
145
|
+
{workspace.map((item) => (
|
|
146
|
+
<li
|
|
147
|
+
key={`workspace-${item.pattern}`}
|
|
148
|
+
className="border-border/60 flex min-h-12 items-center gap-3 border-b px-2 py-2 last:border-b-0"
|
|
109
149
|
>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
)}
|
|
150
|
+
<Building2 className="text-muted-foreground size-4 shrink-0" />
|
|
151
|
+
<div className="min-w-0 flex-1">
|
|
152
|
+
<p className="truncate text-sm font-medium">
|
|
153
|
+
{item.pattern}
|
|
154
|
+
</p>
|
|
155
|
+
<p className="text-muted-foreground text-xs">
|
|
156
|
+
Blocked for everyone by an administrator
|
|
157
|
+
</p>
|
|
158
|
+
</div>
|
|
159
|
+
</li>
|
|
160
|
+
))}
|
|
161
|
+
</ul>
|
|
162
|
+
) : (
|
|
163
|
+
<div className="text-muted-foreground grid min-h-28 place-items-center px-6 text-center text-sm">
|
|
164
|
+
No blocked senders.
|
|
165
|
+
</div>
|
|
166
|
+
)}
|
|
167
|
+
</DelayedFallback>
|
|
135
168
|
</div>
|
|
136
169
|
</div>
|
|
137
170
|
);
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
Minus,
|
|
7
7
|
Paperclip,
|
|
8
8
|
Send,
|
|
9
|
+
Trash2,
|
|
9
10
|
X,
|
|
10
11
|
} from "lucide-react";
|
|
11
12
|
import type { Ref, RefObject } from "react";
|
|
12
13
|
|
|
13
|
-
import type { ComposerAsset } from "./composer-session";
|
|
14
14
|
import { formatBytes } from "./format-bytes";
|
|
15
15
|
import type { MessageDetail } from "./types";
|
|
16
16
|
|
|
@@ -54,11 +54,13 @@ export function ComposeWindowHeader({
|
|
|
54
54
|
from,
|
|
55
55
|
minimizeRef,
|
|
56
56
|
onMinimize,
|
|
57
|
+
onDiscard,
|
|
57
58
|
onClose,
|
|
58
59
|
}: {
|
|
59
60
|
from: string;
|
|
60
61
|
minimizeRef?: Ref<HTMLButtonElement>;
|
|
61
62
|
onMinimize: () => void;
|
|
63
|
+
onDiscard: () => void;
|
|
62
64
|
onClose: () => void;
|
|
63
65
|
}) {
|
|
64
66
|
return (
|
|
@@ -69,6 +71,16 @@ export function ComposeWindowHeader({
|
|
|
69
71
|
From {from}
|
|
70
72
|
</p>
|
|
71
73
|
</div>
|
|
74
|
+
<Button
|
|
75
|
+
type="button"
|
|
76
|
+
variant="ghost"
|
|
77
|
+
size="icon-sm"
|
|
78
|
+
title="Discard draft"
|
|
79
|
+
onClick={onDiscard}
|
|
80
|
+
>
|
|
81
|
+
<Trash2 />
|
|
82
|
+
<span className="sr-only">Discard draft</span>
|
|
83
|
+
</Button>
|
|
72
84
|
<Button
|
|
73
85
|
ref={minimizeRef}
|
|
74
86
|
className="hidden sm:inline-flex"
|
|
@@ -111,7 +123,7 @@ export function ForwardedMessageNotice({
|
|
|
111
123
|
export function ComposeWindowFooter({
|
|
112
124
|
fileInput,
|
|
113
125
|
inlineFileInput,
|
|
114
|
-
|
|
126
|
+
files,
|
|
115
127
|
error,
|
|
116
128
|
sending,
|
|
117
129
|
sendDisabled,
|
|
@@ -120,7 +132,7 @@ export function ComposeWindowFooter({
|
|
|
120
132
|
}: {
|
|
121
133
|
fileInput: RefObject<HTMLInputElement | null>;
|
|
122
134
|
inlineFileInput: RefObject<HTMLInputElement | null>;
|
|
123
|
-
|
|
135
|
+
files: readonly { size: number }[];
|
|
124
136
|
error: string | null;
|
|
125
137
|
sending: boolean;
|
|
126
138
|
sendDisabled: boolean;
|
|
@@ -178,14 +190,14 @@ export function ComposeWindowFooter({
|
|
|
178
190
|
</Button>
|
|
179
191
|
<span
|
|
180
192
|
className={cn(
|
|
181
|
-
"text-muted-foreground min-w-0 flex-1
|
|
182
|
-
error
|
|
193
|
+
"text-muted-foreground min-w-0 flex-1 text-[11px]",
|
|
194
|
+
error ? "text-destructive" : "truncate"
|
|
183
195
|
)}
|
|
184
196
|
>
|
|
185
197
|
{error ||
|
|
186
|
-
(
|
|
187
|
-
? `${
|
|
188
|
-
|
|
198
|
+
(files.length
|
|
199
|
+
? `${files.length} file${files.length === 1 ? "" : "s"} · ${formatBytes(
|
|
200
|
+
files.reduce((total, upload) => total + upload.size, 0)
|
|
189
201
|
)}`
|
|
190
202
|
: "Drop files into message · up to 500 MB")}
|
|
191
203
|
</span>
|