@burdenoff/microfe-notification 2026.1129.1 → 2026.1129.3
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/NotificationRoutes.js +73 -72
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/generated/global-operations.d.ts +4 -0
- package/dist/generated/global-operations.js +4 -0
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +3 -0
- package/dist/hooks/useSendNotification.d.ts +1 -1
- package/dist/hooks/useSendNotification.js.map +1 -1
- package/dist/translations/en.d.ts +179 -0
- package/dist/v2/InboxPage.js +113 -97
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/NotificationDetailPanel.d.ts +9 -4
- package/dist/v2/NotificationDetailPanel.js +66 -51
- package/dist/v2/NotificationDetailPanel.js.map +1 -1
- package/dist/v2/admin/ChoiceSelect.d.ts +9 -0
- package/dist/v2/admin/ChoiceSelect.js +24 -0
- package/dist/v2/admin/ChoiceSelect.js.map +1 -0
- package/dist/v2/admin/DeliveryLogPage.d.ts +1 -0
- package/dist/v2/admin/DeliveryLogPage.js +207 -0
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -0
- package/dist/v2/admin/InsertDetail.d.ts +6 -0
- package/dist/v2/admin/InsertDetail.js +77 -0
- package/dist/v2/admin/InsertDetail.js.map +1 -0
- package/dist/v2/admin/TemplateEditor.d.ts +6 -0
- package/dist/v2/admin/TemplateEditor.js +92 -0
- package/dist/v2/admin/TemplateEditor.js.map +1 -0
- package/dist/v2/admin/TemplateFields.d.ts +9 -0
- package/dist/v2/admin/TemplateFields.js +130 -0
- package/dist/v2/admin/TemplateFields.js.map +1 -0
- package/dist/v2/admin/TemplatePage.d.ts +1 -0
- package/dist/v2/admin/TemplatePage.js +62 -0
- package/dist/v2/admin/TemplatePage.js.map +1 -0
- package/dist/v2/admin/TemplatePreview.d.ts +8 -0
- package/dist/v2/admin/TemplatePreview.js +112 -0
- package/dist/v2/admin/TemplatePreview.js.map +1 -0
- package/dist/v2/admin/TemplatesPage.d.ts +1 -0
- package/dist/v2/admin/TemplatesPage.js +173 -0
- package/dist/v2/admin/TemplatesPage.js.map +1 -0
- package/dist/v2/admin/TopicDialog.d.ts +11 -0
- package/dist/v2/admin/TopicDialog.js +113 -0
- package/dist/v2/admin/TopicDialog.js.map +1 -0
- package/dist/v2/admin/TopicsPage.d.ts +1 -0
- package/dist/v2/admin/TopicsPage.js +152 -0
- package/dist/v2/admin/TopicsPage.js.map +1 -0
- package/dist/v2/admin/templateText.d.ts +35 -0
- package/dist/v2/admin/templateText.js +114 -0
- package/dist/v2/admin/templateText.js.map +1 -0
- package/dist/v2/admin/useTemplateDraft.d.ts +32 -0
- package/dist/v2/admin/useTemplateDraft.js +117 -0
- package/dist/v2/admin/useTemplateDraft.js.map +1 -0
- package/dist/v2/admin/words.d.ts +15 -0
- package/dist/v2/admin/words.js +67 -0
- package/dist/v2/admin/words.js.map +1 -0
- package/dist/v2/send/MessageTab.d.ts +4 -0
- package/dist/v2/send/MessageTab.js +152 -0
- package/dist/v2/send/MessageTab.js.map +1 -0
- package/dist/v2/send/PeopleTab.d.ts +4 -0
- package/dist/v2/send/PeopleTab.js +156 -0
- package/dist/v2/send/PeopleTab.js.map +1 -0
- package/dist/v2/send/SendNotificationDialog.d.ts +4 -0
- package/dist/v2/send/SendNotificationDialog.js +98 -0
- package/dist/v2/send/SendNotificationDialog.js.map +1 -0
- package/dist/v2/send/SendRedirect.d.ts +1 -0
- package/dist/v2/send/SendRedirect.js +20 -0
- package/dist/v2/send/SendRedirect.js.map +1 -0
- package/dist/v2/send/WhenTab.d.ts +4 -0
- package/dist/v2/send/WhenTab.js +64 -0
- package/dist/v2/send/WhenTab.js.map +1 -0
- package/dist/v2/send/sendModel.d.ts +47 -0
- package/dist/v2/send/sendModel.js +90 -0
- package/dist/v2/send/sendModel.js.map +1 -0
- package/dist/v2/send/useSendDraft.d.ts +24 -0
- package/dist/v2/send/useSendDraft.js +120 -0
- package/dist/v2/send/useSendDraft.js.map +1 -0
- package/package.json +1 -1
package/dist/v2/InboxPage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InboxPage.js","names":["Inbox","TAB_FILTERS","UNREAD_FILTER","oldTabTarget","tab","paths","InboxPage","useNotificationPaths","params","useSearchParams","target","Navigate","Inbox$1","tr","useTr","navigate","useNavigate","notify","useNotify","useAdminTools","setParams","readInboxTab","openId","inbox","useNotifications","markUnread","useMarkUnread","shown","useMemo","needsAction","search","open","next","id","markAll","unreadIds","isUnread","n","everyOne","tabLabel","PageHeader","Button","CheckCheck","tools","tool","PageTabs","INBOX_TABS","Search","Input","event","LoadError","InboxEmpty","InboxRows","notification","NotificationDetailPanel","searching","EmptyState","title","description"],"sources":["../../src/v2/InboxPage.tsx"],"sourcesContent":["/**\n * Notifications (BOFF-16785, C1; the mockup's `notif`), under fe-libs' `accountPagesV2`: the inbox\n * at the list width, tabs All · Unread · Needs action · Archived (`?tab=`), compact rows grouped by\n * day, \"Mark all as read\" with Undo, the settings under the gear and, for admins, Send, Templates,\n * Topics and the Delivery log in ⋯. A row opens its panel (`?open=<id>`, decision 10). The same\n * queries as the inbox today (`useNotifications`).\n */\nimport { useMemo } from 'react';\nimport { Navigate, useNavigate, useSearchParams } from 'react-router';\nimport { CheckCheck, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { Button, EmptyState, Input, LoadError, PageTabs, useNotify } from '@burdenoff/fe-libs/ui';\nimport { useNotifications } from '../hooks';\nimport type { NotificationFilter } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { useAdminTools } from '../navigation-v2/useAdminTools';\nimport { INBOX_TABS, isUnread, needsAction, readInboxTab, type InboxTab } from './model/inbox';\nimport { InboxRows } from './InboxRows';\nimport { NotificationDetailPanel } from './NotificationDetailPanel';\nimport { useMarkUnread } from './useNotificationDetail';\n\n/** What each tab asks the service for: the in-app inbox, archived or not, unread or not. */\nconst TAB_FILTERS: Record<InboxTab, Partial<NotificationFilter>> = {\n all: { archived: false, channel: 'IN_APP' },\n unread: { archived: false, channel: 'IN_APP', isRead: false },\n action: { archived: false, channel: 'IN_APP' },\n archived: { archived: true, channel: 'IN_APP' },\n};\nconst UNREAD_FILTER = { channel: 'IN_APP' };\n\n/** Where today's `?tab=` values still go (the round-1 landing's links). */\nfunction oldTabTarget(\n tab: string | null,\n paths: ReturnType<typeof useNotificationPaths>\n): string | null {\n if (tab === 'send') return paths.send;\n if (tab === 'templates') return paths.templates;\n if (tab === 'topics') return paths.topics;\n if (tab === 'history') return paths.deliveryLog;\n return null;\n}\n\nexport function InboxPage() {\n const paths = useNotificationPaths();\n const [params] = useSearchParams();\n const target = oldTabTarget(params.get('tab'), paths);\n if (target) return <Navigate to={target} replace />;\n return <Inbox />;\n}\n\nfunction Inbox() {\n const tr = useTr();\n const navigate = useNavigate();\n const notify = useNotify();\n const paths = useNotificationPaths();\n const { tools } = useAdminTools();\n const [params, setParams] = useSearchParams();\n const tab = readInboxTab(params.get('tab'));\n const openId = params.get('open');\n const inbox = useNotifications({ baseFilter: TAB_FILTERS[tab], unreadFilter: UNREAD_FILTER });\n const markUnread = useMarkUnread();\n const shown = useMemo(\n () => (tab === 'action' ? inbox.notifications.filter(needsAction) : inbox.notifications),\n [inbox.notifications, tab]\n );\n const search = inbox.notificationFilter.search ?? '';\n\n const open = (id: string | null) => {\n const next = new URLSearchParams(params);\n if (id) next.set('open', id);\n else next.delete('open');\n setParams(next);\n };\n\n const markAll = async () => {\n // Undo can only bring back what's loaded: offer it when every unread one is on the page.\n const unreadIds = inbox.allNotifications.filter(isUnread).map((n) => n.id);\n const everyOne = unreadIds.length >= inbox.unreadCount;\n await inbox.markAllAsRead();\n notify({\n title: tr('notifications.v3.markedAll', 'Marked {{count}} as read', {\n count: inbox.unreadCount || unreadIds.length,\n }),\n tone: 'success',\n undo:\n everyOne && unreadIds.length > 0\n ? async () => {\n await markUnread(unreadIds);\n await inbox.refetch();\n }\n : undefined,\n });\n };\n\n const tabLabel: Record<InboxTab, string> = {\n all: tr('notifications.v3.tab.all', 'All'),\n unread: tr('notifications.v3.tab.unread', 'Unread'),\n action: tr('notifications.v3.tab.action', 'Needs action'),\n archived: tr('notifications.v3.tab.archived', 'Archived'),\n };\n\n return (\n <div data-account-pages-v2=\"notifications\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr(\n 'notifications.v3.purpose',\n 'Everything that needs you, and everything you were told.'\n )}\n primary={\n <Button\n variant=\"outline\"\n disabled={inbox.unreadCount === 0}\n onClick={() => void markAll()}\n data-testid=\"inbox-mark-all\"\n >\n <CheckCheck aria-hidden=\"true\" />\n {tr('notifications.v3.markAll', 'Mark all as read')}\n </Button>\n }\n settings={{\n label: tr('notifications.v3.settings', 'Notification settings'),\n onClick: () => navigate(paths.preferences),\n }}\n more={tools.map((tool) => ({\n id: tool.id,\n label: tool.label,\n onSelect: () => navigate(tool.href),\n }))}\n />\n <PageTabs\n ariaLabel={tr('notifications.v3.title', 'Notifications')}\n activeId={tab}\n tabs={INBOX_TABS.map((id) => ({\n id,\n label: tabLabel[id],\n href: `?tab=${id}`,\n badge: id === 'unread' && inbox.unreadCount > 0 ? inbox.unreadCount : undefined,\n }))}\n />\n <div className=\"mt-4 flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">{tr('notifications.v3.search', 'Search notifications')}</span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.search', 'Search notifications')}\n onChange={(event) => inbox.updateFilter({ search: event.target.value })}\n data-testid=\"inbox-search\"\n />\n </label>\n {inbox.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.title', 'Notifications')}\n error={inbox.error}\n onRetry={() => void inbox.refetch()}\n />\n ) : !inbox.isLoading && shown.length === 0 ? (\n <InboxEmpty tab={tab} searching={Boolean(search.trim())} />\n ) : (\n <InboxRows\n notifications={shown}\n loading={inbox.isLoading && shown.length === 0}\n onOpen={(id) => {\n open(id);\n const notification = shown.find((n) => n.id === id);\n if (notification && isUnread(notification)) void inbox.markAsRead(id);\n }}\n onMarkRead={(id) => void inbox.markAsRead(id)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => void inbox.archiveNotification(id)}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n )}\n {inbox.hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"ghost\"\n busy={inbox.isLoadingMore}\n onClick={() => void inbox.loadMore()}\n data-testid=\"inbox-more\"\n >\n {tr('notifications.v3.more', 'Show more')}\n </Button>\n </div>\n ) : null}\n </div>\n <NotificationDetailPanel\n id={openId}\n onClose={() => open(null)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => {\n void inbox.archiveNotification(id);\n open(null);\n }}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n </div>\n );\n}\n\nfunction InboxEmpty({ tab, searching }: { tab: InboxTab; searching: boolean }) {\n const tr = useTr();\n if (searching) {\n return (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.empty.searchTitle', 'No notifications match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n );\n }\n const words: Record<InboxTab, [string, string]> = {\n all: [\n tr('notifications.v3.empty.allTitle', 'You’re all caught up'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n unread: [\n tr('notifications.v3.empty.unreadTitle', 'Nothing unread'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n action: [\n tr('notifications.v3.empty.actionTitle', 'Nothing waiting for you'),\n tr('notifications.v3.empty.actionBody', 'Approvals and requests show up here.'),\n ],\n archived: [\n tr('notifications.v3.empty.archivedTitle', 'Nothing archived'),\n tr(\n 'notifications.v3.empty.archivedBody',\n 'Archive a notification to keep it out of the way. It stays here.'\n ),\n ],\n };\n const [title, description] = words[tab];\n return (\n <EmptyState\n kind={tab === 'archived' ? 'first-use' : 'all-done'}\n title={title}\n description={description}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,IAAMC,IAA6D;CACjE,KAAK;EAAE,UAAU;EAAO,SAAS;CAAS;CAC1C,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAU,QAAQ;CAAM;CAC5D,QAAQ;EAAE,UAAU;EAAO,SAAS;CAAS;CAC7C,UAAU;EAAE,UAAU;EAAM,SAAS;CAAS;AAChD,GACMC,IAAgB,EAAE,SAAS,SAAS;AAG1C,SAASC,EACP,GACA,GACe;CAKf,OAJIC,MAAQ,SAAeC,EAAM,OAC7BD,MAAQ,cAAoBC,EAAM,YAClCD,MAAQ,WAAiBC,EAAM,SAC/BD,MAAQ,YAAkBC,EAAM,cAC7B;AACT;AAEA,SAAgBC,IAAY;CAC1B,IAAMD,IAAQE,EAAqB,GAC7B,CAACC,KAAUC,EAAgB,GAC3BC,IAASP,EAAaK,EAAO,IAAI,KAAK,GAAGH,CAAK;CAEpD,OADIK,IAAe,kBAACC,GAAD;EAAU,IAAID;EAAQ,SAAA;CAAS,CAAA,IAC3C,kBAACV,GAAD,CAAQ,CAAA;AACjB;AAEA,SAASA,IAAQ;CACf,IAAMa,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAASC,EAAU,GACnBb,IAAQE,EAAqB,GAC7B,EAAE,aAAUY,EAAc,GAC1B,CAACX,GAAQY,KAAaX,EAAgB,GACtCL,IAAMiB,EAAab,EAAO,IAAI,KAAK,CAAC,GACpCc,IAASd,EAAO,IAAI,MAAM,GAC1Be,IAAQC,EAAiB;EAAE,YAAYvB,EAAYG;EAAM,cAAcF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A,QAAQ,CACNA,EAAG,sCAAsC,gBAAgB,GACzDA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,yBAAyB,GAClEA,EAAG,qCAAqC,sCAAsC,CAChF;EACA,UAAU,CACRA,EAAG,wCAAwC,kBAAkB,GAC7DA,EACE,uCACA,kEACF,CACF;CAE2B,EAAMT;CACnC,OACE,kBAACoD,GAAD;EACE,MAAMpD,MAAQ,aAAa,cAAc;EAClC;EACM;CACd,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"InboxPage.js","names":["Inbox","TAB_FILTERS","UNREAD_FILTER","oldTabTarget","tab","paths","InboxPage","useNotificationPaths","params","useSearchParams","target","Navigate","Inbox$1","tr","useTr","navigate","useNavigate","notify","useNotify","useAdminTools","permissionsLoading","usePermissions","setParams","sendOpen","holdsAdminToolPermission","hasPermission","readInboxTab","openId","inbox","useNotifications","markUnread","useMarkUnread","shown","useMemo","needsAction","search","open","next","id","showSend","show","SEND_PARAM","markAll","unreadIds","isUnread","n","everyOne","tabLabel","PageHeader","Button","CheckCheck","tools","tool","PageTabs","INBOX_TABS","Search","Input","event","LoadError","InboxEmpty","InboxRows","notification","NotificationDetailPanel","SendNotificationDialog","searching","EmptyState","title","description"],"sources":["../../src/v2/InboxPage.tsx"],"sourcesContent":["/**\n * Notifications (BOFF-16785, C1; the mockup's `notif`), under fe-libs' `accountPagesV2`: the inbox\n * at the list width, tabs All · Unread · Needs action · Archived (`?tab=`), compact rows grouped by\n * day, \"Mark all as read\" with Undo, the settings under the gear and, for admins, Send a\n * notification (a dialog, `?send=1`), Templates, Topics and the Delivery log in ⋯. A row opens its panel (`?open=<id>`, decision 10). The same\n * queries as the inbox today (`useNotifications`).\n */\nimport { useMemo } from 'react';\nimport { Navigate, useNavigate, useSearchParams } from 'react-router';\nimport { CheckCheck, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { Button, EmptyState, Input, LoadError, PageTabs, useNotify } from '@burdenoff/fe-libs/ui';\nimport { useNotifications } from '../hooks';\nimport type { NotificationFilter } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { holdsAdminToolPermission, useAdminTools } from '../navigation-v2/useAdminTools';\nimport { INBOX_TABS, isUnread, needsAction, readInboxTab, type InboxTab } from './model/inbox';\nimport { InboxRows } from './InboxRows';\nimport { NotificationDetailPanel } from './NotificationDetailPanel';\nimport { useMarkUnread } from './useNotificationDetail';\nimport { SendNotificationDialog } from './send/SendNotificationDialog';\nimport { SEND_PARAM } from './send/sendModel';\n\n/** What each tab asks the service for: the in-app inbox, archived or not, unread or not. */\nconst TAB_FILTERS: Record<InboxTab, Partial<NotificationFilter>> = {\n all: { archived: false, channel: 'IN_APP' },\n unread: { archived: false, channel: 'IN_APP', isRead: false },\n action: { archived: false, channel: 'IN_APP' },\n archived: { archived: true, channel: 'IN_APP' },\n};\nconst UNREAD_FILTER = { channel: 'IN_APP' };\n\n/** Where today's `?tab=` values still go (the round-1 landing's links). */\nfunction oldTabTarget(\n tab: string | null,\n paths: ReturnType<typeof useNotificationPaths>\n): string | null {\n if (tab === 'send') return paths.send;\n if (tab === 'templates') return paths.templates;\n if (tab === 'topics') return paths.topics;\n if (tab === 'history') return paths.deliveryLog;\n return null;\n}\n\nexport function InboxPage() {\n const paths = useNotificationPaths();\n const [params] = useSearchParams();\n const target = oldTabTarget(params.get('tab'), paths);\n if (target) return <Navigate to={target} replace />;\n return <Inbox />;\n}\n\nfunction Inbox() {\n const tr = useTr();\n const navigate = useNavigate();\n const notify = useNotify();\n const paths = useNotificationPaths();\n const { tools } = useAdminTools();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const [params, setParams] = useSearchParams();\n // Send a notification (C2b): a dialog over the inbox, for whoever may send.\n const sendOpen =\n params.get(SEND_PARAM) === '1' &&\n !permissionsLoading &&\n holdsAdminToolPermission('send', hasPermission);\n const tab = readInboxTab(params.get('tab'));\n const openId = params.get('open');\n const inbox = useNotifications({ baseFilter: TAB_FILTERS[tab], unreadFilter: UNREAD_FILTER });\n const markUnread = useMarkUnread();\n const shown = useMemo(\n () => (tab === 'action' ? inbox.notifications.filter(needsAction) : inbox.notifications),\n [inbox.notifications, tab]\n );\n const search = inbox.notificationFilter.search ?? '';\n\n const open = (id: string | null) => {\n const next = new URLSearchParams(params);\n if (id) next.set('open', id);\n else next.delete('open');\n setParams(next);\n };\n\n const showSend = (show: boolean) => {\n const next = new URLSearchParams(params);\n if (show) next.set(SEND_PARAM, '1');\n else next.delete(SEND_PARAM);\n setParams(next);\n };\n\n const markAll = async () => {\n // Undo can only bring back what's loaded: offer it when every unread one is on the page.\n const unreadIds = inbox.allNotifications.filter(isUnread).map((n) => n.id);\n const everyOne = unreadIds.length >= inbox.unreadCount;\n await inbox.markAllAsRead();\n notify({\n title: tr('notifications.v3.markedAll', 'Marked {{count}} as read', {\n count: inbox.unreadCount || unreadIds.length,\n }),\n tone: 'success',\n undo:\n everyOne && unreadIds.length > 0\n ? async () => {\n await markUnread(unreadIds);\n await inbox.refetch();\n }\n : undefined,\n });\n };\n\n const tabLabel: Record<InboxTab, string> = {\n all: tr('notifications.v3.tab.all', 'All'),\n unread: tr('notifications.v3.tab.unread', 'Unread'),\n action: tr('notifications.v3.tab.action', 'Needs action'),\n archived: tr('notifications.v3.tab.archived', 'Archived'),\n };\n\n return (\n <div data-account-pages-v2=\"notifications\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr(\n 'notifications.v3.purpose',\n 'Everything that needs you, and everything you were told.'\n )}\n primary={\n <Button\n variant=\"outline\"\n disabled={inbox.unreadCount === 0}\n onClick={() => void markAll()}\n data-testid=\"inbox-mark-all\"\n >\n <CheckCheck aria-hidden=\"true\" />\n {tr('notifications.v3.markAll', 'Mark all as read')}\n </Button>\n }\n settings={{\n label: tr('notifications.v3.settings', 'Notification settings'),\n onClick: () => navigate(paths.preferences),\n }}\n more={tools.map((tool) =>\n tool.id === 'send'\n ? {\n id: tool.id,\n label: tr('notifications.v3.send.title', 'Send a notification'),\n onSelect: () => showSend(true),\n }\n : { id: tool.id, label: tool.label, onSelect: () => navigate(tool.href) }\n )}\n />\n <PageTabs\n ariaLabel={tr('notifications.v3.title', 'Notifications')}\n activeId={tab}\n tabs={INBOX_TABS.map((id) => ({\n id,\n label: tabLabel[id],\n href: `?tab=${id}`,\n badge: id === 'unread' && inbox.unreadCount > 0 ? inbox.unreadCount : undefined,\n }))}\n />\n <div className=\"mt-4 flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">{tr('notifications.v3.search', 'Search notifications')}</span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.search', 'Search notifications')}\n onChange={(event) => inbox.updateFilter({ search: event.target.value })}\n data-testid=\"inbox-search\"\n />\n </label>\n {inbox.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.title', 'Notifications')}\n error={inbox.error}\n onRetry={() => void inbox.refetch()}\n />\n ) : !inbox.isLoading && shown.length === 0 ? (\n <InboxEmpty tab={tab} searching={Boolean(search.trim())} />\n ) : (\n <InboxRows\n notifications={shown}\n loading={inbox.isLoading && shown.length === 0}\n onOpen={(id) => {\n open(id);\n const notification = shown.find((n) => n.id === id);\n if (notification && isUnread(notification)) void inbox.markAsRead(id);\n }}\n onMarkRead={(id) => void inbox.markAsRead(id)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => void inbox.archiveNotification(id)}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n )}\n {inbox.hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"ghost\"\n busy={inbox.isLoadingMore}\n onClick={() => void inbox.loadMore()}\n data-testid=\"inbox-more\"\n >\n {tr('notifications.v3.more', 'Show more')}\n </Button>\n </div>\n ) : null}\n </div>\n <NotificationDetailPanel\n id={openId}\n onClose={() => open(null)}\n inboxActions={{\n markUnread: (id) => void markUnread([id]).then(() => inbox.refetch()),\n archive: (id) => {\n void inbox.archiveNotification(id);\n open(null);\n },\n restore: (id) => void inbox.unarchiveNotification(id),\n }}\n />\n <SendNotificationDialog open={sendOpen} onClose={() => showSend(false)} />\n </div>\n );\n}\n\nfunction InboxEmpty({ tab, searching }: { tab: InboxTab; searching: boolean }) {\n const tr = useTr();\n if (searching) {\n return (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.empty.searchTitle', 'No notifications match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n );\n }\n const words: Record<InboxTab, [string, string]> = {\n all: [\n tr('notifications.v3.empty.allTitle', 'You’re all caught up'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n unread: [\n tr('notifications.v3.empty.unreadTitle', 'Nothing unread'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n action: [\n tr('notifications.v3.empty.actionTitle', 'Nothing waiting for you'),\n tr('notifications.v3.empty.actionBody', 'Approvals and requests show up here.'),\n ],\n archived: [\n tr('notifications.v3.empty.archivedTitle', 'Nothing archived'),\n tr(\n 'notifications.v3.empty.archivedBody',\n 'Archive a notification to keep it out of the way. It stays here.'\n ),\n ],\n };\n const [title, description] = words[tab];\n return (\n <EmptyState\n kind={tab === 'archived' ? 'first-use' : 'all-done'}\n title={title}\n description={description}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAMC,IAA6D;CACjE,KAAK;EAAE,UAAU;EAAO,SAAS;CAAS;CAC1C,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAU,QAAQ;CAAM;CAC5D,QAAQ;EAAE,UAAU;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,mCAAmC,sBAAsB,GAC5DA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,gBAAgB,GACzDA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,yBAAyB,GAClEA,EAAG,qCAAqC,sCAAsC,CAChF;EACA,UAAU,CACRA,EAAG,wCAAwC,kBAAkB,GAC7DA,EACE,uCACA,kEACF,CACF;CAE2B,EAAMT;CACnC,OACE,kBAAC6D,GAAD;EACE,MAAM7D,MAAQ,aAAa,cAAc;EAClC;EACM;CACd,CAAA;AAEL"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/** What the person can do with their own notification: absent in the admins' delivery log. */
|
|
2
|
+
export interface InboxActions {
|
|
3
|
+
markUnread: (id: string) => void;
|
|
4
|
+
archive: (id: string) => void;
|
|
5
|
+
restore: (id: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function NotificationDetailPanel({ id, onClose, inboxActions, }: {
|
|
2
8
|
id: string | null;
|
|
3
9
|
onClose: () => void;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
onRestore: (id: string) => void;
|
|
10
|
+
/** The person's own inbox; the delivery log only reads, so it leaves these out. */
|
|
11
|
+
inboxActions?: InboxActions;
|
|
7
12
|
}): import('react').JSX.Element;
|
|
@@ -13,57 +13,72 @@ import { Button as g, DetailPanel as _, IconTile as v, LoadError as y, Skeleton
|
|
|
13
13
|
function C(e) {
|
|
14
14
|
t(e) || window.open(e, "_blank", "noopener,noreferrer");
|
|
15
15
|
}
|
|
16
|
-
function w({ id: t, onClose: r,
|
|
17
|
-
let
|
|
16
|
+
function w({ id: t, onClose: r, inboxActions: a }) {
|
|
17
|
+
let o = e(), { state: s, retry: l } = c(t), u = s.status === "ready" ? s.notification : null, d = u ? n(u) : null, f = d && a ? /* @__PURE__ */ m(T, {
|
|
18
|
+
notification: d,
|
|
19
|
+
actions: a
|
|
20
|
+
}) : void 0;
|
|
18
21
|
return /* @__PURE__ */ m(_, {
|
|
19
22
|
open: !!t,
|
|
20
23
|
onOpenChange: (e) => e ? void 0 : r(),
|
|
21
|
-
title:
|
|
22
|
-
sub:
|
|
23
|
-
tile:
|
|
24
|
+
title: d?.title ?? o("notifications.v3.panel.loading", "Notification"),
|
|
25
|
+
sub: d ? /* @__PURE__ */ m(D, { notification: d }) : void 0,
|
|
26
|
+
tile: d ? /* @__PURE__ */ m(v, {
|
|
24
27
|
size: "md",
|
|
25
|
-
children: /* @__PURE__ */ m(i, { notification:
|
|
28
|
+
children: /* @__PURE__ */ m(i, { notification: d })
|
|
26
29
|
}) : void 0,
|
|
27
|
-
closeLabel:
|
|
30
|
+
closeLabel: o("notifications.v3.panel.close", "Close"),
|
|
28
31
|
"data-testid": "notification-panel",
|
|
29
|
-
footer:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
children: l("notifications.v3.markUnread", "Mark as unread")
|
|
35
|
-
}), p.archivedAt ? /* @__PURE__ */ m(g, {
|
|
36
|
-
variant: "ghost",
|
|
37
|
-
onClick: () => s(p.id),
|
|
38
|
-
children: l("notifications.v3.restore", "Move back to the inbox")
|
|
39
|
-
}) : /* @__PURE__ */ m(g, {
|
|
40
|
-
variant: "ghost",
|
|
41
|
-
onClick: () => o(p.id),
|
|
42
|
-
children: l("notifications.v3.archive", "Archive")
|
|
43
|
-
})]
|
|
44
|
-
}) : void 0,
|
|
45
|
-
children: u.status === "loading" ? /* @__PURE__ */ h("div", {
|
|
46
|
-
className: "flex flex-col gap-3",
|
|
47
|
-
"aria-busy": "true",
|
|
48
|
-
children: [
|
|
49
|
-
/* @__PURE__ */ m(b, { className: "h-4 w-3/4" }),
|
|
50
|
-
/* @__PURE__ */ m(b, { className: "h-4 w-2/3" }),
|
|
51
|
-
/* @__PURE__ */ m(b, { className: "h-24 w-full" })
|
|
52
|
-
]
|
|
53
|
-
}) : u.status === "failed" ? /* @__PURE__ */ m(y, {
|
|
54
|
-
what: l("notifications.v3.panel.what", "This notification"),
|
|
55
|
-
error: u.error,
|
|
56
|
-
onRetry: d
|
|
57
|
-
}) : u.status === "missing" || !f || !p ? /* @__PURE__ */ m("p", {
|
|
58
|
-
className: "m-0 text-sm text-text-secondary",
|
|
59
|
-
children: l("notifications.v3.panel.missing", "This notification isn’t available any more. It may have been deleted.")
|
|
60
|
-
}) : /* @__PURE__ */ m(E, {
|
|
61
|
-
notification: p,
|
|
62
|
-
data: f
|
|
32
|
+
footer: f,
|
|
33
|
+
children: /* @__PURE__ */ m(E, {
|
|
34
|
+
state: s,
|
|
35
|
+
retry: l,
|
|
36
|
+
notification: d
|
|
63
37
|
})
|
|
64
38
|
});
|
|
65
39
|
}
|
|
66
|
-
function T({ notification: t }) {
|
|
40
|
+
function T({ notification: t, actions: n }) {
|
|
41
|
+
let r = e();
|
|
42
|
+
return /* @__PURE__ */ h("div", {
|
|
43
|
+
className: "flex w-full flex-wrap gap-2",
|
|
44
|
+
children: [/* @__PURE__ */ m(g, {
|
|
45
|
+
variant: "outline",
|
|
46
|
+
onClick: () => n.markUnread(t.id),
|
|
47
|
+
children: r("notifications.v3.markUnread", "Mark as unread")
|
|
48
|
+
}), t.archivedAt ? /* @__PURE__ */ m(g, {
|
|
49
|
+
variant: "ghost",
|
|
50
|
+
onClick: () => n.restore(t.id),
|
|
51
|
+
children: r("notifications.v3.restore", "Move back to the inbox")
|
|
52
|
+
}) : /* @__PURE__ */ m(g, {
|
|
53
|
+
variant: "ghost",
|
|
54
|
+
onClick: () => n.archive(t.id),
|
|
55
|
+
children: r("notifications.v3.archive", "Archive")
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function E({ state: t, retry: n, notification: r }) {
|
|
60
|
+
let i = e();
|
|
61
|
+
return t.status === "loading" ? /* @__PURE__ */ h("div", {
|
|
62
|
+
className: "flex flex-col gap-3",
|
|
63
|
+
"aria-busy": "true",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ m(b, { className: "h-4 w-3/4" }),
|
|
66
|
+
/* @__PURE__ */ m(b, { className: "h-4 w-2/3" }),
|
|
67
|
+
/* @__PURE__ */ m(b, { className: "h-24 w-full" })
|
|
68
|
+
]
|
|
69
|
+
}) : t.status === "failed" ? /* @__PURE__ */ m(y, {
|
|
70
|
+
what: i("notifications.v3.panel.what", "This notification"),
|
|
71
|
+
error: t.error,
|
|
72
|
+
onRetry: n
|
|
73
|
+
}) : t.status !== "ready" || !r ? /* @__PURE__ */ m("p", {
|
|
74
|
+
className: "m-0 text-sm text-text-secondary",
|
|
75
|
+
children: i("notifications.v3.panel.missing", "This notification isn’t available any more. It may have been deleted.")
|
|
76
|
+
}) : /* @__PURE__ */ m(O, {
|
|
77
|
+
notification: r,
|
|
78
|
+
data: t.notification
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function D({ notification: t }) {
|
|
67
82
|
let n = e(), i = S();
|
|
68
83
|
return /* @__PURE__ */ h("span", {
|
|
69
84
|
className: "flex flex-wrap items-center gap-2",
|
|
@@ -76,7 +91,7 @@ function T({ notification: t }) {
|
|
|
76
91
|
}) : null]
|
|
77
92
|
});
|
|
78
93
|
}
|
|
79
|
-
function
|
|
94
|
+
function O({ notification: t, data: n }) {
|
|
80
95
|
let r = e(), i = a(n.metadata), o = t.actions;
|
|
81
96
|
return /* @__PURE__ */ h("div", {
|
|
82
97
|
className: "flex flex-col gap-5",
|
|
@@ -86,7 +101,7 @@ function E({ notification: t, data: n }) {
|
|
|
86
101
|
"data-testid": "panel-message",
|
|
87
102
|
children: t.body
|
|
88
103
|
}),
|
|
89
|
-
i ? /* @__PURE__ */ m(
|
|
104
|
+
i ? /* @__PURE__ */ m(k, {
|
|
90
105
|
thing: i,
|
|
91
106
|
actionUrl: t.actionUrl
|
|
92
107
|
}) : null,
|
|
@@ -102,11 +117,11 @@ function E({ notification: t, data: n }) {
|
|
|
102
117
|
children: [/* @__PURE__ */ m(l, { "aria-hidden": "true" }), r("notifications.v3.panel.open", "Open where it happened")]
|
|
103
118
|
}) : null]
|
|
104
119
|
}) : null,
|
|
105
|
-
/* @__PURE__ */ m(
|
|
120
|
+
/* @__PURE__ */ m(M, { events: n.events })
|
|
106
121
|
]
|
|
107
122
|
});
|
|
108
123
|
}
|
|
109
|
-
function
|
|
124
|
+
function k({ thing: t, actionUrl: n }) {
|
|
110
125
|
let r = e(), i = S(), a = o(t, r);
|
|
111
126
|
return /* @__PURE__ */ h("section", {
|
|
112
127
|
className: "flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3",
|
|
@@ -149,18 +164,18 @@ function D({ thing: t, actionUrl: n }) {
|
|
|
149
164
|
]
|
|
150
165
|
});
|
|
151
166
|
}
|
|
152
|
-
var
|
|
167
|
+
var A = {
|
|
153
168
|
ok: u,
|
|
154
169
|
bad: p,
|
|
155
170
|
waiting: d,
|
|
156
171
|
neutral: d
|
|
157
|
-
},
|
|
172
|
+
}, j = {
|
|
158
173
|
ok: "text-status-success-text",
|
|
159
174
|
bad: "text-status-error-text",
|
|
160
175
|
waiting: "text-status-warning-text",
|
|
161
176
|
neutral: "text-text-muted"
|
|
162
177
|
};
|
|
163
|
-
function
|
|
178
|
+
function M({ events: t }) {
|
|
164
179
|
let n = e(), r = S(), i = s(t, n);
|
|
165
180
|
return i.length === 0 ? null : /* @__PURE__ */ h("section", {
|
|
166
181
|
className: "flex flex-col gap-2",
|
|
@@ -172,12 +187,12 @@ function A({ events: t }) {
|
|
|
172
187
|
className: "m-0 flex list-none flex-col gap-2 p-0",
|
|
173
188
|
"data-testid": "panel-timeline",
|
|
174
189
|
children: i.map((e) => {
|
|
175
|
-
let t =
|
|
190
|
+
let t = A[e.tone];
|
|
176
191
|
return /* @__PURE__ */ h("li", {
|
|
177
192
|
className: "flex items-center gap-2 text-sm",
|
|
178
193
|
children: [
|
|
179
194
|
/* @__PURE__ */ m(t, {
|
|
180
|
-
className: `size-4 ${
|
|
195
|
+
className: `size-4 ${j[e.tone]}`,
|
|
181
196
|
"aria-hidden": "true"
|
|
182
197
|
}),
|
|
183
198
|
/* @__PURE__ */ m("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","Button","onMarkUnread","onRestore","onArchive","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","actions","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport { useNotificationDetail, type NotificationDetailData } from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n id: string | null;\n onClose: () => void;\n onMarkUnread: (id: string) => void;\n onArchive: (id: string) => void;\n onRestore: (id: string) => void;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={\n notification ? (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => onMarkUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => onRestore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => onArchive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n ) : undefined\n }\n >\n {state.status === 'loading' ? (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n ) : state.status === 'failed' ? (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n ) : state.status === 'missing' || !ready || !notification ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n ) : (\n <PanelBody notification={notification} data={ready} />\n )}\n </DetailPanel>\n );\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.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ateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","footer","inboxActions","PanelFooter","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","PanelContent","Button","actions","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot, in\n * the person's own inbox only.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport {\n useNotificationDetail,\n type DetailState,\n type NotificationDetailData,\n} from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\n/** What the person can do with their own notification: absent in the admins' delivery log. */\nexport interface InboxActions {\n markUnread: (id: string) => void;\n archive: (id: string) => void;\n restore: (id: string) => void;\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n inboxActions,\n}: {\n id: string | null;\n onClose: () => void;\n /** The person's own inbox; the delivery log only reads, so it leaves these out. */\n inboxActions?: InboxActions;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n const footer =\n notification && inboxActions ? (\n <PanelFooter notification={notification} actions={inboxActions} />\n ) : undefined;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={footer}\n >\n <PanelContent state={state} retry={retry} notification={notification} />\n </DetailPanel>\n );\n}\n\n/** Mark as unread, and Archive or Move back to the inbox. */\nfunction PanelFooter({\n notification,\n actions,\n}: {\n notification: Notification;\n actions: InboxActions;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => actions.markUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => actions.restore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => actions.archive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n );\n}\n\n/** Loading, couldn't load, gone, or the notification itself. */\nfunction PanelContent({\n state,\n retry,\n notification,\n}: {\n state: DetailState;\n retry: () => void;\n notification: Notification | null;\n}) {\n const tr = useTr();\n if (state.status === 'loading') {\n return (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n );\n }\n if (state.status === 'failed') {\n return (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n );\n }\n if (state.status !== 'ready' || !notification) {\n return (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n );\n }\n return <PanelBody notification={notification} data={state.notification} />;\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAASA,EAAO,GAAa;CAC3B,AAAKC,EAAcC,CAAG,KAAG,OAAO,KAAKA,GAAK,UAAU,qBAAqB;AAC3E;AASA,SAAgBC,EAAwB,EACtC,OACA,YACA,mBAMC;CACD,IAAMC,IAAKC,EAAM,GACX,EAAE,UAAO,aAAUC,EAAsBC,CAAE,GAC3CC,IAAQC,EAAM,WAAW,UAAUA,EAAM,eAAe,MACxDC,IAAeF,IAAQG,EAA4BH,CAAK,IAAI,MAC5DI,IACJF,KAAgBG,IACd,kBAACC,GAAD;EAA2B;EAAc,SAASD;CAAe,CAAA,IAC/D,KAAA;CAEN,OACE,kBAACE,GAAD;EACE,MAAM,EAAQR;EACd,eAAe,MAAUS,IAAO,KAAA,IAAYC,EAAQ;EACpD,OAAOP,GAAc,SAASN,EAAG,kCAAkC,cAAc;EACjF,KAAKM,IAAe,kBAACQ,GAAD,EAAwB,gBAAe,CAAA,IAAI,KAAA;EAC/D,MACER,IACE,kBAACS,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAwB,gBAAe,CAAA;EAC/B,CAAA,IACR,KAAA;EAEN,YAAYhB,EAAG,gCAAgC,OAAO;EACtD,eAAY;EACJ;EAER,UAAA,kBAACiB,GAAD;GAAqB;GAAc;GAAqB;EAAe,CAAA;CAC5D,CAAA;AAEjB;AAGA,SAASP,EAAY,EACnB,iBACA,cAIC;CACD,IAA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BAA6B,eAAe;EAC9C,CAAA,GACJ,kBAAC,MAAD;GAAI,WAAU;GAAwC,eAAY;GAC/D,UAAA8C,EAAM,KAAK,MAAU;IACpB,IAAMG,IAAOR,EAAWS,EAAM;IAC9B,OACE,kBAAC,MAAD;KAAmB,WAAU;KAA7B,UAAA;MACE,kBAACD,GAAD;OAAM,WAAW,UAAUJ,EAAWK,EAAM;OAAS,eAAY;MAAQ,CAAA;MACzE,kBAAC,QAAD;OAAM,WAAU;OAA4B,UAAAA,EAAM;MAAY,CAAA;MAC9D,kBAAC,QAAD;OAAM,WAAU;OAA0B,UAAUA,EAAM;OACvD,UAAA1B,EAAK,OAAO0B,EAAM,EAAE;MACjB,CAAA;KACJ;IANK,GAAAA,EAAM,EAMX;GAER,CAAC;EACC,CAAA,CACG;;AAEb"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function ChoiceSelect<T extends string>({ id, value, options, word, onChange, disabled, className, }: {
|
|
2
|
+
id: string;
|
|
3
|
+
value: T;
|
|
4
|
+
options: readonly T[];
|
|
5
|
+
word: (option: T) => string;
|
|
6
|
+
onChange: (option: T) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
}): import('react').JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "@burdenoff/fe-libs/ui";
|
|
3
|
+
// src/v2/admin/ChoiceSelect.tsx
|
|
4
|
+
function s({ id: s, value: c, options: l, word: u, onChange: d, disabled: f, className: p }) {
|
|
5
|
+
return /* @__PURE__ */ t(n, {
|
|
6
|
+
value: c,
|
|
7
|
+
disabled: f,
|
|
8
|
+
onValueChange: (e) => {
|
|
9
|
+
let t = l.find((t) => t === e);
|
|
10
|
+
t && d(t);
|
|
11
|
+
},
|
|
12
|
+
children: [/* @__PURE__ */ e(a, {
|
|
13
|
+
id: s,
|
|
14
|
+
className: p,
|
|
15
|
+
children: /* @__PURE__ */ e(o, {})
|
|
16
|
+
}), /* @__PURE__ */ e(r, { children: l.map((t) => /* @__PURE__ */ e(i, {
|
|
17
|
+
value: t,
|
|
18
|
+
children: u(t)
|
|
19
|
+
}, t)) })]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export { s as ChoiceSelect };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=ChoiceSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChoiceSelect.js","names":["ChoiceSelect","Select","picked","options","option","next","onChange","SelectTrigger","SelectValue","SelectContent","SelectItem","word"],"sources":["../../../src/v2/admin/ChoiceSelect.tsx"],"sourcesContent":["/**\n * One choice from a short fixed list (BOFF-16785, C2): what a template or topic is about, and\n * which channel a template is sent by. Shows each option's word, never its stored value.\n */\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nexport function ChoiceSelect<T extends string>({\n id,\n value,\n options,\n word,\n onChange,\n disabled,\n className,\n}: {\n id: string;\n value: T;\n options: readonly T[];\n word: (option: T) => string;\n onChange: (option: T) => void;\n disabled?: boolean;\n className?: string;\n}) {\n return (\n <Select\n value={value}\n disabled={disabled}\n onValueChange={(next) => {\n const picked = options.find((option) => option === next);\n if (picked) onChange(picked);\n }}\n >\n <SelectTrigger id={id} className={className}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem key={option} value={option}>\n {word(option)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n"],"mappings":";;;AAYA,SAAgBA,EAA+B,EAC7C,OACA,UACA,YACA,SACA,aACA,aACA,gBASC;CACD,OACE,kBAACC,GAAD;EACS;EACG;EACV,gBAAgB,MAAS;GACvB,IAAMC,IAASC,EAAQ,MAAM,MAAWC,MAAWC,CAAI;GACvD,AAAIH,KAAQI,EAASJ,CAAM;EAC7B;EANF,UAAA,CAQE,kBAACK,GAAD;GAAmB;GAAe;GAChC,UAAA,kBAACC,GAAD,CAAc,CAAA;EACD,CAAA,GACf,kBAACC,GAAD,EAAA,UACGN,EAAQ,KAAK,MACZ,kBAACO,GAAD;GAAyB,OAAON;GAC7B,UAAAO,EAAKP,CAAM;EACF,GAFKA,CAEL,CACb,EACY,CAAA,CACT;;AAEZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DeliveryLogPage(): import('react').JSX.Element;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { useNotificationAdmin as e } from "../../hooks/useNotificationAdmin.js";
|
|
2
|
+
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
+
import { useNotificationPaths as n } from "../../navigation-v2/paths.js";
|
|
4
|
+
import { AdminPageV2 as r } from "../../navigation-v2/AdminPageV2.js";
|
|
5
|
+
import { NotificationCenterPage as i } from "../../pages/NotificationCenterPage.js";
|
|
6
|
+
import { NotificationDetailPanel as a } from "../NotificationDetailPanel.js";
|
|
7
|
+
import { groupByDay as o } from "../model/days.js";
|
|
8
|
+
import { channelWord as s, deliveryState as c } from "./words.js";
|
|
9
|
+
import { useMemo as l, useState as u } from "react";
|
|
10
|
+
import { useFeatureFlagDetails as d } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
11
|
+
import { CheckCircle2 as f, Clock as p, XCircle as m } from "lucide-react";
|
|
12
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
|
+
import { PageHeader as _ } from "@burdenoff/fe-libs/chrome";
|
|
14
|
+
import { EmptyState as v, LoadError as y, Segmented as b, Skeleton as x, StatusChip as S, useWhenLabels as C } from "@burdenoff/fe-libs/ui";
|
|
15
|
+
// src/v2/admin/DeliveryLogPage.tsx
|
|
16
|
+
var w = {
|
|
17
|
+
ok: f,
|
|
18
|
+
bad: m,
|
|
19
|
+
waiting: p
|
|
20
|
+
}, T = new Intl.NumberFormat(), E = {
|
|
21
|
+
ok: "text-status-success-text",
|
|
22
|
+
bad: "text-status-error-text",
|
|
23
|
+
waiting: "text-status-warning-text"
|
|
24
|
+
};
|
|
25
|
+
function D() {
|
|
26
|
+
let e = d("notification.history");
|
|
27
|
+
return e && e.value ? /* @__PURE__ */ h(r, {
|
|
28
|
+
tool: "deliveryLog",
|
|
29
|
+
back: !1,
|
|
30
|
+
children: /* @__PURE__ */ h(P, {})
|
|
31
|
+
}) : /* @__PURE__ */ h(i, {});
|
|
32
|
+
}
|
|
33
|
+
function O(e, t) {
|
|
34
|
+
return e.recipientEmail || e.recipientPhone || t("notifications.v3.log.inApp", "someone in the app");
|
|
35
|
+
}
|
|
36
|
+
function k({ counts: e, tone: n, onTone: r }) {
|
|
37
|
+
let i = t();
|
|
38
|
+
return /* @__PURE__ */ g("div", {
|
|
39
|
+
className: "flex flex-wrap items-center gap-2",
|
|
40
|
+
"data-testid": "log-counts",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ h(S, {
|
|
43
|
+
status: "ok",
|
|
44
|
+
children: i("notifications.v3.log.delivered", "{{count}} delivered", { count: T.format(e.ok) })
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ h(S, {
|
|
47
|
+
status: "bad",
|
|
48
|
+
children: i("notifications.v3.log.failed", "{{count}} didn’t arrive", { count: T.format(e.bad) })
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ h(S, {
|
|
51
|
+
status: "waiting",
|
|
52
|
+
children: i("notifications.v3.log.waiting", "{{count}} waiting", { count: T.format(e.waiting) })
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ h("span", { className: "flex-1" }),
|
|
55
|
+
/* @__PURE__ */ h(b, {
|
|
56
|
+
"aria-label": i("notifications.v3.log.show", "Show"),
|
|
57
|
+
value: n,
|
|
58
|
+
onValueChange: r,
|
|
59
|
+
options: [
|
|
60
|
+
{
|
|
61
|
+
value: "any",
|
|
62
|
+
label: i("notifications.v3.log.any", "All")
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
value: "ok",
|
|
66
|
+
label: i("notifications.v3.delivery.delivered", "Delivered")
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: "bad",
|
|
70
|
+
label: i("notifications.v3.delivery.failed", "Didn’t arrive")
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
value: "waiting",
|
|
74
|
+
label: i("notifications.v3.log.waitingShort", "Waiting")
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function A({ item: e, onOpen: n }) {
|
|
82
|
+
let r = t(), i = C(), { notification: a, state: o } = e, c = w[o.tone];
|
|
83
|
+
return /* @__PURE__ */ h("li", {
|
|
84
|
+
"data-row-id": a.id,
|
|
85
|
+
children: /* @__PURE__ */ g("button", {
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left",
|
|
88
|
+
onClick: () => n(a.id),
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ h(c, {
|
|
91
|
+
className: `size-4 shrink-0 ${E[o.tone]}`,
|
|
92
|
+
"aria-hidden": "true"
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ g("span", {
|
|
95
|
+
className: "min-w-0 flex-1",
|
|
96
|
+
children: [/* @__PURE__ */ h("span", {
|
|
97
|
+
className: "block truncate text-sm text-text-primary",
|
|
98
|
+
children: r("notifications.v3.log.line", "{{title}} → {{who}}", {
|
|
99
|
+
title: a.title,
|
|
100
|
+
who: O(a, r)
|
|
101
|
+
})
|
|
102
|
+
}), /* @__PURE__ */ g("span", {
|
|
103
|
+
className: "block truncate text-xs text-text-secondary",
|
|
104
|
+
children: [
|
|
105
|
+
s(a.channel, r),
|
|
106
|
+
" · ",
|
|
107
|
+
o.word
|
|
108
|
+
]
|
|
109
|
+
})]
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ h("time", {
|
|
112
|
+
className: "shrink-0 text-xs text-text-muted",
|
|
113
|
+
dateTime: a.createdAt,
|
|
114
|
+
children: i.moment(a.createdAt)
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function j({ items: e, onOpen: n }) {
|
|
121
|
+
let r = t();
|
|
122
|
+
return /* @__PURE__ */ h("div", {
|
|
123
|
+
className: "flex flex-col gap-4",
|
|
124
|
+
"data-testid": "log-rows",
|
|
125
|
+
children: o(e, r).map((e) => /* @__PURE__ */ g("section", {
|
|
126
|
+
"aria-label": e.label,
|
|
127
|
+
className: "flex flex-col gap-1",
|
|
128
|
+
children: [/* @__PURE__ */ h("h2", {
|
|
129
|
+
className: "m-0 px-1 text-xs font-medium text-text-muted",
|
|
130
|
+
children: e.label
|
|
131
|
+
}), /* @__PURE__ */ h("ul", {
|
|
132
|
+
className: "m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0",
|
|
133
|
+
children: e.items.map((e) => /* @__PURE__ */ h(A, {
|
|
134
|
+
item: e,
|
|
135
|
+
onOpen: n
|
|
136
|
+
}, e.notification.id))
|
|
137
|
+
})]
|
|
138
|
+
}, e.key))
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function M({ filtered: e }) {
|
|
142
|
+
let n = t();
|
|
143
|
+
return /* @__PURE__ */ h(v, {
|
|
144
|
+
kind: e ? "filtered" : "first-use",
|
|
145
|
+
title: e ? n("notifications.v3.log.noneTitle", "Nothing here") : n("notifications.v3.log.emptyTitle", "Nothing sent yet"),
|
|
146
|
+
description: n("notifications.v3.log.emptyBody", "Each notification sent is listed here with what happened to it.")
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function N() {
|
|
150
|
+
return /* @__PURE__ */ h("div", {
|
|
151
|
+
className: "flex flex-col gap-2",
|
|
152
|
+
"aria-busy": "true",
|
|
153
|
+
children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */ h(x, { className: "h-12 w-full rounded-lg" }, t))
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function P() {
|
|
157
|
+
let r = t(), i = n(), o = e(), [s, d] = u("any"), [f, p] = u(null), m = l(() => o.notifications.map((e) => ({
|
|
158
|
+
notification: e,
|
|
159
|
+
state: c(e.deliveryStatus, r),
|
|
160
|
+
createdAt: e.createdAt
|
|
161
|
+
})), [o.notifications, r]), v = l(() => {
|
|
162
|
+
let e = {
|
|
163
|
+
ok: 0,
|
|
164
|
+
bad: 0,
|
|
165
|
+
waiting: 0
|
|
166
|
+
};
|
|
167
|
+
for (let t of m) e[t.state.tone] += 1;
|
|
168
|
+
return e;
|
|
169
|
+
}, [m]), b = s === "any" ? m : m.filter((e) => e.state.tone === s), x = m.length === 0, S = /* @__PURE__ */ h(j, {
|
|
170
|
+
items: b,
|
|
171
|
+
onOpen: p
|
|
172
|
+
});
|
|
173
|
+
return o.error && x ? S = /* @__PURE__ */ h(y, {
|
|
174
|
+
what: r("notifications.v3.log.title", "Delivery log"),
|
|
175
|
+
error: o.error,
|
|
176
|
+
onRetry: () => void o.refetch()
|
|
177
|
+
}) : o.isLoading && x ? S = /* @__PURE__ */ h(N, {}) : b.length === 0 && (S = /* @__PURE__ */ h(M, { filtered: s !== "any" })), /* @__PURE__ */ g("div", {
|
|
178
|
+
"data-account-pages-v2": "notification-delivery-log",
|
|
179
|
+
className: "flex w-full min-w-0 flex-col",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ h(_, {
|
|
182
|
+
variant: "compact",
|
|
183
|
+
title: r("notifications.v3.log.title", "Delivery log"),
|
|
184
|
+
description: r("notifications.v3.log.purpose", "Every notification sent, and whether it arrived."),
|
|
185
|
+
back: {
|
|
186
|
+
label: r("notifications.v3.title", "Notifications"),
|
|
187
|
+
to: i.inbox
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ g("div", {
|
|
191
|
+
className: "flex flex-col gap-3",
|
|
192
|
+
children: [/* @__PURE__ */ h(k, {
|
|
193
|
+
counts: v,
|
|
194
|
+
tone: s,
|
|
195
|
+
onTone: d
|
|
196
|
+
}), S]
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ h(a, {
|
|
199
|
+
id: f,
|
|
200
|
+
onClose: () => p(null)
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
export { D as DeliveryLogPage };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=DeliveryLogPage.js.map
|