@rapidmx/web-client 0.3.0 → 0.4.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/apps/admin/branding/index.tsx +39 -404
- package/apps/admin/domains/[uid].tsx +92 -259
- package/apps/admin/encryption-policy/index.tsx +19 -0
- package/apps/admin/index.tsx +100 -82
- package/apps/admin/mailbox-policy/index.tsx +19 -0
- package/apps/admin/mailboxes/new/index.tsx +28 -291
- package/apps/admin/plugins/index.tsx +15 -0
- package/apps/admin/retention-policy/index.tsx +39 -132
- package/apps/admin/setup/index.tsx +15 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +249 -210
- package/apps/shared/components/admin/settings/BrandingForm.tsx +374 -0
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +176 -0
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +104 -0
- package/apps/shared/components/admin/settings/LoadedSettingsForm.tsx +34 -0
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +302 -0
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +119 -0
- package/apps/shared/components/admin/settings/PluginsManager.tsx +595 -0
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +98 -0
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +254 -0
- package/apps/shared/components/admin/setup/SetupWizard.tsx +300 -0
- package/apps/shared/components/calendar/CalendarListSidebar.tsx +120 -76
- package/apps/shared/components/calendar/EventModal.tsx +40 -4
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +80 -99
- package/apps/shared/components/contacts/ContactForm.tsx +38 -4
- package/apps/shared/components/layout/AppShell.tsx +198 -169
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +298 -265
- package/apps/shared/components/layout/UnlockPromptProvider.tsx +128 -0
- package/apps/shared/components/mail/MessageDetailPane.tsx +630 -595
- package/apps/shared/components/mail/compose/ComposeContext.tsx +8 -3
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +930 -765
- package/apps/shared/components/mail/layout/MailShell.tsx +408 -302
- package/apps/shared/components/settings/layout/SettingsShell.tsx +1 -0
- package/apps/shared/mail/findWellKnownFolderUid.ts +13 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +89 -0
- package/apps/shared/search/localIndexBlockCipher.ts +83 -0
- package/apps/shared/search/localIndexBuilder.ts +179 -0
- package/apps/shared/search/localIndexKey.ts +27 -0
- package/apps/shared/search/localIndexRpcClient.ts +116 -0
- package/apps/shared/search/localIndexSchema.ts +227 -0
- package/apps/shared/search/localIndexSizePreference.ts +88 -0
- package/apps/shared/search/localIndexVFS.ts +235 -0
- package/apps/shared/search/localIndexWorker.ts +464 -0
- package/apps/shared/search/searchTier2.ts +79 -0
- package/apps/shared/search/wa-sqlite-shims.d.ts +44 -0
- package/apps/www/calendar/index.tsx +31 -21
- package/apps/www/contacts/index.tsx +33 -6
- package/apps/www/index.tsx +661 -106
- package/apps/www/messages/[uid].tsx +5 -1
- package/apps/www/settings/encryption/index.tsx +63 -1
- package/apps/www/settings/sharing/index.tsx +271 -0
- package/apps/www/tasks/index.tsx +53 -4
- package/dist/apps/admin/branding/index.js +4 -98
- package/dist/apps/admin/domains/[uid].js +5 -68
- package/dist/apps/admin/encryption-policy/index.js +8 -0
- package/dist/apps/admin/index.js +14 -1
- package/dist/apps/admin/mailbox-policy/index.js +8 -0
- package/dist/apps/admin/mailboxes/new/index.js +4 -89
- package/dist/apps/admin/plugins/index.js +6 -0
- package/dist/apps/admin/retention-policy/index.js +3 -36
- package/dist/apps/admin/setup/index.js +6 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.js +34 -3
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +105 -0
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +77 -0
- package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.js +57 -0
- package/dist/apps/shared/components/admin/settings/LoadedSettingsForm.js +25 -0
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +106 -0
- package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +52 -0
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +260 -0
- package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.js +44 -0
- package/dist/apps/shared/components/admin/setup/EscrowSetupStep.js +131 -0
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +142 -0
- package/dist/apps/shared/components/calendar/CalendarListSidebar.js +24 -13
- package/dist/apps/shared/components/calendar/EventModal.js +16 -4
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +47 -39
- package/dist/apps/shared/components/contacts/ContactForm.js +16 -5
- package/dist/apps/shared/components/layout/AppShell.js +30 -7
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +15 -3
- package/dist/apps/shared/components/layout/UnlockPromptProvider.js +77 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.js +27 -2
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +2 -2
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +134 -14
- package/dist/apps/shared/components/mail/layout/MailShell.js +106 -40
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +1 -0
- package/dist/apps/shared/mail/findWellKnownFolderUid.js +12 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.js +76 -0
- package/dist/apps/shared/search/localIndexBlockCipher.js +63 -0
- package/dist/apps/shared/search/localIndexBuilder.js +153 -0
- package/dist/apps/shared/search/localIndexKey.js +25 -0
- package/dist/apps/shared/search/localIndexRpcClient.js +78 -0
- package/dist/apps/shared/search/localIndexSchema.js +179 -0
- package/dist/apps/shared/search/localIndexSizePreference.js +78 -0
- package/dist/apps/shared/search/localIndexVFS.js +230 -0
- package/dist/apps/shared/search/localIndexWorker.js +341 -0
- package/dist/apps/shared/search/searchTier2.js +38 -0
- package/dist/apps/www/calendar/index.js +14 -12
- package/dist/apps/www/contacts/index.js +15 -6
- package/dist/apps/www/index.js +496 -94
- package/dist/apps/www/messages/[uid].js +5 -1
- package/dist/apps/www/settings/encryption/index.js +30 -2
- package/dist/apps/www/settings/sharing/index.js +128 -0
- package/dist/apps/www/tasks/index.js +27 -5
- package/package.json +3 -2
|
@@ -1,404 +1,39 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, {
|
|
6
|
-
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
getBranding()
|
|
42
|
-
.then(setBranding)
|
|
43
|
-
.catch((err) => setLoadError(err instanceof ApiRequestError ? err.message : "Could not load branding."))
|
|
44
|
-
.finally(() => setLoading(false));
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
if (loading) {
|
|
48
|
-
return <p className="text-sm text-text-muted">Loading…</p>;
|
|
49
|
-
}
|
|
50
|
-
if (loadError || !branding) {
|
|
51
|
-
return <Alert>{loadError}</Alert>;
|
|
52
|
-
}
|
|
53
|
-
return <BrandingForm branding={branding} onChange={setBranding} />;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function BrandingForm({ branding, onChange }: { branding: Branding; onChange: (b: Branding) => void }) {
|
|
57
|
-
const [companyName, setCompanyName] = useState(branding.companyName);
|
|
58
|
-
const [title, setTitle] = useState(branding.title);
|
|
59
|
-
const [headerHtml, setHeaderHtml] = useState(branding.headerHtml ?? "");
|
|
60
|
-
const [footerHtml, setFooterHtml] = useState(branding.footerHtml ?? "");
|
|
61
|
-
const [logoUrlInput, setLogoUrlInput] = useState(branding.logoUrl ?? "");
|
|
62
|
-
const [iconUrlInput, setIconUrlInput] = useState(branding.iconUrl ?? "");
|
|
63
|
-
const [stylesheetUrlInput, setStylesheetUrlInput] = useState(branding.stylesheetUrl ?? "");
|
|
64
|
-
|
|
65
|
-
const [error, setError] = useState<string | null>(null);
|
|
66
|
-
const [saving, setSaving] = useState(false);
|
|
67
|
-
const [saved, setSaved] = useState(false);
|
|
68
|
-
const [assetBusy, setAssetBusy] = useState<string | null>(null);
|
|
69
|
-
|
|
70
|
-
const logoFileRef = useRef<HTMLInputElement>(null);
|
|
71
|
-
const iconFileRef = useRef<HTMLInputElement>(null);
|
|
72
|
-
const stylesheetFileRef = useRef<HTMLInputElement>(null);
|
|
73
|
-
|
|
74
|
-
function runAsset(name: string, action: () => Promise<Branding>) {
|
|
75
|
-
setError(null);
|
|
76
|
-
setAssetBusy(name);
|
|
77
|
-
return action()
|
|
78
|
-
.then((updated) => {
|
|
79
|
-
onChange(updated);
|
|
80
|
-
setLogoUrlInput(updated.logoUrl ?? "");
|
|
81
|
-
setIconUrlInput(updated.iconUrl ?? "");
|
|
82
|
-
setStylesheetUrlInput(updated.stylesheetUrl ?? "");
|
|
83
|
-
})
|
|
84
|
-
.catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not update branding."))
|
|
85
|
-
.finally(() => setAssetBusy(null));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function handleLogoFileChange(e: ChangeEvent<HTMLInputElement>) {
|
|
89
|
-
const file = e.target.files?.[0];
|
|
90
|
-
if (!file) return;
|
|
91
|
-
if (file.size > MAX_UPLOAD_BYTES) {
|
|
92
|
-
setError(`"${file.name}" is too large — logos must be 5MB or smaller.`);
|
|
93
|
-
} else {
|
|
94
|
-
void runAsset("logo-upload", () => uploadBrandingLogo(file));
|
|
95
|
-
}
|
|
96
|
-
e.target.value = "";
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function handleIconFileChange(e: ChangeEvent<HTMLInputElement>) {
|
|
100
|
-
const file = e.target.files?.[0];
|
|
101
|
-
if (!file) return;
|
|
102
|
-
if (file.size > MAX_UPLOAD_BYTES) {
|
|
103
|
-
setError(`"${file.name}" is too large — icons must be 5MB or smaller.`);
|
|
104
|
-
} else {
|
|
105
|
-
void runAsset("icon-upload", () => uploadBrandingIcon(file));
|
|
106
|
-
}
|
|
107
|
-
e.target.value = "";
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function handleStylesheetFileChange(e: ChangeEvent<HTMLInputElement>) {
|
|
111
|
-
const file = e.target.files?.[0];
|
|
112
|
-
if (!file) return;
|
|
113
|
-
if (file.size > MAX_UPLOAD_BYTES) {
|
|
114
|
-
setError(`"${file.name}" is too large — stylesheets must be 5MB or smaller.`);
|
|
115
|
-
} else {
|
|
116
|
-
void runAsset("stylesheet-upload", () => uploadBrandingStylesheet(file));
|
|
117
|
-
}
|
|
118
|
-
e.target.value = "";
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function handleSubmit(e: FormEvent) {
|
|
122
|
-
e.preventDefault();
|
|
123
|
-
setError(null);
|
|
124
|
-
setSaved(false);
|
|
125
|
-
setSaving(true);
|
|
126
|
-
try {
|
|
127
|
-
const updated = await updateBranding({ companyName, title, headerHtml, footerHtml });
|
|
128
|
-
onChange(updated);
|
|
129
|
-
setSaved(true);
|
|
130
|
-
} catch (err) {
|
|
131
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not save branding.");
|
|
132
|
-
} finally {
|
|
133
|
-
setSaving(false);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<div className="max-w-2xl">
|
|
139
|
-
<h1 className="text-xl font-bold uppercase tracking-wide mb-1">Branding</h1>
|
|
140
|
-
<p className="text-sm text-text-muted mb-5">
|
|
141
|
-
Customize the logo, nav-header icon, product name, and chrome shown to every visitor of the
|
|
142
|
-
webmail and admin console — including anonymous booking-page visitors.
|
|
143
|
-
</p>
|
|
144
|
-
|
|
145
|
-
{error && <Alert>{error}</Alert>}
|
|
146
|
-
{saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
|
|
147
|
-
|
|
148
|
-
<div className="flex flex-col gap-6">
|
|
149
|
-
<section className="flex flex-col gap-3">
|
|
150
|
-
<h2 className="text-sm font-bold uppercase tracking-wide text-text-muted">Logo</h2>
|
|
151
|
-
<div className="flex items-center gap-4">
|
|
152
|
-
<img
|
|
153
|
-
src={branding.logoUrl || "/images/logo.svg"}
|
|
154
|
-
alt="Current logo"
|
|
155
|
-
width="64"
|
|
156
|
-
height="64"
|
|
157
|
-
className="border border-border rounded-sm bg-surface-alt p-1"
|
|
158
|
-
/>
|
|
159
|
-
<div className="flex flex-col gap-2">
|
|
160
|
-
<Button
|
|
161
|
-
type="button"
|
|
162
|
-
variant="secondary"
|
|
163
|
-
className="!w-auto"
|
|
164
|
-
loading={assetBusy === "logo-upload"}
|
|
165
|
-
disabled={assetBusy !== null}
|
|
166
|
-
onClick={() => logoFileRef.current?.click()}
|
|
167
|
-
>
|
|
168
|
-
Upload logo
|
|
169
|
-
</Button>
|
|
170
|
-
<input
|
|
171
|
-
ref={logoFileRef}
|
|
172
|
-
type="file"
|
|
173
|
-
accept="image/*"
|
|
174
|
-
aria-label="Upload logo"
|
|
175
|
-
className="hidden"
|
|
176
|
-
onChange={handleLogoFileChange}
|
|
177
|
-
/>
|
|
178
|
-
{branding.logoUrl && (
|
|
179
|
-
<Button
|
|
180
|
-
type="button"
|
|
181
|
-
variant="text"
|
|
182
|
-
disabled={assetBusy !== null}
|
|
183
|
-
loading={assetBusy === "logo-delete"}
|
|
184
|
-
onClick={() => void runAsset("logo-delete", async () => {
|
|
185
|
-
await deleteBrandingLogo();
|
|
186
|
-
return { ...branding, logoUrl: undefined };
|
|
187
|
-
})}
|
|
188
|
-
>
|
|
189
|
-
Remove logo
|
|
190
|
-
</Button>
|
|
191
|
-
)}
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
195
|
-
<span className="font-semibold">Or use an external image URL</span>
|
|
196
|
-
<div className="flex gap-2">
|
|
197
|
-
<input
|
|
198
|
-
aria-label="Logo URL"
|
|
199
|
-
className={INPUT_CLASS}
|
|
200
|
-
value={logoUrlInput}
|
|
201
|
-
onChange={(e) => setLogoUrlInput(e.target.value)}
|
|
202
|
-
/>
|
|
203
|
-
<Button
|
|
204
|
-
type="button"
|
|
205
|
-
variant="secondary"
|
|
206
|
-
className="!w-auto"
|
|
207
|
-
disabled={assetBusy !== null || logoUrlInput === (branding.logoUrl ?? "")}
|
|
208
|
-
loading={assetBusy === "logo-url"}
|
|
209
|
-
onClick={() => void runAsset("logo-url", () => updateBranding({ logoUrl: logoUrlInput }))}
|
|
210
|
-
>
|
|
211
|
-
Set
|
|
212
|
-
</Button>
|
|
213
|
-
</div>
|
|
214
|
-
</label>
|
|
215
|
-
</section>
|
|
216
|
-
|
|
217
|
-
<section className="flex flex-col gap-3">
|
|
218
|
-
<h2 className="text-sm font-bold uppercase tracking-wide text-text-muted">Icon</h2>
|
|
219
|
-
<p className="text-xs text-text-muted -mt-1">
|
|
220
|
-
A compact mark for navigation headers, independent of the full logo above. Falls back to
|
|
221
|
-
the logo, then a default asset, when not set.
|
|
222
|
-
</p>
|
|
223
|
-
<div className="flex items-center gap-4">
|
|
224
|
-
<img
|
|
225
|
-
src={branding.iconUrl || branding.logoUrl || "/images/logo.svg"}
|
|
226
|
-
alt="Current icon"
|
|
227
|
-
width="64"
|
|
228
|
-
height="64"
|
|
229
|
-
className="border border-border rounded-sm bg-surface-alt p-1"
|
|
230
|
-
/>
|
|
231
|
-
<div className="flex flex-col gap-2">
|
|
232
|
-
<Button
|
|
233
|
-
type="button"
|
|
234
|
-
variant="secondary"
|
|
235
|
-
className="!w-auto"
|
|
236
|
-
loading={assetBusy === "icon-upload"}
|
|
237
|
-
disabled={assetBusy !== null}
|
|
238
|
-
onClick={() => iconFileRef.current?.click()}
|
|
239
|
-
>
|
|
240
|
-
Upload icon
|
|
241
|
-
</Button>
|
|
242
|
-
<input
|
|
243
|
-
ref={iconFileRef}
|
|
244
|
-
type="file"
|
|
245
|
-
accept="image/*"
|
|
246
|
-
aria-label="Upload icon"
|
|
247
|
-
className="hidden"
|
|
248
|
-
onChange={handleIconFileChange}
|
|
249
|
-
/>
|
|
250
|
-
{branding.iconUrl && (
|
|
251
|
-
<Button
|
|
252
|
-
type="button"
|
|
253
|
-
variant="text"
|
|
254
|
-
disabled={assetBusy !== null}
|
|
255
|
-
loading={assetBusy === "icon-delete"}
|
|
256
|
-
onClick={() => void runAsset("icon-delete", async () => {
|
|
257
|
-
await deleteBrandingIcon();
|
|
258
|
-
return { ...branding, iconUrl: undefined };
|
|
259
|
-
})}
|
|
260
|
-
>
|
|
261
|
-
Remove icon
|
|
262
|
-
</Button>
|
|
263
|
-
)}
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
267
|
-
<span className="font-semibold">Or use an external image URL</span>
|
|
268
|
-
<div className="flex gap-2">
|
|
269
|
-
<input
|
|
270
|
-
aria-label="Icon URL"
|
|
271
|
-
className={INPUT_CLASS}
|
|
272
|
-
value={iconUrlInput}
|
|
273
|
-
onChange={(e) => setIconUrlInput(e.target.value)}
|
|
274
|
-
/>
|
|
275
|
-
<Button
|
|
276
|
-
type="button"
|
|
277
|
-
variant="secondary"
|
|
278
|
-
className="!w-auto"
|
|
279
|
-
disabled={assetBusy !== null || iconUrlInput === (branding.iconUrl ?? "")}
|
|
280
|
-
loading={assetBusy === "icon-url"}
|
|
281
|
-
onClick={() => void runAsset("icon-url", () => updateBranding({ iconUrl: iconUrlInput }))}
|
|
282
|
-
>
|
|
283
|
-
Set
|
|
284
|
-
</Button>
|
|
285
|
-
</div>
|
|
286
|
-
</label>
|
|
287
|
-
</section>
|
|
288
|
-
|
|
289
|
-
<section className="flex flex-col gap-3">
|
|
290
|
-
<h2 className="text-sm font-bold uppercase tracking-wide text-text-muted">Custom stylesheet</h2>
|
|
291
|
-
<div className="flex items-center gap-3">
|
|
292
|
-
<span className="text-sm text-text-muted truncate">
|
|
293
|
-
{branding.stylesheetUrl || "None configured"}
|
|
294
|
-
</span>
|
|
295
|
-
</div>
|
|
296
|
-
<div className="flex gap-2">
|
|
297
|
-
<Button
|
|
298
|
-
type="button"
|
|
299
|
-
variant="secondary"
|
|
300
|
-
className="!w-auto"
|
|
301
|
-
loading={assetBusy === "stylesheet-upload"}
|
|
302
|
-
disabled={assetBusy !== null}
|
|
303
|
-
onClick={() => stylesheetFileRef.current?.click()}
|
|
304
|
-
>
|
|
305
|
-
Upload CSS file
|
|
306
|
-
</Button>
|
|
307
|
-
<input
|
|
308
|
-
ref={stylesheetFileRef}
|
|
309
|
-
type="file"
|
|
310
|
-
accept="text/css,.css"
|
|
311
|
-
aria-label="Upload stylesheet"
|
|
312
|
-
className="hidden"
|
|
313
|
-
onChange={handleStylesheetFileChange}
|
|
314
|
-
/>
|
|
315
|
-
{branding.stylesheetUrl && (
|
|
316
|
-
<Button
|
|
317
|
-
type="button"
|
|
318
|
-
variant="text"
|
|
319
|
-
disabled={assetBusy !== null}
|
|
320
|
-
loading={assetBusy === "stylesheet-delete"}
|
|
321
|
-
onClick={() => void runAsset("stylesheet-delete", async () => {
|
|
322
|
-
await deleteBrandingStylesheet();
|
|
323
|
-
return { ...branding, stylesheetUrl: undefined };
|
|
324
|
-
})}
|
|
325
|
-
>
|
|
326
|
-
Remove stylesheet
|
|
327
|
-
</Button>
|
|
328
|
-
)}
|
|
329
|
-
</div>
|
|
330
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
331
|
-
<span className="font-semibold">Or use an external stylesheet URL</span>
|
|
332
|
-
<div className="flex gap-2">
|
|
333
|
-
<input
|
|
334
|
-
aria-label="Stylesheet URL"
|
|
335
|
-
className={INPUT_CLASS}
|
|
336
|
-
value={stylesheetUrlInput}
|
|
337
|
-
onChange={(e) => setStylesheetUrlInput(e.target.value)}
|
|
338
|
-
/>
|
|
339
|
-
<Button
|
|
340
|
-
type="button"
|
|
341
|
-
variant="secondary"
|
|
342
|
-
className="!w-auto"
|
|
343
|
-
disabled={assetBusy !== null || stylesheetUrlInput === (branding.stylesheetUrl ?? "")}
|
|
344
|
-
loading={assetBusy === "stylesheet-url"}
|
|
345
|
-
onClick={() =>
|
|
346
|
-
void runAsset("stylesheet-url", () => updateBranding({ stylesheetUrl: stylesheetUrlInput }))
|
|
347
|
-
}
|
|
348
|
-
>
|
|
349
|
-
Set
|
|
350
|
-
</Button>
|
|
351
|
-
</div>
|
|
352
|
-
</label>
|
|
353
|
-
</section>
|
|
354
|
-
|
|
355
|
-
<form onSubmit={handleSubmit} className="flex flex-col gap-4 pt-2 border-t border-border">
|
|
356
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
357
|
-
<span className="font-semibold">Company name</span>
|
|
358
|
-
<input
|
|
359
|
-
aria-label="Company name"
|
|
360
|
-
className={INPUT_CLASS}
|
|
361
|
-
value={companyName}
|
|
362
|
-
onChange={(e) => setCompanyName(e.target.value)}
|
|
363
|
-
/>
|
|
364
|
-
</label>
|
|
365
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
366
|
-
<span className="font-semibold">Product title</span>
|
|
367
|
-
<input
|
|
368
|
-
aria-label="Product title"
|
|
369
|
-
className={INPUT_CLASS}
|
|
370
|
-
value={title}
|
|
371
|
-
onChange={(e) => setTitle(e.target.value)}
|
|
372
|
-
/>
|
|
373
|
-
<span className="text-xs text-text-muted">Shown as the browser tab title.</span>
|
|
374
|
-
</label>
|
|
375
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
376
|
-
<span className="font-semibold">Header HTML (optional)</span>
|
|
377
|
-
<textarea
|
|
378
|
-
aria-label="Header HTML"
|
|
379
|
-
className={`${INPUT_CLASS} font-mono`}
|
|
380
|
-
rows={3}
|
|
381
|
-
value={headerHtml}
|
|
382
|
-
onChange={(e) => setHeaderHtml(e.target.value)}
|
|
383
|
-
/>
|
|
384
|
-
</label>
|
|
385
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
386
|
-
<span className="font-semibold">Footer HTML (optional)</span>
|
|
387
|
-
<textarea
|
|
388
|
-
aria-label="Footer HTML"
|
|
389
|
-
className={`${INPUT_CLASS} font-mono`}
|
|
390
|
-
rows={3}
|
|
391
|
-
value={footerHtml}
|
|
392
|
-
onChange={(e) => setFooterHtml(e.target.value)}
|
|
393
|
-
/>
|
|
394
|
-
</label>
|
|
395
|
-
<div>
|
|
396
|
-
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
397
|
-
Save
|
|
398
|
-
</Button>
|
|
399
|
-
</div>
|
|
400
|
-
</form>
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
);
|
|
404
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { useEffect, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import { Branding, getBranding } from "@rapidmx/react-shared/branding/brandingApi.js";
|
|
8
|
+
import AdminShell, { AdminShellProps } from "../../shared/components/admin/layout/AdminShell.js";
|
|
9
|
+
import BrandingForm from "../../shared/components/admin/settings/BrandingForm.js";
|
|
10
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
11
|
+
|
|
12
|
+
export default function BrandingPage(props: Omit<AdminShellProps, "active">) {
|
|
13
|
+
return (
|
|
14
|
+
<AdminShell {...props} active="branding">
|
|
15
|
+
<BrandingContent />
|
|
16
|
+
</AdminShell>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function BrandingContent() {
|
|
21
|
+
const [branding, setBranding] = useState<Branding | null>(null);
|
|
22
|
+
const [loading, setLoading] = useState(true);
|
|
23
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
getBranding()
|
|
27
|
+
.then(setBranding)
|
|
28
|
+
.catch((err) => setLoadError(err instanceof ApiRequestError ? err.message : "Could not load branding."))
|
|
29
|
+
.finally(() => setLoading(false));
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
if (loading) {
|
|
33
|
+
return <p className="text-sm text-text-muted">Loading…</p>;
|
|
34
|
+
}
|
|
35
|
+
if (loadError || !branding) {
|
|
36
|
+
return <Alert>{loadError}</Alert>;
|
|
37
|
+
}
|
|
38
|
+
return <BrandingForm branding={branding} onChange={setBranding} />;
|
|
39
|
+
}
|