@remit/web-client 0.0.336 → 0.0.338
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/dist/src/auth/AccountMenu.js +5 -3
- package/dist/src/auth/provider.d.ts +0 -1
- package/dist/src/components/settings/ReportLink.d.ts +3 -0
- package/dist/src/components/settings/ReportLink.js +4 -0
- package/dist/src/components/settings/classification/ClassificationPanel.d.ts +1 -0
- package/dist/src/components/settings/classification/ClassificationPanel.js +49 -0
- package/dist/src/components/settings/classification/FailureBanner.d.ts +8 -0
- package/dist/src/components/settings/classification/FailureBanner.js +8 -0
- package/dist/src/components/settings/classification/ProviderCard.d.ts +7 -0
- package/dist/src/components/settings/classification/ProviderCard.js +174 -0
- package/dist/src/components/settings/people/PeoplePanel.js +1 -3
- package/dist/src/hooks/useClassificationSettings.d.ts +173 -0
- package/dist/src/hooks/useClassificationSettings.js +47 -0
- package/dist/src/lib/classification.d.ts +40 -0
- package/dist/src/lib/classification.js +106 -0
- package/dist/src/routeTree.gen.d.ts +29 -16
- package/dist/src/routeTree.gen.js +14 -7
- package/dist/src/routes/settings/{security.d.ts → $slotId.d.ts} +1 -1
- package/dist/src/routes/settings/$slotId.js +20 -0
- package/dist/src/routes/settings/-shared/help-copy.d.ts +0 -1
- package/dist/src/routes/settings/-shared/help-copy.js +0 -1
- package/dist/src/routes/settings/accounts.js +4 -7
- package/dist/src/routes/settings/advanced.js +4 -7
- package/dist/src/routes/settings/appearance.js +4 -7
- package/dist/src/routes/settings/calendars.js +4 -6
- package/dist/src/routes/settings/classification.d.ts +1 -0
- package/dist/src/routes/settings/classification.js +18 -0
- package/dist/src/routes/settings/filters.js +4 -7
- package/dist/src/routes/settings/folders.js +4 -7
- package/dist/src/routes/settings/labels.js +4 -7
- package/dist/src/routes/settings/people.js +4 -6
- package/dist/src/routes/settings/senders.js +4 -7
- package/dist/src/routes/settings/warnings.js +4 -7
- package/dist/src/routes/settings.d.ts +0 -1
- package/dist/src/routes/settings.js +10 -30
- package/dist/src/routing/sections.d.ts +6 -1
- package/dist/src/routing/sections.js +10 -1
- package/dist/src/settings-slots.d.ts +14 -0
- package/dist/src/settings-slots.js +4 -0
- package/dist/src/shell/index.d.ts +5 -1
- package/dist/src/shell/index.js +8 -2
- package/package.json +2 -2
- package/dist/src/routes/settings/security.js +0 -21
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SettingsShell } from "@remit/ui";
|
|
3
|
+
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { ClassificationPanel } from "../../components/settings/classification/ClassificationPanel";
|
|
6
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
7
|
+
import { useSettingsNavItems } from "../settings";
|
|
8
|
+
export const Route = createFileRoute("/settings/classification")({
|
|
9
|
+
component: ClassificationSettings,
|
|
10
|
+
});
|
|
11
|
+
const classificationHelp = (_jsxs("div", { className: "space-y-3", children: [_jsx("p", { children: "A model labels new mail: spam and phishing, priority, personal, and a category. With classification off, or when a call fails, the built-in rules label it." }), _jsx("p", { children: "The API key is stored encrypted on the server and never sent back to the browser. Test connection sends one built-in sample message, with the form as it stands, and changes nothing." })] }));
|
|
12
|
+
function ClassificationSettings() {
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const navItems = useSettingsNavItems();
|
|
15
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
16
|
+
const [helpOpen, setHelpOpen] = useState(true);
|
|
17
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "classification", title: "Mail classification", description: "Label new mail with a model. Mail already in your folders keeps its labels.", help: classificationHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((open) => !open), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsx(ClassificationPanel, {}) }));
|
|
18
|
+
}
|
|
@@ -15,7 +15,8 @@ import { filterRunReportHref, filterToggleReportHref, } from "../../lib/filter-r
|
|
|
15
15
|
import { buildMailboxRoleMap, labelForMailbox } from "../../lib/folder-roles";
|
|
16
16
|
import { buildMoveOptions, folderDelimiter } from "../../lib/move-options";
|
|
17
17
|
import { filterRunStatus } from "../../lib/organize/filter-run";
|
|
18
|
-
import {
|
|
18
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
19
|
+
import { useSettingsNavItems } from "../settings";
|
|
19
20
|
export const Route = createFileRoute("/settings/filters")({
|
|
20
21
|
component: FiltersSettings,
|
|
21
22
|
});
|
|
@@ -74,14 +75,10 @@ export function AccountFilters({ account, }) {
|
|
|
74
75
|
function FiltersSettings() {
|
|
75
76
|
const navigate = useNavigate();
|
|
76
77
|
const navItems = useSettingsNavItems();
|
|
78
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
77
79
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
78
80
|
const { data: config, isPending, isError, error, refetch, } = useQuery(configOperationsGetConfigOptions());
|
|
79
|
-
|
|
80
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
81
|
-
if (path)
|
|
82
|
-
void navigate({ to: path });
|
|
83
|
-
};
|
|
84
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "filters", title: "Filters", description: "Standing and temporary rules created by Organize, per account.", help: filtersHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: handleSelectNav, onBackToMail: () => void navigate({ to: "/mail" }), children: isPending ? (
|
|
81
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "filters", title: "Filters", description: "Standing and temporary rules created by Organize, per account.", help: filtersHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: isPending ? (
|
|
85
82
|
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-label on loading skeleton provides useful context for assistive tech
|
|
86
83
|
_jsx("div", { className: "h-24 animate-pulse rounded-sm border border-line bg-surface", "aria-busy": "true", "aria-label": "Loading accounts" })) : isError ? (_jsx(ErrorState, { title: "Couldn't load accounts", error: error, onRetry: () => {
|
|
87
84
|
refetch();
|
|
@@ -12,7 +12,8 @@ import { guardFolderDeletion } from "../../lib/delete-folder";
|
|
|
12
12
|
import { softErrorStatuses } from "../../lib/error-classifier";
|
|
13
13
|
import { folderFailure } from "../../lib/folder-failure";
|
|
14
14
|
import { buildMailboxRoleMap, CANONICAL_TO_NAV_ROLE, labelForMailbox, NAV_ROLE_TO_CANONICAL, } from "../../lib/folder-roles";
|
|
15
|
-
import {
|
|
15
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
16
|
+
import { useSettingsNavItems } from "../settings";
|
|
16
17
|
export const Route = createFileRoute("/settings/folders")({
|
|
17
18
|
component: FoldersSettings,
|
|
18
19
|
});
|
|
@@ -128,14 +129,10 @@ function AccountFolders({ account }) {
|
|
|
128
129
|
function FoldersSettings() {
|
|
129
130
|
const navigate = useNavigate();
|
|
130
131
|
const navItems = useSettingsNavItems();
|
|
132
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
131
133
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
132
134
|
const { data: config, isPending, isError, error, refetch, } = useQuery(configOperationsGetConfigOptions());
|
|
133
|
-
|
|
134
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
135
|
-
if (path)
|
|
136
|
-
void navigate({ to: path });
|
|
137
|
-
};
|
|
138
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "folders", title: "Folder roles", description: "Appoint which real folder fills each canonical role, per account.", help: _jsx(FolderRolesHelp, {}), helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: handleSelectNav, onBackToMail: () => void navigate({ to: "/mail" }), children: isPending ? (
|
|
135
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "folders", title: "Folder roles", description: "Appoint which real folder fills each canonical role, per account.", help: _jsx(FolderRolesHelp, {}), helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: isPending ? (
|
|
139
136
|
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-label on loading skeleton provides useful context for assistive tech
|
|
140
137
|
_jsx("div", { className: "h-24 animate-pulse rounded-sm border border-line bg-surface", "aria-busy": "true", "aria-label": "Loading accounts" })) : isError ? (_jsx(ErrorState, { title: "Couldn't load accounts", error: error, onRetry: () => {
|
|
141
138
|
refetch();
|
|
@@ -7,7 +7,8 @@ import { useState } from "react";
|
|
|
7
7
|
import { LabelsList } from "../../components/settings/LabelsList";
|
|
8
8
|
import { useCreateLabel, useDeleteLabel, useLabelList, useUpdateLabel, } from "../../hooks/useLabels";
|
|
9
9
|
import { deleteLabelConfirmCopy } from "../../lib/organize/label-delete-copy";
|
|
10
|
-
import {
|
|
10
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
11
|
+
import { useSettingsNavItems } from "../settings";
|
|
11
12
|
export const Route = createFileRoute("/settings/labels")({
|
|
12
13
|
component: LabelsSettings,
|
|
13
14
|
});
|
|
@@ -57,14 +58,10 @@ function AccountLabels({ account }) {
|
|
|
57
58
|
function LabelsSettings() {
|
|
58
59
|
const navigate = useNavigate();
|
|
59
60
|
const navItems = useSettingsNavItems();
|
|
61
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
60
62
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
61
63
|
const { data: config, isPending, isError, error, refetch, } = useQuery(configOperationsGetConfigOptions());
|
|
62
|
-
|
|
63
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
64
|
-
if (path)
|
|
65
|
-
void navigate({ to: path });
|
|
66
|
-
};
|
|
67
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "labels", title: "Labels", description: "Mark mail without moving it, per account.", help: labelsHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: handleSelectNav, onBackToMail: () => void navigate({ to: "/mail" }), children: isPending ? (
|
|
64
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "labels", title: "Labels", description: "Mark mail without moving it, per account.", help: labelsHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: isPending ? (
|
|
68
65
|
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-label on loading skeleton provides useful context for assistive tech
|
|
69
66
|
_jsx("div", { className: "h-24 animate-pulse rounded-sm border border-line bg-surface", "aria-busy": "true", "aria-label": "Loading accounts" })) : isError ? (_jsx(ErrorState, { title: "Couldn't load accounts", error: error, onRetry: () => {
|
|
70
67
|
refetch();
|
|
@@ -3,7 +3,8 @@ import { SettingsShell } from "@remit/ui";
|
|
|
3
3
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { PeoplePanel } from "../../components/settings/people/PeoplePanel";
|
|
6
|
-
import {
|
|
6
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
7
|
+
import { useSettingsNavItems } from "../settings";
|
|
7
8
|
export const Route = createFileRoute("/settings/people")({
|
|
8
9
|
component: PeopleSettings,
|
|
9
10
|
});
|
|
@@ -11,10 +12,7 @@ const peopleHelp = (_jsxs("div", { className: "space-y-3", children: [_jsx("p",
|
|
|
11
12
|
function PeopleSettings() {
|
|
12
13
|
const navigate = useNavigate();
|
|
13
14
|
const navItems = useSettingsNavItems();
|
|
15
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
14
16
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
15
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "people", title: "People", description: "Everyone with an account on this server.", help: peopleHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((open) => !open), onSelect: (
|
|
16
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
17
|
-
if (path)
|
|
18
|
-
void navigate({ to: path });
|
|
19
|
-
}, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsx(PeoplePanel, {}) }));
|
|
17
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "people", title: "People", description: "Everyone with an account on this server.", help: peopleHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((open) => !open), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsx(PeoplePanel, {}) }));
|
|
20
18
|
}
|
|
@@ -17,7 +17,8 @@ import { Search, Star, X } from "lucide-react";
|
|
|
17
17
|
import { useCallback, useEffect, useState } from "react";
|
|
18
18
|
import { useDebouncedValue } from "../../hooks/useDebouncedValue";
|
|
19
19
|
import { formatDate } from "../../lib/format";
|
|
20
|
-
import {
|
|
20
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
21
|
+
import { useSettingsNavItems } from "../settings";
|
|
21
22
|
import { sendersHelp } from "./-shared/help-copy";
|
|
22
23
|
export const Route = createFileRoute("/settings/senders")({
|
|
23
24
|
component: SendersSettings,
|
|
@@ -168,6 +169,7 @@ export function SearchGroupPane({ group, query, onCount, }) {
|
|
|
168
169
|
function SendersSettings() {
|
|
169
170
|
const navigate = useNavigate();
|
|
170
171
|
const navItems = useSettingsNavItems();
|
|
172
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
171
173
|
const [group, setGroup] = useState("vip");
|
|
172
174
|
const [query, setQuery] = useState("");
|
|
173
175
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
@@ -185,12 +187,7 @@ function SendersSettings() {
|
|
|
185
187
|
setGroupCounts((prev) => ({ ...prev, [group]: m }));
|
|
186
188
|
}, [group]);
|
|
187
189
|
const total = groupCounts[group];
|
|
188
|
-
|
|
189
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
190
|
-
if (path)
|
|
191
|
-
void navigate({ to: path });
|
|
192
|
-
};
|
|
193
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "senders", title: "Senders & Rules", description: "Per-sender preferences \u2014 set with one key from any message, managed here.", flush: true, help: sendersHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: handleSelectNav, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsxs("div", { className: "flex min-h-0 flex-1 flex-col lg:flex-row", children: [_jsx(SenderGroupSwitch, { active: group, onSelect: (g) => {
|
|
190
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "senders", title: "Senders & Rules", description: "Per-sender preferences \u2014 set with one key from any message, managed here.", flush: true, help: sendersHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsxs("div", { className: "flex min-h-0 flex-1 flex-col lg:flex-row", children: [_jsx(SenderGroupSwitch, { active: group, onSelect: (g) => {
|
|
194
191
|
setGroup(g);
|
|
195
192
|
setQuery("");
|
|
196
193
|
}, options: ["vip", "muted", "blocked"].map((g) => ({
|
|
@@ -3,7 +3,8 @@ import { SettingsShell } from "@remit/ui";
|
|
|
3
3
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { WarningsPanel } from "../../components/settings/WarningsPanel";
|
|
6
|
-
import {
|
|
6
|
+
import { useOpenSettingsSection } from "../../routing/sections";
|
|
7
|
+
import { useSettingsNavItems } from "../settings";
|
|
7
8
|
import { warningsHelp } from "./-shared/help-copy";
|
|
8
9
|
export const Route = createFileRoute("/settings/warnings")({
|
|
9
10
|
component: WarningsSettings,
|
|
@@ -11,11 +12,7 @@ export const Route = createFileRoute("/settings/warnings")({
|
|
|
11
12
|
function WarningsSettings() {
|
|
12
13
|
const navigate = useNavigate();
|
|
13
14
|
const navItems = useSettingsNavItems();
|
|
15
|
+
const openSettingsSection = useOpenSettingsSection();
|
|
14
16
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
15
|
-
|
|
16
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
17
|
-
if (path)
|
|
18
|
-
void navigate({ to: path });
|
|
19
|
-
};
|
|
20
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "warnings", title: "Warnings", description: "Messages that failed to sync, and messages set aside.", help: warningsHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: handleSelectNav, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsx(WarningsPanel, {}) }));
|
|
17
|
+
return (_jsx(SettingsShell, { items: navItems, activeId: "warnings", title: "Warnings", description: "Messages that failed to sync, and messages set aside.", help: warningsHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: openSettingsSection, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsx(WarningsPanel, {}) }));
|
|
21
18
|
}
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { SettingsNavItem } from "@remit/ui";
|
|
12
12
|
export declare const SETTINGS_NAV_ITEMS: SettingsNavItem[];
|
|
13
|
-
export declare const SETTINGS_ID_TO_PATH: Record<string, string>;
|
|
14
13
|
/**
|
|
15
14
|
* The nav every settings page renders. People shows only once the server lists
|
|
16
15
|
* people: it answers 404 while self sign-up is open or off self-host.
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createFileRoute, Outlet } from "@tanstack/react-router";
|
|
3
|
-
import { CalendarDays, Filter, FolderTree, Inbox, Palette,
|
|
4
|
-
import { createContext, useContext } from "react";
|
|
5
|
-
import { useAuthProvider } from "../auth/provider";
|
|
3
|
+
import { CalendarDays, Filter, FolderTree, Inbox, Palette, Sparkles, Tag, UserCog, Users, } from "lucide-react";
|
|
6
4
|
import { AdvancedNavIcon } from "../components/settings/AdvancedNavIcon";
|
|
7
5
|
import { WarningsNavIcon } from "../components/settings/WarningsNavIcon";
|
|
8
6
|
import { usePeople } from "../hooks/usePeople";
|
|
7
|
+
import { useSettingsSlots } from "../settings-slots";
|
|
9
8
|
/* ------------------------------------------------------------------ */
|
|
10
9
|
/* Nav items — single source of truth shared by all settings pages */
|
|
11
10
|
/* ------------------------------------------------------------------ */
|
|
@@ -31,6 +30,11 @@ export const SETTINGS_NAV_ITEMS = [
|
|
|
31
30
|
label: "Labels",
|
|
32
31
|
icon: _jsx(Tag, { className: "size-4" }),
|
|
33
32
|
},
|
|
33
|
+
{
|
|
34
|
+
id: "classification",
|
|
35
|
+
label: "Mail classification",
|
|
36
|
+
icon: _jsx(Sparkles, { className: "size-4" }),
|
|
37
|
+
},
|
|
34
38
|
{
|
|
35
39
|
id: "calendars",
|
|
36
40
|
label: "Calendars",
|
|
@@ -48,25 +52,6 @@ export const SETTINGS_NAV_ITEMS = [
|
|
|
48
52
|
},
|
|
49
53
|
{ id: "advanced", label: "Advanced", icon: _jsx(AdvancedNavIcon, {}) },
|
|
50
54
|
];
|
|
51
|
-
export const SETTINGS_ID_TO_PATH = {
|
|
52
|
-
accounts: "/settings/accounts",
|
|
53
|
-
security: "/settings/security",
|
|
54
|
-
senders: "/settings/senders",
|
|
55
|
-
folders: "/settings/folders",
|
|
56
|
-
filters: "/settings/filters",
|
|
57
|
-
labels: "/settings/labels",
|
|
58
|
-
calendars: "/settings/calendars",
|
|
59
|
-
appearance: "/settings/appearance",
|
|
60
|
-
warnings: "/settings/warnings",
|
|
61
|
-
people: "/settings/people",
|
|
62
|
-
advanced: "/settings/advanced",
|
|
63
|
-
};
|
|
64
|
-
const SECURITY_NAV_ITEM = {
|
|
65
|
-
id: "security",
|
|
66
|
-
label: "Security",
|
|
67
|
-
icon: _jsx(ShieldCheck, { className: "size-4" }),
|
|
68
|
-
};
|
|
69
|
-
const SecurityUrlContext = createContext(undefined);
|
|
70
55
|
const PEOPLE_NAV_ITEM = {
|
|
71
56
|
id: "people",
|
|
72
57
|
label: "People",
|
|
@@ -78,10 +63,9 @@ const PEOPLE_NAV_ITEM = {
|
|
|
78
63
|
*/
|
|
79
64
|
export const useSettingsNavItems = () => {
|
|
80
65
|
const people = usePeople();
|
|
81
|
-
const
|
|
66
|
+
const slots = useSettingsSlots();
|
|
82
67
|
const items = [...SETTINGS_NAV_ITEMS];
|
|
83
|
-
|
|
84
|
-
items.splice(1, 0, SECURITY_NAV_ITEM);
|
|
68
|
+
items.splice(1, 0, ...slots.map(({ id, label, icon }) => ({ id, label, icon })));
|
|
85
69
|
if (!people.isSuccess)
|
|
86
70
|
return items;
|
|
87
71
|
const advanced = items.findIndex((item) => item.id === "advanced");
|
|
@@ -91,13 +75,9 @@ export const useSettingsNavItems = () => {
|
|
|
91
75
|
...items.slice(advanced),
|
|
92
76
|
];
|
|
93
77
|
};
|
|
94
|
-
const SettingsLayout = () => {
|
|
95
|
-
const { Account } = useAuthProvider();
|
|
96
|
-
return (_jsx(Account, { fallback: _jsx(SecurityUrlContext.Provider, { value: undefined, children: _jsx(Outlet, {}) }), children: ({ securityUrl }) => (_jsx(SecurityUrlContext.Provider, { value: securityUrl, children: _jsx(Outlet, {}) })) }));
|
|
97
|
-
};
|
|
98
78
|
/* ------------------------------------------------------------------ */
|
|
99
79
|
/* Route — pass-through */
|
|
100
80
|
/* ------------------------------------------------------------------ */
|
|
101
81
|
export const Route = createFileRoute("/settings")({
|
|
102
|
-
component:
|
|
82
|
+
component: () => _jsx(Outlet, {}),
|
|
103
83
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the moves that leave whatever the reader is on rather than open something
|
|
4
4
|
* under it, so they carry no panels and no query.
|
|
5
5
|
*/
|
|
6
|
-
export type AppSection = "brief" | "flagged" | "outbox" | "settings" | "accounts" | "
|
|
6
|
+
export type AppSection = "brief" | "flagged" | "outbox" | "settings" | "accounts" | "importConfig";
|
|
7
7
|
/** Go to a top-level section by name, so no caller writes a path. */
|
|
8
8
|
export declare function useGoToSection(): (section: AppSection) => void;
|
|
9
9
|
/**
|
|
@@ -14,3 +14,8 @@ export declare function useGoToSection(): (section: AppSection) => void;
|
|
|
14
14
|
* what it was about.
|
|
15
15
|
*/
|
|
16
16
|
export declare function useConfigureAccountSmtp(): (accountId: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Open a settings section by id. A built-in section matches its own literal
|
|
19
|
+
* route before `/settings/$slotId`, so one call reaches both kinds.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useOpenSettingsSection(): (slotId: string) => void;
|
|
@@ -6,7 +6,6 @@ const sectionRoute = {
|
|
|
6
6
|
outbox: "/mail/outbox",
|
|
7
7
|
settings: "/settings",
|
|
8
8
|
accounts: "/settings/accounts",
|
|
9
|
-
security: "/settings/security",
|
|
10
9
|
importConfig: "/import",
|
|
11
10
|
};
|
|
12
11
|
/** Go to a top-level section by name, so no caller writes a path. */
|
|
@@ -32,3 +31,13 @@ export function useConfigureAccountSmtp() {
|
|
|
32
31
|
});
|
|
33
32
|
}, [navigate]);
|
|
34
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Open a settings section by id. A built-in section matches its own literal
|
|
36
|
+
* route before `/settings/$slotId`, so one call reaches both kinds.
|
|
37
|
+
*/
|
|
38
|
+
export function useOpenSettingsSection() {
|
|
39
|
+
const navigate = useNavigate();
|
|
40
|
+
return useCallback((slotId) => {
|
|
41
|
+
navigate({ to: "/settings/$slotId", params: { slotId } });
|
|
42
|
+
}, [navigate]);
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A settings section the host registers. It routes at `/settings/<id>` and
|
|
4
|
+
* joins the settings nav beside the built-in sections.
|
|
5
|
+
*/
|
|
6
|
+
export interface SettingsSlot {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
icon: ReactNode;
|
|
10
|
+
Component: ComponentType;
|
|
11
|
+
help: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const SettingsSlotsProvider: import("react").Provider<SettingsSlot[]>;
|
|
14
|
+
export declare const useSettingsSlots: () => SettingsSlot[];
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type AuthProvider } from "../auth/provider";
|
|
2
|
+
import { type SettingsSlot } from "../settings-slots";
|
|
2
3
|
import "../lib/i18n";
|
|
3
4
|
import "../index.css";
|
|
4
5
|
import "../lib/client";
|
|
5
6
|
export interface MountOptions {
|
|
6
7
|
/** The identity system this build composes. */
|
|
7
8
|
authProvider: AuthProvider;
|
|
9
|
+
/** Settings sections the host adds, each at `/settings/<id>`. */
|
|
10
|
+
settingsSlots?: SettingsSlot[];
|
|
8
11
|
/** Element to mount into. Defaults to `#root`. */
|
|
9
12
|
rootElementId?: string;
|
|
10
13
|
}
|
|
@@ -14,4 +17,5 @@ export interface MountOptions {
|
|
|
14
17
|
* primitive a deployment shares, with the identity system supplied by the
|
|
15
18
|
* distributor rather than baked in.
|
|
16
19
|
*/
|
|
17
|
-
export declare const mountApp: ({ authProvider, rootElementId, }: MountOptions) => void;
|
|
20
|
+
export declare const mountApp: ({ authProvider, settingsSlots, rootElementId, }: MountOptions) => void;
|
|
21
|
+
export type { SettingsSlot } from "../settings-slots";
|
package/dist/src/shell/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { TelemetryContext } from "../lib/telemetry-context";
|
|
|
15
15
|
import { installThemeSync } from "../lib/theme";
|
|
16
16
|
import { createAppRouter } from "../router";
|
|
17
17
|
import { getRuntimeConfig } from "../runtime-config";
|
|
18
|
+
import { SettingsSlotsProvider } from "../settings-slots";
|
|
18
19
|
import "../lib/i18n";
|
|
19
20
|
import "../index.css";
|
|
20
21
|
import "../lib/client"; // Initialize client with error interceptor
|
|
@@ -24,7 +25,7 @@ import "../lib/client"; // Initialize client with error interceptor
|
|
|
24
25
|
* primitive a deployment shares, with the identity system supplied by the
|
|
25
26
|
* distributor rather than baked in.
|
|
26
27
|
*/
|
|
27
|
-
export const mountApp = ({ authProvider, rootElementId = "root", }) => {
|
|
28
|
+
export const mountApp = ({ authProvider, settingsSlots = [], rootElementId = "root", }) => {
|
|
28
29
|
installConsoleErrorCatcher();
|
|
29
30
|
installThemeSync();
|
|
30
31
|
authProvider.configure();
|
|
@@ -51,11 +52,16 @@ export const mountApp = ({ authProvider, rootElementId = "root", }) => {
|
|
|
51
52
|
});
|
|
52
53
|
installStaleBuildReload();
|
|
53
54
|
const router = createAppRouter(queryClient, telemetry);
|
|
55
|
+
for (const slot of settingsSlots) {
|
|
56
|
+
if (Object.hasOwn(router.routesByPath, `/settings/${slot.id}`)) {
|
|
57
|
+
throw new Error(`Settings slot "${slot.id}" collides with a built-in settings section`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
54
60
|
telemetry.recordPageView(window.location.pathname);
|
|
55
61
|
const rootElement = document.getElementById(rootElementId);
|
|
56
62
|
if (!rootElement) {
|
|
57
63
|
throw new Error(`Root element not found: #${rootElementId}`);
|
|
58
64
|
}
|
|
59
65
|
const { Shell } = authProvider;
|
|
60
|
-
createRoot(rootElement).render(_jsx(StrictMode, { children: _jsx(TelemetryContext.Provider, { value: telemetry, children: _jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(AuthProviderProvider, { value: authProvider, children: _jsx(Shell, { children: _jsx(RouterProvider, { router: router }) }) }), !import.meta.env.PROD && !getRuntimeConfig().disableDevtools && (_jsx(ReactQueryDevtools, { initialIsOpen: false }))] }) }) }));
|
|
66
|
+
createRoot(rootElement).render(_jsx(StrictMode, { children: _jsx(TelemetryContext.Provider, { value: telemetry, children: _jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(AuthProviderProvider, { value: authProvider, children: _jsx(SettingsSlotsProvider, { value: settingsSlots, children: _jsx(Shell, { children: _jsx(RouterProvider, { router: router }) }) }) }), !import.meta.env.PROD && !getRuntimeConfig().disableDevtools && (_jsx(ReactQueryDevtools, { initialIsOpen: false }))] }) }) }));
|
|
61
67
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.338",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
|
|
6
6
|
"exports": {
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@hookform/resolvers": "5.4.0",
|
|
94
|
-
"@remit/ui": "0.0.
|
|
94
|
+
"@remit/ui": "0.0.233",
|
|
95
95
|
"@tanstack/react-query": "5.101.2",
|
|
96
96
|
"@tanstack/react-query-devtools": "5.101.2",
|
|
97
97
|
"@tanstack/react-router": "1.170.18",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { SettingsShell } from "@remit/ui";
|
|
3
|
-
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { AccountSession } from "../../auth/AccountSession";
|
|
6
|
-
import { SETTINGS_ID_TO_PATH, useSettingsNavItems } from "../settings";
|
|
7
|
-
import { securityHelp } from "./-shared/help-copy";
|
|
8
|
-
export const Route = createFileRoute("/settings/security")({
|
|
9
|
-
component: SecuritySettings,
|
|
10
|
-
});
|
|
11
|
-
function SecuritySettings() {
|
|
12
|
-
const navigate = useNavigate();
|
|
13
|
-
const navItems = useSettingsNavItems();
|
|
14
|
-
const [helpOpen, setHelpOpen] = useState(true);
|
|
15
|
-
const handleSelectNav = (id) => {
|
|
16
|
-
const path = SETTINGS_ID_TO_PATH[id];
|
|
17
|
-
if (path)
|
|
18
|
-
void navigate({ to: path });
|
|
19
|
-
};
|
|
20
|
-
return (_jsx(SettingsShell, { items: navItems, activeId: "security", title: "Security", description: "Protect your account with a second step and passkeys.", help: securityHelp, helpOpen: helpOpen, onToggleHelp: () => setHelpOpen((v) => !v), onSelect: handleSelectNav, onBackToMail: () => void navigate({ to: "/mail" }), children: _jsx("div", { className: "space-y-3 text-sm text-fg-muted", children: _jsx(AccountSession, { children: ({ securityUrl }) => securityUrl ? (_jsx("a", { href: securityUrl, className: "font-medium text-accent hover:underline", children: "Manage two-factor authentication and passkeys" })) : null }) }) }));
|
|
21
|
-
}
|