mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
fix(mail-ingest): server gates after joining dev, and smaller admin buttons
- lint:tx: the mail transports and the intake document why their writes stand alone (@txIndependent, network I/O between them, one copy per address); the JSDoc of NotificationsService.respond is back above it after the response actions were registered in between. - lint:boundaries: booking-import asks McpToolGuardsService whether the person may edit the trip's bookings instead of reading the Users table; its unit test builds the service through one named factory. - lint:query-api: findIdByExternal reads through Kysely. - lint:test-mocks: the mail e2e hands its own snapshot db to the ORM instead of mocking the database module. - Entities regenerated (index order only). - Client: the review row reads the live booking, the shells share useMailInboxShell, and the admin card's buttons are one size down.
This commit is contained in:
@@ -29,6 +29,9 @@ import { useMailIngestAdmin, type MailIngestAdmin } from './useMailIngestAdmin';
|
||||
|
||||
type T = TranslationFn;
|
||||
|
||||
/** The card's buttons sit inside the form, one size below the page's: caption type, tighter padding. */
|
||||
const SMALL = 'px-3 py-1.5 text-caption';
|
||||
|
||||
/** The address a mail service posts to, shown so the admin can paste it into the sender's settings. */
|
||||
function InboundUrl({ t }: { t: T }) {
|
||||
const toast = useToast();
|
||||
@@ -39,7 +42,7 @@ function InboundUrl({ t }: { t: T }) {
|
||||
<span className={READONLY_BOX}>{url}</span>
|
||||
<button
|
||||
type="button"
|
||||
className={SETTINGS_BUTTON}
|
||||
className={`${SETTINGS_BUTTON} ${SMALL}`}
|
||||
aria-label={t('mailAdmin.copyUrl')}
|
||||
onClick={() => void copyText(url).then((ok) => (ok ? toast.success(t('common.copied')) : undefined))}
|
||||
>
|
||||
@@ -249,7 +252,7 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className={SETTINGS_BUTTON_PRIMARY}
|
||||
className={`${SETTINGS_BUTTON_PRIMARY} ${SMALL}`}
|
||||
disabled={!admin.dirty || admin.problems.length > 0 || admin.saving}
|
||||
onClick={admin.save}
|
||||
>
|
||||
@@ -258,7 +261,7 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={SETTINGS_BUTTON}
|
||||
className={`${SETTINGS_BUTTON} ${SMALL}`}
|
||||
disabled={admin.testing || admin.dirty || form.transport === 'off'}
|
||||
onClick={admin.runTest}
|
||||
>
|
||||
|
||||
@@ -14,9 +14,8 @@ import AssistantLauncher from '../Assistant/AssistantLauncher'
|
||||
import { resolvePluginIcon } from '../shared/PluginIcon'
|
||||
import { visibleManagedNavItems } from '../../managed'
|
||||
import { useCollapseOnOverflow } from '../../hooks/useCollapseOnOverflow'
|
||||
import { useMailIngestStore, watchMailInbox } from '../../store/mailIngestStore'
|
||||
import { openMailInbox } from '../MailIngest/mailInboxOpener'
|
||||
import { useMailInboxLink } from '../MailIngest/useMailInboxLink'
|
||||
import { useMailInboxShell } from '../MailIngest/useMailInboxShell'
|
||||
import MailInboxDialog from '../MailIngest/MailInboxDialog'
|
||||
|
||||
const ADDON_ICONS: Record<string, LucideIcon> = { CalendarDays, Briefcase, Globe, Compass, Bookmark }
|
||||
@@ -48,16 +47,7 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
const [userMenuOpen, setUserMenuOpen] = useState<boolean>(false)
|
||||
const [scrolled, setScrolled] = useState<boolean>(false)
|
||||
// The booking mail import's inbox: its menu entry shows only where the import is on for this person.
|
||||
const mailImport = useMailIngestStore(s => s.settings)
|
||||
const mailPending = useMailIngestStore(s => s.pending)
|
||||
const mailImportOn = !!mailImport?.available && mailImport.prefs.enabled
|
||||
useMailInboxLink(mailImportOn)
|
||||
const userId = user?.id
|
||||
useEffect(() => {
|
||||
if (!userId) return
|
||||
void useMailIngestStore.getState().loadSettings()
|
||||
return watchMailInbox()
|
||||
}, [userId])
|
||||
const { on: mailImportOn, pending: mailPending } = useMailInboxShell(user?.id)
|
||||
const darkMode = settings.dark_mode
|
||||
const dark = darkMode === true || darkMode === 'dark' || (darkMode === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useMailIngestStore, watchMailInbox } from '../../store/mailIngestStore';
|
||||
import { useMailInboxLink } from './useMailInboxLink';
|
||||
|
||||
/**
|
||||
* Everything a shell needs for the inbox of forwarded bookings: reads the
|
||||
* person's import settings once they are signed in, follows the server's
|
||||
* inbox events, opens the inbox from a ?inbox=mail link, and answers whether
|
||||
* the import is on (the menu entry and the dialog show only then) and how many
|
||||
* entries wait (the badge). The desktop Navbar and the phone's MMailInboxHost
|
||||
* mount it, one per shell.
|
||||
*/
|
||||
export function useMailInboxShell(userId: number | undefined): { on: boolean; pending: number } {
|
||||
const settings = useMailIngestStore((s) => s.settings);
|
||||
const pending = useMailIngestStore((s) => s.pending);
|
||||
const on = !!settings?.available && settings.prefs.enabled;
|
||||
useMailInboxLink(on);
|
||||
useEffect(() => {
|
||||
if (!userId) return;
|
||||
void useMailIngestStore.getState().loadSettings();
|
||||
return watchMailInbox();
|
||||
}, [userId]);
|
||||
return { on, pending };
|
||||
}
|
||||
Reference in New Issue
Block a user