@octarq/plugin-mail 0.1.0 → 0.1.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/api.ts +1 -80
- package/package.json +3 -3
- package/pages/AuthBadges.tsx +3 -3
- package/pages/Compose.tsx +17 -12
- package/pages/EmailListItem.tsx +5 -5
- package/pages/EmailListPane.tsx +35 -6
- package/pages/EmailView.tsx +14 -13
- package/pages/FolderNav.tsx +1 -0
- package/pages/MailSettings.tsx +87 -48
- package/pages/MailTabs.tsx +1 -1
- package/pages/MailboxBar.tsx +1 -0
- package/pages/MailboxEditor.tsx +1 -1
- package/pages/SMTPSenders.tsx +114 -71
- package/pages/SuppressionList.tsx +4 -2
- package/pages/forms.test.tsx +67 -21
- package/pages/index.tsx +23 -24
- package/widgets/MailSetupStepWidget.tsx +4 -3
package/api.ts
CHANGED
|
@@ -1,87 +1,8 @@
|
|
|
1
1
|
// Mail feature API surface — the slice of the JSON API owned by the mail plugin.
|
|
2
2
|
// Fully self-contained without relative host leaks.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
status: number;
|
|
6
|
-
body?: any;
|
|
7
|
-
requestId?: string;
|
|
8
|
-
constructor(status: number, message: string, body?: any, requestId?: string) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.status = status;
|
|
11
|
-
this.body = body;
|
|
12
|
-
this.requestId = requestId;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getAppLang(): string {
|
|
17
|
-
try {
|
|
18
|
-
const saved = localStorage.getItem("lang");
|
|
19
|
-
if (saved) return saved;
|
|
20
|
-
} catch {
|
|
21
|
-
/* ignore */
|
|
22
|
-
}
|
|
23
|
-
return typeof navigator !== "undefined" ? navigator.language || "en" : "en";
|
|
24
|
-
}
|
|
4
|
+
import { req } from "@octarq/plugin-sdk";
|
|
25
5
|
|
|
26
|
-
interface ErrorEnvelope {
|
|
27
|
-
message?: string;
|
|
28
|
-
error?: string;
|
|
29
|
-
detail?: string;
|
|
30
|
-
details?: Array<string | { location?: string; message?: string }>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function req<T>(method: string, path: string, body?: unknown, lang?: string): Promise<T> {
|
|
34
|
-
const currentLang = lang || getAppLang();
|
|
35
|
-
const headers: Record<string, string> = {
|
|
36
|
-
"Accept-Language": currentLang,
|
|
37
|
-
};
|
|
38
|
-
if (body) {
|
|
39
|
-
headers["Content-Type"] = "application/json";
|
|
40
|
-
}
|
|
41
|
-
const res = await fetch(path, {
|
|
42
|
-
method,
|
|
43
|
-
headers,
|
|
44
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
45
|
-
});
|
|
46
|
-
if (!res.ok) {
|
|
47
|
-
let msg = res.statusText;
|
|
48
|
-
let parsed: ErrorEnvelope | null = null;
|
|
49
|
-
try {
|
|
50
|
-
parsed = (await res.json()) as ErrorEnvelope;
|
|
51
|
-
if (parsed?.message) {
|
|
52
|
-
msg = parsed.message;
|
|
53
|
-
if (parsed.details && Array.isArray(parsed.details) && parsed.details.length > 0) {
|
|
54
|
-
const detailMsgs = parsed.details
|
|
55
|
-
.map((d) => {
|
|
56
|
-
if (typeof d === "string") return d;
|
|
57
|
-
if (d?.message) {
|
|
58
|
-
const loc = d.location ? `${d.location.replace(/^body\./, "")}: ` : "";
|
|
59
|
-
return `${loc}${d.message}`;
|
|
60
|
-
}
|
|
61
|
-
return "";
|
|
62
|
-
})
|
|
63
|
-
.filter(Boolean)
|
|
64
|
-
.join("; ");
|
|
65
|
-
if (detailMsgs) msg = `${msg} (${detailMsgs})`;
|
|
66
|
-
}
|
|
67
|
-
} else if (parsed?.error) {
|
|
68
|
-
msg = parsed.error;
|
|
69
|
-
} else if (parsed?.detail) {
|
|
70
|
-
msg = parsed.detail;
|
|
71
|
-
}
|
|
72
|
-
} catch {
|
|
73
|
-
// Non-JSON error body: fall through to statusText.
|
|
74
|
-
}
|
|
75
|
-
const requestId = res.headers.get("x-request-id") || undefined;
|
|
76
|
-
throw new ApiError(res.status, msg || `HTTP ${res.status}`, parsed, requestId);
|
|
77
|
-
}
|
|
78
|
-
if (res.status === 204) return undefined as unknown as T;
|
|
79
|
-
const contentType = res.headers.get("content-type");
|
|
80
|
-
if (contentType && contentType.includes("application/json")) {
|
|
81
|
-
return (await res.json()) as T;
|
|
82
|
-
}
|
|
83
|
-
return (await res.text()) as unknown as T;
|
|
84
|
-
}
|
|
85
6
|
|
|
86
7
|
export interface HostEntry {
|
|
87
8
|
host: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octarq/plugin-mail",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Mailboxes, SMTP relay, and inbound webhook processing plugin for Octarq",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
".": "./index.ts"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@octarq/plugin-sdk": "^0.
|
|
12
|
+
"@octarq/plugin-sdk": "^0.25.0",
|
|
13
13
|
"react": "^18.3.1",
|
|
14
14
|
"react-dom": "^18.3.1",
|
|
15
15
|
"react-router-dom": "^6.28.0 || ^7.0.0"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lucide-react": "^1.21.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@octarq/plugin-sdk": "^0.
|
|
21
|
+
"@octarq/plugin-sdk": "^0.25.0",
|
|
22
22
|
"@types/react": "^18.3.1",
|
|
23
23
|
"@types/react-dom": "^18.3.1",
|
|
24
24
|
"react": "^18.3.1",
|
package/pages/AuthBadges.tsx
CHANGED
|
@@ -17,9 +17,9 @@ export function AuthBadges({
|
|
|
17
17
|
const warn = result === "softfail" || result === "neutral";
|
|
18
18
|
if (compact && pass) return null; // only show problems in list view
|
|
19
19
|
|
|
20
|
-
let tone: "
|
|
21
|
-
if (pass) tone = "
|
|
22
|
-
else if (warn) tone = "
|
|
20
|
+
let tone: "success" | "warning" | "danger" = "danger";
|
|
21
|
+
if (pass) tone = "success";
|
|
22
|
+
else if (warn) tone = "warning";
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<Badge key={label} tone={tone} className="font-mono text-[10px] uppercase tracking-wider">
|
package/pages/Compose.tsx
CHANGED
|
@@ -48,11 +48,11 @@ export function Compose({
|
|
|
48
48
|
setLoadingSenders(true);
|
|
49
49
|
(async () => {
|
|
50
50
|
try {
|
|
51
|
-
const res = await fetch("/api/
|
|
51
|
+
const res = await fetch("/api/vault/items?provider_type=communication", {
|
|
52
52
|
credentials: "same-origin",
|
|
53
53
|
});
|
|
54
54
|
if (res.status === 404) {
|
|
55
|
-
//
|
|
55
|
+
// Core Vault is unavailable on this instance: the local SMTP sender
|
|
56
56
|
// registry is the only source, so offer it instead of an empty list.
|
|
57
57
|
const list = await mailApi.smtpSenders();
|
|
58
58
|
if (cancelled) return;
|
|
@@ -63,7 +63,8 @@ export function Compose({
|
|
|
63
63
|
}
|
|
64
64
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
65
65
|
const data = await res.json();
|
|
66
|
-
const
|
|
66
|
+
const raw = Array.isArray(data) ? data : (data?.body ?? []);
|
|
67
|
+
const commSenders = (Array.isArray(raw) ? raw : []).filter(
|
|
67
68
|
(item: any) => item.provider === "smtp" || item.provider === "resend"
|
|
68
69
|
);
|
|
69
70
|
if (cancelled) return;
|
|
@@ -192,14 +193,18 @@ export function Compose({
|
|
|
192
193
|
className="text-sm"
|
|
193
194
|
value={String(smtpSenderId)}
|
|
194
195
|
onValueChange={(v) => setSmtpSenderId(Number(v))}
|
|
195
|
-
options={senders.map((s) =>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
options={senders.map((s) => {
|
|
197
|
+
const detail =
|
|
198
|
+
s.metadata?.fromEmail ||
|
|
199
|
+
s.fromEmail ||
|
|
200
|
+
s.summary ||
|
|
201
|
+
s.metadata?.smtpHost ||
|
|
202
|
+
s.provider;
|
|
203
|
+
return {
|
|
204
|
+
value: String(s.id),
|
|
205
|
+
label: detail ? `${s.name} (${detail})` : s.name,
|
|
206
|
+
};
|
|
207
|
+
})}
|
|
203
208
|
/>
|
|
204
209
|
</Field>
|
|
205
210
|
)}
|
|
@@ -224,7 +229,7 @@ export function Compose({
|
|
|
224
229
|
/>
|
|
225
230
|
</Field>
|
|
226
231
|
{showSuggestions && contacts.length > 0 && (
|
|
227
|
-
<div className="absolute left-0 right-0 top-full mt-1 z-30 bg-card border border-border rounded-
|
|
232
|
+
<div className="absolute left-0 right-0 top-full mt-1 z-30 bg-card border border-border rounded-lg shadow-lg overflow-hidden divide-y divide-border">
|
|
228
233
|
{contacts.map((c) => (
|
|
229
234
|
<button
|
|
230
235
|
key={c.id}
|
package/pages/EmailListItem.tsx
CHANGED
|
@@ -10,11 +10,11 @@ interface EmailListItemProps {
|
|
|
10
10
|
onSelect: () => void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const CATEGORY_META: Record<string, { tone: "
|
|
14
|
-
bill: { tone: "
|
|
15
|
-
otp: { tone: "
|
|
16
|
-
marketing: { tone: "
|
|
17
|
-
important: { tone: "
|
|
13
|
+
const CATEGORY_META: Record<string, { tone: "warning" | "info" | "danger" | "default"; label: string }> = {
|
|
14
|
+
bill: { tone: "warning", label: "Bill" },
|
|
15
|
+
otp: { tone: "info", label: "OTP" },
|
|
16
|
+
marketing: { tone: "default", label: "Marketing" },
|
|
17
|
+
important: { tone: "danger", label: "Important" },
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
function renderImportanceDots(n?: number) {
|
package/pages/EmailListPane.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PageCard, Empty, Button, Input, Skeleton, useTranslation } from "@octarq/plugin-sdk";
|
|
2
2
|
import { Search, X, Mail as MailIcon, Inbox } from "lucide-react";
|
|
3
3
|
import { Email, Mailbox } from "../api";
|
|
4
4
|
import { MailFolder } from "./types";
|
|
@@ -56,15 +56,31 @@ export function EmailListPane({
|
|
|
56
56
|
)}
|
|
57
57
|
</div>
|
|
58
58
|
|
|
59
|
-
<
|
|
59
|
+
<PageCard className="mt-0 flex-1 overflow-hidden p-0">
|
|
60
60
|
{emails.length === 0 && loading ? (
|
|
61
|
-
<
|
|
61
|
+
<div
|
|
62
|
+
role="status"
|
|
63
|
+
aria-busy="true"
|
|
64
|
+
aria-label={t("mail.loading")}
|
|
65
|
+
className="divide-y divide-border"
|
|
66
|
+
>
|
|
67
|
+
{Array.from({ length: 7 }).map((_, i) => (
|
|
68
|
+
<div key={i} className="flex flex-col gap-1.5 p-3.5">
|
|
69
|
+
<div className="flex items-center justify-between gap-2">
|
|
70
|
+
<Skeleton className="h-3.5 w-36" />
|
|
71
|
+
<Skeleton className="h-3 w-12" />
|
|
72
|
+
</div>
|
|
73
|
+
<Skeleton className="h-3.5 w-4/5" />
|
|
74
|
+
<Skeleton className="h-3 w-3/5" />
|
|
75
|
+
</div>
|
|
76
|
+
))}
|
|
77
|
+
</div>
|
|
62
78
|
) : (
|
|
63
79
|
<div className="max-h-[650px] divide-y divide-border overflow-y-auto" onScroll={onScroll}>
|
|
64
80
|
{emails.length === 0 ? (
|
|
65
81
|
q ? (
|
|
66
82
|
<div className="flex flex-col items-center gap-2.5 px-6 py-10 text-center">
|
|
67
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-
|
|
83
|
+
<div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted text-muted-foreground">
|
|
68
84
|
<Search className="h-4 w-4" />
|
|
69
85
|
</div>
|
|
70
86
|
<p className="text-[13px] text-muted-foreground">
|
|
@@ -112,12 +128,25 @@ export function EmailListPane({
|
|
|
112
128
|
onSelect={() => onOpenEmail(e)}
|
|
113
129
|
/>
|
|
114
130
|
))}
|
|
115
|
-
{loading &&
|
|
131
|
+
{loading && (
|
|
132
|
+
<div
|
|
133
|
+
role="status"
|
|
134
|
+
aria-busy="true"
|
|
135
|
+
aria-label={t("mail.loading")}
|
|
136
|
+
className="flex flex-col gap-1.5 p-3.5"
|
|
137
|
+
>
|
|
138
|
+
<div className="flex items-center justify-between gap-2">
|
|
139
|
+
<Skeleton className="h-3.5 w-32" />
|
|
140
|
+
<Skeleton className="h-3 w-12" />
|
|
141
|
+
</div>
|
|
142
|
+
<Skeleton className="h-3.5 w-3/4" />
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
116
145
|
</>
|
|
117
146
|
)}
|
|
118
147
|
</div>
|
|
119
148
|
)}
|
|
120
|
-
</
|
|
149
|
+
</PageCard>
|
|
121
150
|
</div>
|
|
122
151
|
);
|
|
123
152
|
}
|
package/pages/EmailView.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field, Input,
|
|
1
|
+
import { Field, Input, PageCard, Badge, Button, toast, confirmDialog, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { mailApi, Attachment, Email } from "../api";
|
|
4
4
|
import { Paperclip, Trash2, Reply, Download, X, Sparkles, ExternalLink, ShieldAlert, ArchiveRestore, Edit3, Copy, KeyRound } from "lucide-react";
|
|
@@ -16,11 +16,11 @@ function parseAttachments(json: string): Attachment[] {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const CATEGORY_META: Record<string, { tone: "
|
|
20
|
-
bill: { tone: "
|
|
21
|
-
otp: { tone: "
|
|
22
|
-
marketing: { tone: "
|
|
23
|
-
important: { tone: "
|
|
19
|
+
const CATEGORY_META: Record<string, { tone: "warning" | "info" | "danger" | "default"; label: string }> = {
|
|
20
|
+
bill: { tone: "warning", label: "Bill" },
|
|
21
|
+
otp: { tone: "info", label: "OTP" },
|
|
22
|
+
marketing: { tone: "default", label: "Marketing" },
|
|
23
|
+
important: { tone: "danger", label: "Important" },
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
function renderImportanceDots(n?: number) {
|
|
@@ -89,7 +89,7 @@ export function EmailViewForm({
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
|
-
<
|
|
92
|
+
<PageCard className="mt-0 flex flex-col h-full max-h-full min-h-0 p-0">
|
|
93
93
|
<div className="p-5 border-b border-border flex justify-between items-start shrink-0 gap-4">
|
|
94
94
|
<div className="flex-1 min-w-0">
|
|
95
95
|
<h2 className="text-lg font-bold text-foreground mb-2 leading-snug">{email.subject || t("mail.noSubject")}</h2>
|
|
@@ -116,7 +116,7 @@ export function EmailViewForm({
|
|
|
116
116
|
{(email.otp || (email.category === "otp" && email.subject.match(/\b([A-Z0-9]{4,8})\b/i)?.[1])) && (
|
|
117
117
|
<div
|
|
118
118
|
data-testid="otp-copy-bar"
|
|
119
|
-
className="mx-5 mt-3 flex items-center justify-between gap-3 px-4 py-2.5 bg-accent-soft border border-primary/20 rounded-
|
|
119
|
+
className="mx-5 mt-3 flex items-center justify-between gap-3 px-4 py-2.5 bg-accent-soft border border-primary/20 rounded-lg text-xs shrink-0"
|
|
120
120
|
>
|
|
121
121
|
<div className="flex items-center gap-2.5">
|
|
122
122
|
<KeyRound className="h-4 w-4 text-accent-fg shrink-0" />
|
|
@@ -142,7 +142,7 @@ export function EmailViewForm({
|
|
|
142
142
|
)}
|
|
143
143
|
|
|
144
144
|
{email.unsubscribeUrl && (
|
|
145
|
-
<div className="mx-5 mt-3 flex items-center justify-between gap-3 px-3.5 py-2 bg-warning-bg border border-warning-border rounded-
|
|
145
|
+
<div className="mx-5 mt-3 flex items-center justify-between gap-3 px-3.5 py-2 bg-warning-bg border border-warning-border rounded-lg text-xs shrink-0">
|
|
146
146
|
<span className="text-warning-fg font-medium truncate">{t("mail.unsubscribe")}</span>
|
|
147
147
|
<Button
|
|
148
148
|
variant="outline"
|
|
@@ -159,7 +159,7 @@ export function EmailViewForm({
|
|
|
159
159
|
)}
|
|
160
160
|
|
|
161
161
|
{(summary || email.summary) && (
|
|
162
|
-
<div className="mx-5 mt-4 rounded-
|
|
162
|
+
<div className="mx-5 mt-4 rounded-lg bg-info-bg border border-info-border p-3.5 shrink-0" data-testid="email-summary-box">
|
|
163
163
|
<div className="flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-accent-fg mb-1.5">
|
|
164
164
|
<Sparkles className="h-3 w-3" />
|
|
165
165
|
{t("mail.aiSummaryTitle")}
|
|
@@ -170,7 +170,8 @@ export function EmailViewForm({
|
|
|
170
170
|
|
|
171
171
|
<div className="flex-1 overflow-y-auto p-5 min-h-[400px] bg-well">
|
|
172
172
|
{email.html ? (
|
|
173
|
-
|
|
173
|
+
/* ui-color-ok: HTML emails assume a light paper viewport */
|
|
174
|
+
<iframe srcDoc={email.html} className="h-full min-h-[400px] w-full rounded-lg border border-border bg-white" sandbox="" title={t("mail.iframeTitle")} />
|
|
174
175
|
) : (
|
|
175
176
|
<pre className="whitespace-pre-wrap break-words font-sans text-sm text-foreground leading-relaxed">{email.text}</pre>
|
|
176
177
|
)}
|
|
@@ -184,7 +185,7 @@ export function EmailViewForm({
|
|
|
184
185
|
<Paperclip className="h-3 w-3 text-accent-fg" />
|
|
185
186
|
{a.filename || t("mail.attachmentFallback")} <span className="font-mono tnum">({Math.max(1, Math.round(a.size / 1024))} KB)</span>
|
|
186
187
|
{a.truncated && (
|
|
187
|
-
<Badge tone="
|
|
188
|
+
<Badge tone="warning" className="font-mono text-[10px] uppercase tracking-wider ml-1">
|
|
188
189
|
{t("mail.truncated")}
|
|
189
190
|
</Badge>
|
|
190
191
|
)}
|
|
@@ -277,6 +278,6 @@ export function EmailViewForm({
|
|
|
277
278
|
</div>
|
|
278
279
|
</div>
|
|
279
280
|
</div>
|
|
280
|
-
</
|
|
281
|
+
</PageCard>
|
|
281
282
|
);
|
|
282
283
|
}
|
package/pages/FolderNav.tsx
CHANGED
package/pages/MailSettings.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field, Input, Textarea, Switch, Button,
|
|
1
|
+
import { Field, Input, Textarea, Switch, Button, PageSection, PageCard, PageRows, PageRow, Separator, Skeleton, toast, useTranslation } from "@octarq/plugin-sdk";
|
|
2
2
|
import { useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { mailApi, MailSettingsData } from "../api";
|
|
4
4
|
|
|
@@ -75,61 +75,100 @@ export function MailSettings() {
|
|
|
75
75
|
setTimeout(() => setCopied(false), 1500);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
if (!s)
|
|
78
|
+
if (!s) {
|
|
79
|
+
return (
|
|
80
|
+
<div role="status" aria-busy="true" aria-label={t("settings.loadingLower")}>
|
|
81
|
+
<PageSection className="mt-0" title={t("settings.inboundMailboxesSettings")}>
|
|
82
|
+
<PageCard className="space-y-5">
|
|
83
|
+
<div className="space-y-2">
|
|
84
|
+
<Skeleton className="h-3.5 w-36" />
|
|
85
|
+
<Skeleton className="h-16 w-full rounded-lg" />
|
|
86
|
+
</div>
|
|
87
|
+
<div className="space-y-2">
|
|
88
|
+
<Skeleton className="h-3.5 w-40" />
|
|
89
|
+
<Skeleton className="h-9 w-full rounded-lg" />
|
|
90
|
+
</div>
|
|
91
|
+
<div className="space-y-2">
|
|
92
|
+
<Skeleton className="h-3.5 w-32" />
|
|
93
|
+
<Skeleton className="h-9 w-full rounded-lg" />
|
|
94
|
+
</div>
|
|
95
|
+
</PageCard>
|
|
96
|
+
<PageRows>
|
|
97
|
+
<div data-slot="page-row" className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3">
|
|
98
|
+
<div className="flex-1 space-y-1.5">
|
|
99
|
+
<Skeleton className="h-4 w-36" />
|
|
100
|
+
<Skeleton className="h-3 w-64" />
|
|
101
|
+
</div>
|
|
102
|
+
<Skeleton className="h-6 w-11 shrink-0 rounded-full" />
|
|
103
|
+
</div>
|
|
104
|
+
<Separator />
|
|
105
|
+
<div data-slot="page-row" className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3">
|
|
106
|
+
<div className="flex-1 space-y-1.5">
|
|
107
|
+
<Skeleton className="h-4 w-40" />
|
|
108
|
+
<Skeleton className="h-3 w-56" />
|
|
109
|
+
</div>
|
|
110
|
+
<Skeleton className="h-6 w-11 shrink-0 rounded-full" />
|
|
111
|
+
</div>
|
|
112
|
+
</PageRows>
|
|
113
|
+
</PageSection>
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
79
117
|
|
|
80
118
|
const displayed = tokenLoaded && revealed ? inboundToken : MASK;
|
|
81
119
|
|
|
82
120
|
return (
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<
|
|
91
|
-
readOnly
|
|
92
|
-
className="font-mono text-xs"
|
|
93
|
-
value={`${location.origin}/api/v1/webhook/${s?.orgSlug || ""}/email/inbound/${displayed}`}
|
|
94
|
-
onFocus={(e) => e.currentTarget.select()}
|
|
95
|
-
/>
|
|
96
|
-
</Field>
|
|
97
|
-
<Field label={t("settings.inboundTokenLabel")} hint={t("settings.inboundTokenHint")}>
|
|
98
|
-
<div className="flex gap-2">
|
|
121
|
+
<PageSection className="mt-0" title={t("settings.inboundMailboxesSettings")}>
|
|
122
|
+
<PageCard className="space-y-5">
|
|
123
|
+
<Field label={t("settings.reservedMailboxesLabel")} hint={t("settings.reservedMailboxesHint")}>
|
|
124
|
+
<Textarea className="font-mono text-xs" rows={2} value={reservedMailboxes} onChange={(e) => setReservedMailboxes(e.target.value)} placeholder="admin postmaster" />
|
|
125
|
+
</Field>
|
|
126
|
+
{adminView && (
|
|
127
|
+
<>
|
|
128
|
+
<Field label={t("settings.inboundWebhookUrlLabel")} hint={t("settings.inboundWebhookUrlHint")}>
|
|
99
129
|
<Input
|
|
130
|
+
readOnly
|
|
100
131
|
className="font-mono text-xs"
|
|
101
|
-
value={displayed}
|
|
102
|
-
|
|
103
|
-
onChange={(e) => setInboundToken(e.target.value)}
|
|
104
|
-
placeholder={t("settings.inboundTokenPlaceholder")}
|
|
132
|
+
value={`${location.origin}/api/v1/webhook/${s?.orgSlug || ""}/email/inbound/${displayed}`}
|
|
133
|
+
onFocus={(e) => e.currentTarget.select()}
|
|
105
134
|
/>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
</Field>
|
|
136
|
+
<Field label={t("settings.inboundTokenLabel")} hint={t("settings.inboundTokenHint")}>
|
|
137
|
+
<div className="flex gap-2">
|
|
138
|
+
<Input
|
|
139
|
+
className="font-mono text-xs"
|
|
140
|
+
value={displayed}
|
|
141
|
+
readOnly={!revealed || !tokenLoaded}
|
|
142
|
+
onChange={(e) => setInboundToken(e.target.value)}
|
|
143
|
+
placeholder={t("settings.inboundTokenPlaceholder")}
|
|
144
|
+
/>
|
|
145
|
+
<Button variant="outline" className="shrink-0 text-xs" onClick={reveal}>
|
|
146
|
+
{revealed ? t("settings.inboundTokenHide") : t("settings.inboundTokenReveal")}
|
|
147
|
+
</Button>
|
|
148
|
+
<Button variant="subtle" className="shrink-0 text-xs" onClick={copyToken}>
|
|
149
|
+
{copied ? t("uiCommon.copied") : t("settings.inboundTokenCopy")}
|
|
150
|
+
</Button>
|
|
151
|
+
</div>
|
|
152
|
+
</Field>
|
|
153
|
+
</>
|
|
154
|
+
)}
|
|
155
|
+
</PageCard>
|
|
156
|
+
<PageRows>
|
|
157
|
+
<PageRow
|
|
158
|
+
title={t("settings.enableCatchAll")}
|
|
159
|
+
description={t("settings.enableCatchAllDesc")}
|
|
160
|
+
control={<Switch checked={catchAll} onCheckedChange={setCatchAll} aria-label={t("settings.enableCatchAll")} />}
|
|
161
|
+
/>
|
|
162
|
+
<Separator />
|
|
163
|
+
<PageRow
|
|
164
|
+
title={t("settings.autoWrapLinks")}
|
|
165
|
+
description={t("settings.autoWrapLinksDesc")}
|
|
166
|
+
control={<Switch checked={autoWrap} onCheckedChange={setAutoWrap} aria-label={t("settings.autoWrapLinks")} />}
|
|
167
|
+
/>
|
|
168
|
+
</PageRows>
|
|
169
|
+
<div className="mt-4 flex justify-end">
|
|
131
170
|
<Button variant="primary" className="text-xs" onClick={save} disabled={busy}>{busy ? t("settings.saving") : t("settings.saveSettings")}</Button>
|
|
132
171
|
</div>
|
|
133
|
-
</
|
|
172
|
+
</PageSection>
|
|
134
173
|
);
|
|
135
174
|
}
|
package/pages/MailTabs.tsx
CHANGED
package/pages/MailboxBar.tsx
CHANGED
|
@@ -41,6 +41,7 @@ export function MailboxBar({
|
|
|
41
41
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
42
42
|
<div className="min-w-0 flex-1">
|
|
43
43
|
<TabBar
|
|
44
|
+
className="flex-wrap"
|
|
44
45
|
size="sm"
|
|
45
46
|
value={active === undefined ? "all" : String(active)}
|
|
46
47
|
onValueChange={(v) => onSelect(v === "all" ? undefined : Number(v))}
|
package/pages/MailboxEditor.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Code, Field, Input, Textarea, Guide, Modal, Switch, timeAgo,
|
|
1
|
+
import { Code, Field, Input, Textarea, Guide, Modal, Switch, timeAgo, Badge, Button, Select, Alert, confirmDialog, FormError, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { useSearchParams } from "react-router-dom";
|
|
4
4
|
import { mailApi, Attachment, Email, Mailbox } from "../api";
|
package/pages/SMTPSenders.tsx
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { Empty, Field, Input, Modal, Badge, Button,
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
1
|
+
import { Empty, Field, Input, Modal, Badge, StatusBadge, Button, PageSection, PageRows, Separator, Skeleton, toast, confirmDialog, FormError, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
|
|
2
|
+
import { Fragment, useEffect, useState } from "react";
|
|
3
3
|
import { NavLink } from "react-router-dom";
|
|
4
4
|
import { mailApi, SMTPSender } from "../api";
|
|
5
5
|
import { KeyRound, Send, Blocks } from "lucide-react";
|
|
6
6
|
|
|
7
|
-
// Which registry owns the sender rows. An instance with
|
|
8
|
-
// mounted uses
|
|
7
|
+
// Which registry owns the sender rows. An instance with Core Vault
|
|
8
|
+
// mounted uses vault items; a standalone instance without vault uses
|
|
9
9
|
// the local mail_smtp_senders table. The two registries number rows
|
|
10
10
|
// independently, so a page must read exactly one of them.
|
|
11
11
|
type SenderMode = "integration" | "local" | null;
|
|
12
12
|
|
|
13
|
+
function formatIntegrationSenderSummary(s: any): string {
|
|
14
|
+
const fromEmail = s.metadata?.fromEmail || s.fromEmail;
|
|
15
|
+
const host = s.metadata?.smtpHost || s.host;
|
|
16
|
+
const port = s.metadata?.smtpPort || s.port || 587;
|
|
17
|
+
if (fromEmail && host) return `${fromEmail} via ${host}:${port}`;
|
|
18
|
+
if (s.summary) return s.summary;
|
|
19
|
+
if (fromEmail) return fromEmail;
|
|
20
|
+
if (host) return `${host}:${port}`;
|
|
21
|
+
return s.metadata?.fromName || s.provider || s.name || "";
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
export function SMTPSenders() {
|
|
14
25
|
const { t } = useTranslation();
|
|
15
26
|
const { role, isInstanceAdmin } = useCurrentRole();
|
|
@@ -24,7 +35,7 @@ export function SMTPSenders() {
|
|
|
24
35
|
async function load() {
|
|
25
36
|
setLoading(true);
|
|
26
37
|
try {
|
|
27
|
-
const res = await fetch("/api/
|
|
38
|
+
const res = await fetch("/api/vault/items?provider_type=communication", {
|
|
28
39
|
credentials: "same-origin",
|
|
29
40
|
});
|
|
30
41
|
if (res.status === 404) {
|
|
@@ -38,9 +49,10 @@ export function SMTPSenders() {
|
|
|
38
49
|
return;
|
|
39
50
|
}
|
|
40
51
|
const data = await res.json();
|
|
52
|
+
const raw = Array.isArray(data) ? data : (data?.body ?? []);
|
|
41
53
|
setMode("integration");
|
|
42
54
|
setSenders(
|
|
43
|
-
(Array.isArray(
|
|
55
|
+
(Array.isArray(raw) ? raw : []).filter(
|
|
44
56
|
(item: any) => item.provider === "smtp" || item.provider === "resend"
|
|
45
57
|
)
|
|
46
58
|
);
|
|
@@ -70,7 +82,7 @@ export function SMTPSenders() {
|
|
|
70
82
|
await mailApi.testSMTPSender(sender.id);
|
|
71
83
|
toast.success(t("settings.smtpTestSent", { to: sender.fromEmail }));
|
|
72
84
|
} else {
|
|
73
|
-
const res = await fetch(`/api/
|
|
85
|
+
const res = await fetch(`/api/vault/items/${sender.id}/test`, {
|
|
74
86
|
method: "POST",
|
|
75
87
|
credentials: "same-origin",
|
|
76
88
|
});
|
|
@@ -88,7 +100,8 @@ export function SMTPSenders() {
|
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
return (
|
|
91
|
-
<
|
|
103
|
+
<PageSection
|
|
104
|
+
className="mt-0"
|
|
92
105
|
title={t("settings.smtpOutgoingGateways")}
|
|
93
106
|
description={t("settings.smtpOutgoingGatewaysDesc")}
|
|
94
107
|
action={
|
|
@@ -107,7 +120,7 @@ export function SMTPSenders() {
|
|
|
107
120
|
>
|
|
108
121
|
|
|
109
122
|
{mode === "integration" && (
|
|
110
|
-
<div className="flex items-center justify-between p-3 rounded-lg border border-primary/20 bg-accent-soft text-xs text-foreground">
|
|
123
|
+
<div className="mt-3 flex items-center justify-between p-3 rounded-lg border border-primary/20 bg-accent-soft text-xs text-foreground">
|
|
111
124
|
<div className="flex items-center gap-2">
|
|
112
125
|
<Blocks className="h-4 w-4 text-accent-fg shrink-0" />
|
|
113
126
|
<span>{t("settings.integrationsHubBanner")}</span>
|
|
@@ -122,76 +135,106 @@ export function SMTPSenders() {
|
|
|
122
135
|
)}
|
|
123
136
|
|
|
124
137
|
{loading ? (
|
|
125
|
-
<div
|
|
138
|
+
<div role="status" aria-busy="true" aria-label={t("settings.loadingLower")}>
|
|
139
|
+
<PageRows>
|
|
140
|
+
{Array.from({ length: 3 }).map((_, i) => (
|
|
141
|
+
<Fragment key={i}>
|
|
142
|
+
{i > 0 && <Separator />}
|
|
143
|
+
<div
|
|
144
|
+
data-slot="page-row"
|
|
145
|
+
className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3"
|
|
146
|
+
>
|
|
147
|
+
<div className="flex-1 space-y-1.5">
|
|
148
|
+
<div className="flex items-center gap-2">
|
|
149
|
+
<Skeleton className="h-4 w-36" />
|
|
150
|
+
<Skeleton className="h-4 w-16 rounded-full" />
|
|
151
|
+
</div>
|
|
152
|
+
<Skeleton className="h-3 w-56" />
|
|
153
|
+
</div>
|
|
154
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
155
|
+
<Skeleton className="h-7 w-14 rounded-lg" />
|
|
156
|
+
<Skeleton className="h-7 w-20 rounded-lg" />
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</Fragment>
|
|
160
|
+
))}
|
|
161
|
+
</PageRows>
|
|
162
|
+
</div>
|
|
126
163
|
) : senders.length === 0 ? (
|
|
127
164
|
// The heading carries the add/open control, so the empty state states
|
|
128
165
|
// the fact and adds no second button.
|
|
129
|
-
<Empty reason={t("settings.noSmtpSenders")}>
|
|
166
|
+
<Empty reason={t("settings.noSmtpSenders")} className="mt-3">
|
|
130
167
|
<Send />
|
|
131
168
|
</Empty>
|
|
132
169
|
) : (
|
|
133
|
-
<
|
|
134
|
-
{senders.map(s => (
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
170
|
+
<PageRows>
|
|
171
|
+
{senders.map((s, idx) => (
|
|
172
|
+
<Fragment key={s.id}>
|
|
173
|
+
{idx > 0 && <Separator />}
|
|
174
|
+
<div
|
|
175
|
+
data-slot="page-row"
|
|
176
|
+
className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3 group"
|
|
177
|
+
>
|
|
178
|
+
<div className="min-w-0">
|
|
179
|
+
<div className="font-semibold text-sm text-foreground flex flex-wrap items-center gap-1.5">
|
|
180
|
+
{s.name}
|
|
181
|
+
{mode === "integration" ? (
|
|
182
|
+
<>
|
|
183
|
+
<Badge tone={s.provider === "resend" ? "secondary" : "info"} className="uppercase tracking-wider text-[10px]">
|
|
184
|
+
{s.provider}
|
|
185
|
+
</Badge>
|
|
186
|
+
{s.configured ?? true
|
|
187
|
+
? <StatusBadge tone="success" className="text-[10px]"><KeyRound className="h-2.5 w-2.5 mr-0.5 inline" />{t("settings.smtpPasswordSet")}</StatusBadge>
|
|
188
|
+
: <StatusBadge tone="warning" className="text-[10px]">{t("settings.smtpNoPassword")}</StatusBadge>}
|
|
189
|
+
</>
|
|
190
|
+
) : (
|
|
191
|
+
s.passSet
|
|
192
|
+
? <StatusBadge tone="success" className="text-[10px]"><KeyRound className="h-2.5 w-2.5 mr-0.5 inline" />{t("settings.smtpPasswordSet")}</StatusBadge>
|
|
193
|
+
: <StatusBadge tone="warning" className="text-[10px]">{t("settings.smtpNoPassword")}</StatusBadge>
|
|
194
|
+
)}
|
|
195
|
+
</div>
|
|
196
|
+
<div className="text-xs text-muted-foreground mt-1 font-mono">
|
|
197
|
+
{mode === "integration"
|
|
198
|
+
? formatIntegrationSenderSummary(s)
|
|
199
|
+
: `${s.fromEmail} via ${s.host}:${s.port}`}
|
|
200
|
+
</div>
|
|
158
201
|
</div>
|
|
202
|
+
{canManageSMTP && (
|
|
203
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
204
|
+
<Button
|
|
205
|
+
variant="subtle"
|
|
206
|
+
onClick={() => test(s)}
|
|
207
|
+
disabled={testingId === s.id}
|
|
208
|
+
className="text-xs py-1 px-2.5"
|
|
209
|
+
>
|
|
210
|
+
{testingId === s.id ? t("settings.testing") : t("settings.test")}
|
|
211
|
+
</Button>
|
|
212
|
+
{mode === "integration" ? (
|
|
213
|
+
<NavLink to="/settings/integrations?category=communication">
|
|
214
|
+
<Button variant="subtle" className="text-xs py-1 px-2.5">
|
|
215
|
+
{t("settings.openIntegrationsHub")}
|
|
216
|
+
</Button>
|
|
217
|
+
</NavLink>
|
|
218
|
+
) : (
|
|
219
|
+
<>
|
|
220
|
+
<Button variant="subtle" onClick={() => setEditing(s)} className="text-xs py-1 px-2.5">
|
|
221
|
+
{t("settings.editSmtp")}
|
|
222
|
+
</Button>
|
|
223
|
+
<Button
|
|
224
|
+
variant="danger"
|
|
225
|
+
onClick={() => remove(s.id)}
|
|
226
|
+
className="text-xs py-1 px-2.5 border-0"
|
|
227
|
+
>
|
|
228
|
+
{t("settings.remove")}
|
|
229
|
+
</Button>
|
|
230
|
+
</>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
)}
|
|
159
234
|
</div>
|
|
160
|
-
|
|
161
|
-
<div className="flex items-center gap-2">
|
|
162
|
-
<Button
|
|
163
|
-
variant="subtle"
|
|
164
|
-
onClick={() => test(s)}
|
|
165
|
-
disabled={testingId === s.id}
|
|
166
|
-
className="text-xs py-1 px-2.5"
|
|
167
|
-
>
|
|
168
|
-
{testingId === s.id ? t("settings.testing") : t("settings.test")}
|
|
169
|
-
</Button>
|
|
170
|
-
{mode === "integration" ? (
|
|
171
|
-
<NavLink to="/settings/integrations?category=communication">
|
|
172
|
-
<Button variant="subtle" className="text-xs py-1 px-2.5">
|
|
173
|
-
{t("settings.openIntegrationsHub")}
|
|
174
|
-
</Button>
|
|
175
|
-
</NavLink>
|
|
176
|
-
) : (
|
|
177
|
-
<>
|
|
178
|
-
<Button variant="subtle" onClick={() => setEditing(s)} className="text-xs py-1 px-2.5">
|
|
179
|
-
{t("settings.editSmtp")}
|
|
180
|
-
</Button>
|
|
181
|
-
<Button
|
|
182
|
-
variant="danger"
|
|
183
|
-
onClick={() => remove(s.id)}
|
|
184
|
-
className="text-xs py-1 px-2.5 border-0"
|
|
185
|
-
>
|
|
186
|
-
{t("settings.remove")}
|
|
187
|
-
</Button>
|
|
188
|
-
</>
|
|
189
|
-
)}
|
|
190
|
-
</div>
|
|
191
|
-
)}
|
|
192
|
-
</div>
|
|
235
|
+
</Fragment>
|
|
193
236
|
))}
|
|
194
|
-
</
|
|
237
|
+
</PageRows>
|
|
195
238
|
)}
|
|
196
239
|
{(creating || editing) && (
|
|
197
240
|
<SMTPSenderModal
|
|
@@ -200,7 +243,7 @@ export function SMTPSenders() {
|
|
|
200
243
|
onSaved={() => { setCreating(false); setEditing(null); load(); }}
|
|
201
244
|
/>
|
|
202
245
|
)}
|
|
203
|
-
</
|
|
246
|
+
</PageSection>
|
|
204
247
|
);
|
|
205
248
|
}
|
|
206
249
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Modal, Field, Input, Badge, Empty, Panel, confirmDialog, timeAgo, Table, THead, TBody, TR, TH, TD, FormError, useTranslation } from "@octarq/plugin-sdk";
|
|
1
|
+
import { Button, Modal, Field, Input, Badge, Empty, Panel, confirmDialog, timeAgo, Table, THead, TBody, TR, TH, TD, TableSkeleton, FormError, useTranslation } from "@octarq/plugin-sdk";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { mailApi, MailSuppression } from "../api";
|
|
4
4
|
import { Plus, Trash2, ShieldAlert } from "lucide-react";
|
|
@@ -76,7 +76,9 @@ export function SuppressionList() {
|
|
|
76
76
|
>
|
|
77
77
|
|
|
78
78
|
{loading && items.length === 0 ? (
|
|
79
|
-
<div className="
|
|
79
|
+
<div className="overflow-x-auto border border-border rounded-lg">
|
|
80
|
+
<TableSkeleton columnsCount={5} rowsCount={5} ariaLabel={t("mail.loading")} />
|
|
81
|
+
</div>
|
|
80
82
|
) : items.length === 0 ? (
|
|
81
83
|
<Empty reason={t("mail.noSuppressions")}>
|
|
82
84
|
<ShieldAlert />
|
package/pages/forms.test.tsx
CHANGED
|
@@ -39,8 +39,30 @@ const mockIntegrations = [
|
|
|
39
39
|
provider: "smtp",
|
|
40
40
|
providerType: "communication",
|
|
41
41
|
configured: true,
|
|
42
|
-
summary: "noreply@acme.com via smtp.mailgun.org:587",
|
|
43
42
|
isDefault: true,
|
|
43
|
+
metadata: {
|
|
44
|
+
fromEmail: "noreply@acme.com",
|
|
45
|
+
fromName: "Acme Mail",
|
|
46
|
+
smtpHost: "smtp.mailgun.org",
|
|
47
|
+
smtpPort: 587,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 2,
|
|
52
|
+
name: "Transactional Resend",
|
|
53
|
+
provider: "resend",
|
|
54
|
+
providerType: "communication",
|
|
55
|
+
configured: true,
|
|
56
|
+
metadata: {
|
|
57
|
+
fromEmail: "alerts@acme.com",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 3,
|
|
62
|
+
name: "Bare SMTP",
|
|
63
|
+
provider: "smtp",
|
|
64
|
+
providerType: "communication",
|
|
65
|
+
configured: false,
|
|
44
66
|
},
|
|
45
67
|
];
|
|
46
68
|
|
|
@@ -92,6 +114,7 @@ const testResources = {
|
|
|
92
114
|
noSmtpConfigured: "No SMTP outgoing senders configured.",
|
|
93
115
|
noSmtpSenders: "No SMTP outgoing senders configured.",
|
|
94
116
|
smtpPasswordSet: "password set",
|
|
117
|
+
smtpNoPassword: "no password",
|
|
95
118
|
integrationsHubBanner: "Manage third-party credentials and cloud provider integrations centrally.",
|
|
96
119
|
openIntegrationsHub: "Integrations Hub",
|
|
97
120
|
addSmtpSender: "Add SMTP Sender",
|
|
@@ -147,10 +170,10 @@ describe("Mail Forms", () => {
|
|
|
147
170
|
const urlObj = new URL(rawUrl, "http://localhost");
|
|
148
171
|
const path = urlObj.pathname;
|
|
149
172
|
|
|
150
|
-
if (method === "GET" && path === "/api/
|
|
173
|
+
if (method === "GET" && path === "/api/vault/items") {
|
|
151
174
|
return jsonResponse(mockIntegrations);
|
|
152
175
|
}
|
|
153
|
-
if (method === "POST" && path.startsWith("/api/
|
|
176
|
+
if (method === "POST" && path.startsWith("/api/vault/items/") && path.endsWith("/test")) {
|
|
154
177
|
return jsonResponse({ ok: true, message: "Sent test email via Corporate Mailgun." });
|
|
155
178
|
}
|
|
156
179
|
|
|
@@ -237,7 +260,9 @@ describe("Mail Forms", () => {
|
|
|
237
260
|
// Wait for settings & senders to load and checkbox to appear
|
|
238
261
|
await waitFor(() => {
|
|
239
262
|
expect(screen.getByRole("checkbox")).toBeDefined();
|
|
263
|
+
expect(screen.getAllByText("Corporate Mailgun (noreply@acme.com)").length).toBeGreaterThan(0);
|
|
240
264
|
});
|
|
265
|
+
expect(document.body.textContent).not.toContain("undefined");
|
|
241
266
|
|
|
242
267
|
// Fill in recipients, subject, body
|
|
243
268
|
const toInput = screen.getByPlaceholderText("hello@world.com");
|
|
@@ -316,7 +341,7 @@ describe("Mail Forms", () => {
|
|
|
316
341
|
const urlObj = new URL(rawUrl, "http://localhost");
|
|
317
342
|
const path = urlObj.pathname;
|
|
318
343
|
|
|
319
|
-
if (method === "GET" && (path === "/api/
|
|
344
|
+
if (method === "GET" && (path === "/api/vault/items" || path === "/api/smtp-senders")) return jsonResponse(mockIntegrations);
|
|
320
345
|
if (method === "GET" && path === "/api/settings") return jsonResponse({});
|
|
321
346
|
if (method === "POST" && path === "/api/emails/send") {
|
|
322
347
|
return jsonResponse({ message: "SMTP relay authentication failed" }, 400);
|
|
@@ -348,7 +373,7 @@ describe("Mail Forms", () => {
|
|
|
348
373
|
const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
|
|
349
374
|
const urlObj = new URL(rawUrl, "http://localhost");
|
|
350
375
|
const path = urlObj.pathname;
|
|
351
|
-
if (method === "GET" && (path === "/api/
|
|
376
|
+
if (method === "GET" && (path === "/api/vault/items" || path === "/api/smtp-senders")) return jsonResponse([]);
|
|
352
377
|
if (method === "GET" && path === "/api/settings") return jsonResponse({});
|
|
353
378
|
throw new Error(`Unhandled fetch: ${method} ${rawUrl}`);
|
|
354
379
|
});
|
|
@@ -361,16 +386,15 @@ describe("Mail Forms", () => {
|
|
|
361
386
|
});
|
|
362
387
|
});
|
|
363
388
|
|
|
364
|
-
// Standalone Core
|
|
365
|
-
|
|
366
|
-
it("falls back to local SMTP senders when the Integrations Hub is absent", async () => {
|
|
389
|
+
// Standalone instances without Core Vault still serve the local sender registry.
|
|
390
|
+
it("falls back to local SMTP senders when Core Vault is absent", async () => {
|
|
367
391
|
fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
368
392
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
369
393
|
const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
|
|
370
394
|
const urlObj = new URL(rawUrl, "http://localhost");
|
|
371
395
|
const path = urlObj.pathname;
|
|
372
396
|
|
|
373
|
-
if (method === "GET" && path === "/api/
|
|
397
|
+
if (method === "GET" && path === "/api/vault/items") return jsonResponse({ detail: "Not Found" }, 404);
|
|
374
398
|
if (method === "GET" && path === "/api/smtp-senders") return jsonResponse(mockSenders);
|
|
375
399
|
if (method === "GET" && path === "/api/settings") return jsonResponse({});
|
|
376
400
|
if (method === "POST" && path === "/api/emails/send") return jsonResponse({ ok: true });
|
|
@@ -491,40 +515,63 @@ describe("Mail Forms", () => {
|
|
|
491
515
|
});
|
|
492
516
|
|
|
493
517
|
describe("SMTPSenders", () => {
|
|
494
|
-
it("uses
|
|
518
|
+
it("uses Core Vault when it is mounted and hides the local sender form", async () => {
|
|
495
519
|
renderWithProviders(<SMTPSenders />);
|
|
496
520
|
|
|
497
521
|
await waitFor(() => {
|
|
498
522
|
expect(screen.getByText("Corporate Mailgun")).toBeDefined();
|
|
499
523
|
expect(screen.getByText("noreply@acme.com via smtp.mailgun.org:587")).toBeDefined();
|
|
500
|
-
expect(screen.getByText("
|
|
524
|
+
expect(screen.getByText("alerts@acme.com")).toBeDefined();
|
|
525
|
+
expect(screen.getByText("Bare SMTP")).toBeDefined();
|
|
526
|
+
expect(screen.getAllByText("password set").length).toBeGreaterThan(0);
|
|
527
|
+
expect(screen.getByText("no password")).toBeDefined();
|
|
501
528
|
expect(screen.getByText("Manage third-party credentials and cloud provider integrations centrally.")).toBeDefined();
|
|
502
529
|
});
|
|
503
530
|
|
|
504
|
-
|
|
505
|
-
|
|
531
|
+
expect(document.body.textContent).not.toContain("undefined");
|
|
532
|
+
|
|
533
|
+
// Test connection goes through Core Vault, not the local table.
|
|
534
|
+
fireEvent.click(screen.getAllByRole("button", { name: "Test" })[0]);
|
|
506
535
|
|
|
507
536
|
await waitFor(() => {
|
|
508
537
|
const tested = fetchMock.mock.calls.some((c) => {
|
|
509
538
|
const url = typeof c[0] === "string" ? c[0] : (c[0] as Request).url;
|
|
510
|
-
return url.includes("/api/
|
|
539
|
+
return url.includes("/api/vault/items/1/test");
|
|
511
540
|
});
|
|
512
541
|
expect(tested).toBe(true);
|
|
513
542
|
});
|
|
514
543
|
|
|
515
|
-
// The local CRUD surfaces stay absent while
|
|
544
|
+
// The local CRUD surfaces stay absent while Core Vault is authoritative.
|
|
516
545
|
expect(screen.queryByRole("button", { name: "Add SMTP" })).toBeNull();
|
|
517
546
|
expect(screen.queryByRole("button", { name: "Edit SMTP" })).toBeNull();
|
|
518
547
|
expect(screen.queryByRole("button", { name: "Remove" })).toBeNull();
|
|
519
548
|
});
|
|
520
549
|
|
|
521
|
-
it("
|
|
550
|
+
it("unwraps { body: [...] } envelope from Core Vault API", async () => {
|
|
551
|
+
fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
552
|
+
const method = (init?.method ?? "GET").toUpperCase();
|
|
553
|
+
const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
|
|
554
|
+
const urlObj = new URL(rawUrl, "http://localhost");
|
|
555
|
+
if (method === "GET" && urlObj.pathname === "/api/vault/items" && urlObj.searchParams.get("provider_type") === "communication") {
|
|
556
|
+
return jsonResponse({ body: mockIntegrations });
|
|
557
|
+
}
|
|
558
|
+
throw new Error(`Unhandled fetch: ${method} ${rawUrl}`);
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
renderWithProviders(<SMTPSenders />);
|
|
562
|
+
|
|
563
|
+
await waitFor(() => {
|
|
564
|
+
expect(screen.getByText("Corporate Mailgun")).toBeDefined();
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
it("renders empty state with deep link when Core Vault has no senders", async () => {
|
|
522
569
|
fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
523
570
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
524
571
|
const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
|
|
525
572
|
const urlObj = new URL(rawUrl, "http://localhost");
|
|
526
573
|
const path = urlObj.pathname;
|
|
527
|
-
if (method === "GET" && path === "/api/
|
|
574
|
+
if (method === "GET" && path === "/api/vault/items") return jsonResponse([]);
|
|
528
575
|
throw new Error(`Unhandled fetch: ${method} ${rawUrl}`);
|
|
529
576
|
});
|
|
530
577
|
|
|
@@ -536,16 +583,15 @@ describe("Mail Forms", () => {
|
|
|
536
583
|
});
|
|
537
584
|
});
|
|
538
585
|
|
|
539
|
-
// Standalone Core
|
|
540
|
-
|
|
541
|
-
it("serves the local sender registry when the Integrations Hub is absent", async () => {
|
|
586
|
+
// Standalone instances without Core Vault serve the local registry and keep its CRUD controls.
|
|
587
|
+
it("serves the local sender registry when Core Vault is absent", async () => {
|
|
542
588
|
fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
543
589
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
544
590
|
const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
|
|
545
591
|
const urlObj = new URL(rawUrl, "http://localhost");
|
|
546
592
|
const path = urlObj.pathname;
|
|
547
593
|
|
|
548
|
-
if (method === "GET" && path === "/api/
|
|
594
|
+
if (method === "GET" && path === "/api/vault/items") return jsonResponse({ detail: "Not Found" }, 404);
|
|
549
595
|
if (method === "GET" && path === "/api/smtp-senders") return jsonResponse(mockSenders);
|
|
550
596
|
if (method === "POST" && path === "/api/smtp-senders/1/test") return jsonResponse({ ok: true });
|
|
551
597
|
if (method === "POST" && path === "/api/smtp-senders") {
|
package/pages/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PageShell, Button, useTranslation } from "@octarq/plugin-sdk";
|
|
2
2
|
import { useEffect, useState, useMemo } from "react";
|
|
3
3
|
import { useSearchParams } from "react-router-dom";
|
|
4
4
|
import { mailApi, Domain, effectiveMailHosts, Email, Mailbox } from "../api";
|
|
@@ -121,26 +121,25 @@ export default function MailPage() {
|
|
|
121
121
|
const totalUnread = useMemo(() => boxes.reduce((acc, b) => acc + (b.unread || 0), 0), [boxes]);
|
|
122
122
|
|
|
123
123
|
return (
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/>
|
|
124
|
+
<PageShell
|
|
125
|
+
title={t("mail.pageTitle")}
|
|
126
|
+
description={t("mail.pageDesc")}
|
|
127
|
+
action={
|
|
128
|
+
<div className="flex items-center gap-2">
|
|
129
|
+
<Button variant="ghost" size="sm" onClick={markAllRead}>
|
|
130
|
+
{t("mail.markRead")}
|
|
131
|
+
</Button>
|
|
132
|
+
<Button variant="outline" size="sm" onClick={() => setCompose(true)}>
|
|
133
|
+
<Send className="h-3.5 w-3.5" />
|
|
134
|
+
{t("mail.compose")}
|
|
135
|
+
</Button>
|
|
136
|
+
<Button variant="primary" size="sm" onClick={() => setNewBox(true)}>
|
|
137
|
+
<Plus className="h-3.5 w-3.5" />
|
|
138
|
+
{t("mail.newMailbox")}
|
|
139
|
+
</Button>
|
|
140
|
+
</div>
|
|
141
|
+
}
|
|
142
|
+
>
|
|
144
143
|
|
|
145
144
|
<MailTabs tab={tab} onTabChange={setTab} />
|
|
146
145
|
|
|
@@ -184,8 +183,8 @@ export default function MailPage() {
|
|
|
184
183
|
onChanged={() => { loadEmails(true); loadBoxes(); }}
|
|
185
184
|
/>
|
|
186
185
|
) : (
|
|
187
|
-
<div className="flex min-h-[420px] flex-col items-center justify-center gap-3 rounded-
|
|
188
|
-
<div className="flex h-12 w-12 items-center justify-center rounded-
|
|
186
|
+
<div className="flex min-h-[420px] flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-well px-6 py-16 text-center">
|
|
187
|
+
<div className="flex h-12 w-12 items-center justify-center rounded-lg border border-border bg-card text-accent-fg">
|
|
189
188
|
<Inbox className="h-5 w-5" />
|
|
190
189
|
</div>
|
|
191
190
|
<p className="font-display text-[13px] text-foreground">{t("mail.selectEmail")}</p>
|
|
@@ -209,6 +208,6 @@ export default function MailPage() {
|
|
|
209
208
|
onDraftSaved={() => { loadEmails(true); }}
|
|
210
209
|
/>
|
|
211
210
|
)}
|
|
212
|
-
</
|
|
211
|
+
</PageShell>
|
|
213
212
|
);
|
|
214
213
|
}
|
|
@@ -14,9 +14,9 @@ export default function MailSetupStepWidget() {
|
|
|
14
14
|
let cancelled = false;
|
|
15
15
|
(async () => {
|
|
16
16
|
try {
|
|
17
|
-
//
|
|
17
|
+
// Core Vault owns mail senders when it is mounted. Count the
|
|
18
18
|
// same registry the mail pages offer, not just the local table.
|
|
19
|
-
const res = await fetch("/api/
|
|
19
|
+
const res = await fetch("/api/vault/items?provider_type=communication", {
|
|
20
20
|
credentials: "same-origin",
|
|
21
21
|
});
|
|
22
22
|
if (res.status === 404) {
|
|
@@ -26,7 +26,8 @@ export default function MailSetupStepWidget() {
|
|
|
26
26
|
}
|
|
27
27
|
if (!res.ok) return;
|
|
28
28
|
const data = await res.json();
|
|
29
|
-
const
|
|
29
|
+
const raw = Array.isArray(data) ? data : (data?.body ?? []);
|
|
30
|
+
const list = (Array.isArray(raw) ? raw : []).filter(
|
|
30
31
|
(item: any) => item.provider === "smtp" || item.provider === "resend"
|
|
31
32
|
);
|
|
32
33
|
if (!cancelled) setSmtpCount(list.length);
|