From c6e437cc9aa65935da6f4e7625507a2444dc590f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 12:11:59 +0000 Subject: [PATCH 1/5] test(fields): pin the notification template preview pane (red: no widget yet) Claude-Session: https://claude.ai/code/session_01L9qibyrf8y7cWLVu7DMgBN Co-authored-by: Claude --- ...icationTemplatePreviewField-39569.test.tsx | 258 ++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx diff --git a/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx b/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx new file mode 100644 index 00000000000..375e01406b5 --- /dev/null +++ b/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx @@ -0,0 +1,258 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack#39569 — the notification template preview pane (ruling + * 7405856818 on #39412, item 2 = B): a `sys_notification_template` record + * shows its SAVED subject and body as the server's preview door renders them, + * `POST /api/v1/messaging/notification-templates/:id/preview` + * (service-messaging `notification-template-preview-routes.ts`), against + * sample values the administrator types. + * + * The pins hold what the ruling and the card promise: + * + * - the placeholders found in the saved row are the sample-value inputs — + * one input per value the render context reads, `{{ topic }}` excepted (the + * door fills it from the row); + * - the door is the only renderer: what is shown is the door's answer, byte + * for byte, and a refusal is shown as its own text; + * - typing a sample value asks nothing; the preview is asked again when the + * administrator asks for it, and when the saved row changes; + * - the read face sits under the body on the record page, and a grid cell of + * the same field draws the body alone and asks nothing. + */ +import { describe, it, expect, vi, afterEach } from 'vitest'; +import React from 'react'; +import { render, screen, fireEvent, cleanup, waitFor, act } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { SchemaRendererProvider } from '@object-ui/react'; +import { + NotificationTemplatePreviewField, + notificationTemplatePreviewUrl, + samplePayload, + samplePlaceholders, +} from '../NotificationTemplatePreviewField'; +import { getCellRenderer, resolveCellRendererType } from '../../index'; + +type DoorCall = { url: string; init?: RequestInit }; + +/** A stub of the host's authenticated fetch that answers `answer` and records every call. */ +function door(answer: (call: DoorCall) => Response | Promise) { + const calls: DoorCall[] = []; + const fetch = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => { + const call = { url: String(input), init }; + calls.push(call); + return answer(call); + }); + return { fetch, calls }; +} + +const ok = (data: unknown) => () => new Response(JSON.stringify({ success: true, data }), { status: 200 }); +const refused = (status: number, code: string, message: string) => () => + new Response(JSON.stringify({ success: false, error: { code, message } }), { status }); + +/** The body the door was sent, parsed. */ +function sentBody(call: DoorCall): unknown { + return JSON.parse(String(call.init?.body ?? 'null')); +} + +const ROW = { + id: 'tpl_1', + topic: 'invoice.paid', + format: 'markdown', + subject: 'Invoice {{ payload.number }} paid', + body: 'Hi {{ customer.name }}, we received {{ amount }} for {{ payload.number }} ({{ topic }}).', + updated_at: '2026-12-04T10:00:00.000Z', +}; + +function mount(apiFetch: ReturnType['fetch'] | undefined, row: Record = ROW) { + const view = render( + + + , + ); + const rerender = (next: Record) => + view.rerender( + + + , + ); + return { ...view, rerender }; +} + +afterEach(() => cleanup()); + +describe('the placeholders of the saved row are the sample-value inputs', () => { + it('reads the holes the renderer substitutes, subject first, one input per value the payload carries', () => { + expect(samplePlaceholders(ROW.subject, ROW.body)).toEqual(['number', 'customer.name', 'amount']); + }); + + it('a title or body hole reads the payload too; topic and the bare payload are not inputs', () => { + expect(samplePlaceholders('{{title}} {{ payload.title }} {{ body }}', '{{ topic }} {{ payload }} {{ payload.topic }}')).toEqual([ + 'title', + 'body', + 'topic', + ]); + }); + + it('text the renderer leaves verbatim is not a placeholder', () => { + expect(samplePlaceholders('{{ not a hole }} {{}} { single } {{ a-b }}', undefined)).toEqual([]); + }); + + it('the sample payload nests a dotted path and leaves an empty input out', () => { + expect(samplePayload(['number', 'customer.name', 'amount'], { number: 'INV-7', 'customer.name': 'Ada', amount: '' })).toEqual({ + number: 'INV-7', + customer: { name: 'Ada' }, + }); + }); +}); + +describe('NotificationTemplatePreviewField — the door is the only renderer', () => { + it('asks the door for the saved row on mount and shows its subject and text body as answered', async () => { + const { fetch, calls } = door(ok({ subject: 'Invoice paid', text: 'Hi , we received for (invoice.paid).' })); + mount(fetch); + + expect(await screen.findByTestId('notification-template-preview-subject')).toHaveTextContent('Invoice paid'); + expect(screen.getByTestId('notification-template-preview-text').textContent).toBe('Hi , we received for (invoice.paid).'); + expect(calls).toHaveLength(1); + expect(calls[0].url).toBe(notificationTemplatePreviewUrl('tpl_1')); + expect(calls[0].url).toBe('/api/v1/messaging/notification-templates/tpl_1/preview'); + expect(calls[0].init?.method).toBe('POST'); + expect(sentBody(calls[0])).toEqual({ payload: {} }); + }); + + it('one input per placeholder, labelled by the value it fills', async () => { + const { fetch } = door(ok({ subject: 's', text: 't' })); + mount(fetch); + await screen.findByTestId('notification-template-preview-subject'); + expect(screen.getByLabelText('number')).toBeInTheDocument(); + expect(screen.getByLabelText('customer.name')).toBeInTheDocument(); + expect(screen.getByLabelText('amount')).toBeInTheDocument(); + expect(screen.queryByLabelText('topic')).toBeNull(); + }); + + it('typing a sample value asks nothing; asking for the preview sends the typed values', async () => { + const { fetch, calls } = door(ok({ subject: 'Invoice INV-7 paid', text: 'Hi Ada' })); + mount(fetch); + await screen.findByTestId('notification-template-preview-subject'); + expect(calls).toHaveLength(1); + + fireEvent.change(screen.getByLabelText('number'), { target: { value: 'INV-7' } }); + fireEvent.change(screen.getByLabelText('customer.name'), { target: { value: 'Ada' } }); + expect(calls).toHaveLength(1); + + fireEvent.click(screen.getByTestId('notification-template-preview-render')); + await waitFor(() => expect(calls).toHaveLength(2)); + expect(sentBody(calls[1])).toEqual({ payload: { number: 'INV-7', customer: { name: 'Ada' } } }); + }); + + it('an html row shows the door’s html through the package sanitizer, never as script', async () => { + const { fetch } = door(ok({ subject: 'S', html: '

Hi <b>Ada</b>

' })); + mount(fetch, { ...ROW, format: 'html' }); + const face = await screen.findByTestId('notification-template-preview-html'); + await waitFor(() => expect(face).toHaveTextContent('Hi Ada')); + expect(face.querySelector('script')).toBeNull(); + expect(face.querySelector('b')).toBeNull(); + }); + + it.each([ + [403, 'PERMISSION_DENIED', 'You may not read this notification template.'], + [404, 'RECORD_NOT_FOUND', "There is no notification template 'tpl_1' that you can read."], + [400, 'VALIDATION_ERROR', '`payload` must be a JSON object of the sample values the template reads.'], + ])('a %s refusal is shown as its own text, with its code', async (status, code, message) => { + const { fetch } = door(refused(status, code, message)); + mount(fetch); + const alert = await screen.findByRole('alert'); + expect(alert).toHaveTextContent(message); + expect(alert).toHaveTextContent(code); + expect(screen.queryByTestId('notification-template-preview-subject')).toBeNull(); + }); + + it('a failed request is shown as text too', async () => { + const { fetch } = door(() => { + throw new TypeError('Failed to fetch'); + }); + mount(fetch); + expect(await screen.findByRole('alert')).toHaveTextContent('Failed to fetch'); + }); + + it('the saved row changing asks again; the same saved row re-rendered does not', async () => { + const { fetch, calls } = door(ok({ subject: 's', text: 't' })); + const view = mount(fetch); + await screen.findByTestId('notification-template-preview-subject'); + expect(calls).toHaveLength(1); + + view.rerender({ ...ROW }); + await act(async () => {}); + expect(calls).toHaveLength(1); + + view.rerender({ ...ROW, subject: 'Paid: {{ payload.number }}', updated_at: '2026-12-04T10:05:00.000Z' }); + await waitFor(() => expect(calls).toHaveLength(2)); + }); + + it('an unsaved draft on the record page asks nothing until it is saved', async () => { + const { fetch, calls } = door(ok({ subject: 's', text: 't' })); + const view = mount(fetch); + await screen.findByTestId('notification-template-preview-subject'); + + // The record page merges an unsaved inline draft into the record it hands + // its fields; the save stamps a new `updated_at`. + view.rerender({ ...ROW, subject: 'Draft {{ x }}' }); + view.rerender({ ...ROW, subject: 'Draft {{ xy }}' }); + await act(async () => {}); + expect(calls).toHaveLength(1); + }); + + it('a row with no id (not saved yet) asks nothing and says to save it', async () => { + const { fetch, calls } = door(ok({ subject: 's', text: 't' })); + mount(fetch, { ...ROW, id: undefined }); + expect(await screen.findByTestId('notification-template-preview-unsaved')).toBeInTheDocument(); + expect(calls).toHaveLength(0); + }); + + it('a host with no fetch asks nothing and says so', async () => { + mount(undefined); + expect(await screen.findByTestId('notification-template-preview-unavailable')).toBeInTheDocument(); + }); +}); + +describe('the `notification-template-preview` widget hint is the body’s read face', () => { + const FIELD = { name: 'body', type: 'markdown', label: 'Body', widget: 'notification-template-preview' } as any; + + it('a markdown field declaring the hint resolves to its read face', () => { + expect(resolveCellRendererType(FIELD)).toBe('notification-template-preview'); + // Any other markdown field keeps the markdown face. + expect(resolveCellRendererType({ type: 'markdown' })).toBe('markdown'); + expect(resolveCellRendererType({ type: 'markdown', widget: 'object-ref' })).toBe('markdown'); + }); + + it('on the record page the face draws the body and the preview under it', async () => { + const { fetch, calls } = door(ok({ subject: 'Invoice paid', text: 'Hi' })); + const Cell = getCellRenderer(resolveCellRendererType(FIELD)); + render( + + + , + ); + expect(await screen.findByTestId('notification-template-preview-subject')).toHaveTextContent('Invoice paid'); + expect(calls).toHaveLength(1); + }); + + it('a grid cell of the same field draws the body alone and asks nothing', async () => { + const { fetch, calls } = door(ok({ subject: 'Invoice paid', text: 'Hi' })); + const Cell = getCellRenderer(resolveCellRendererType(FIELD)); + render( + + + , + ); + await act(async () => {}); + expect(screen.queryByTestId('notification-template-preview')).toBeNull(); + expect(calls).toHaveLength(0); + }); +}); From efb16d8398af81344c9ebb6330b9ae570a249a7f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 12:21:57 +0000 Subject: [PATCH 2/5] feat(fields): notification template body read face previews the saved row through the server door Claude-Session: https://claude.ai/code/session_01L9qibyrf8y7cWLVu7DMgBN Co-authored-by: Claude --- ui/packages/fields/src/index.tsx | 31 ++ .../NotificationTemplatePreviewField.tsx | 338 ++++++++++++++++++ 2 files changed, 369 insertions(+) create mode 100644 ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx diff --git a/ui/packages/fields/src/index.tsx b/ui/packages/fields/src/index.tsx index 68ec4e13b45..f1ac0ad618f 100644 --- a/ui/packages/fields/src/index.tsx +++ b/ui/packages/fields/src/index.tsx @@ -3611,6 +3611,15 @@ const WIDGET_CELL_RENDERER_TYPES: ReadonlySet = new Set([ 'permission-ref', ]); +/** + * Widget hints whose read face draws a `markdown` field: the body it stores, + * and something drawn from it under the body. Promoted over `markdown` alone, + * so the face can always draw the body the way the markdown cell does. + * `notification-template-preview` is a notification template's body with the + * server's preview of the saved row under it (objectstack#39569). + */ +const MARKDOWN_WIDGET_CELL_RENDERER_TYPES: ReadonlySet = new Set(['notification-template-preview']); + /** * Resolve the canonical cell-renderer key for a field. Accepts either a * raw type string (back-compat) or a field-metadata object so that @@ -3626,6 +3635,9 @@ export function resolveCellRendererType(fieldOrType: string | { type?: string; f if (typeof widget === 'string' && WIDGET_CELL_RENDERER_TYPES.has(widget) && TEXTUAL_BASE_TYPES.has(baseType)) { return widget; } + if (typeof widget === 'string' && MARKDOWN_WIDGET_CELL_RENDERER_TYPES.has(widget) && baseType === 'markdown') { + return widget; + } const formatRaw = fieldOrType.format; const format = typeof formatRaw === 'string' ? formatRaw.toLowerCase() : ''; if (format && FORMAT_TO_RENDERER[format] && TEXTUAL_BASE_TYPES.has(baseType)) { @@ -4359,6 +4371,25 @@ registerFieldRenderer('permission-ref', PermissionRefCell); // The criteria key draws its sentence through the widget's own read display, // loaded lazily on the first cell that shows one (the stored text until then). registerFieldRenderer('filter-condition', FilterConditionCell); +// A notification template's body, with the server's preview of the saved row +// under it on the record page (objectstack#39569). The pane loads lazily, off +// the eager closure; a grid cell draws the body alone and asks nothing. +const LazyNotificationTemplatePreview = recoverableLazy(() => + import('./widgets/NotificationTemplatePreviewField.js').then((m) => ({ default: m.NotificationTemplatePreviewField })), +); +function NotificationTemplatePreviewCell(props: CellRendererProps): React.ReactElement { + const body = ; + if (props.inGridColumn) return body; + return ( +
+ {body} + + + +
+ ); +} +registerFieldRenderer('notification-template-preview', NotificationTemplatePreviewCell); // `owner` was registered here to the same UserCellRenderer until objectui#4814 // retired the spelling — see the TOMBSTONE below. `getCellRenderer('owner')` // now reports the prescription and falls to the text cell. diff --git a/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx b/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx new file mode 100644 index 00000000000..b548ccb5211 --- /dev/null +++ b/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx @@ -0,0 +1,338 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * The notification template preview pane: the read face a + * `sys_notification_template` body declaring `widget: + * 'notification-template-preview'` draws under the body on the record page + * (objectstack#39569; ruling 7405856818 on #39412, item 2 = B). + * + * ## The door is the only renderer + * + * The pane renders nothing itself. It asks the messaging service's preview + * door, `POST /api/v1/messaging/notification-templates/:id/preview` + * (service-messaging `notification-template-preview-routes.ts`), which renders + * the SAVED row with the function the email and SMS channels send with and + * answers `{ subject, html | text }`. The pane shows that answer as it came: + * an `html` face through this package's one sanitizer (`HtmlCellRenderer`), a + * `text` face as plain text, because that is what the channels send. A refusal + * is shown as its own text and code. + * + * ## The sample values + * + * No topic declares its payload, so the inputs are the placeholders found in + * the saved subject and body ({@link samplePlaceholders}), read with the + * renderer's own hole grammar (`TOKEN` in service-messaging + * `template-renderer.ts`) and mapped onto the payload the door takes: the + * render context spreads the payload at its top level, so `{{ amount }}` and + * `{{ payload.amount }}` read one value, and `{{ title }}` / `{{ body }}` read + * the payload's when the notification gives none. `{{ topic }}` is the row's + * own topic, filled by the door, so it is not an input. + * + * ## When it asks + * + * On mount, when the SAVED row changes, and when the administrator asks with + * the values typed. Typing asks nothing, and neither does an unsaved inline + * draft the record page merges into the record it hands its fields: the row is + * judged saved again only when its `updated_at` stamp moves (or, for a row + * that carries none, when its rendered columns do). + * + * The request rides the host's authenticated fetch + * (`SchemaRendererContext.apiFetch`), as `preferenceOptions.ts` does; a + * surface whose host supplies none says the preview is not available here. + */ + +import React from 'react'; +import { Button, Input, cn } from '@object-ui/components'; +import { SchemaRendererContext, type ApiFetch } from '@object-ui/react'; +import type { CellRendererProps } from '../index.js'; +import { HtmlCellRenderer } from './richTextDisplay.js'; +import { useFieldTranslation } from './useFieldTranslation.js'; + +/** The preview door for the saved template `id`. */ +export function notificationTemplatePreviewUrl(id: string): string { + return `/api/v1/messaging/notification-templates/${encodeURIComponent(id)}/preview`; +} + +/** The renderer's hole grammar: `TOKEN` in service-messaging `template-renderer.ts`. */ +const HOLE = /\{\{\s*([\w.$]+)\s*\}\}/g; + +/** Render-context names the door fills itself: never a sample value. */ +const DOOR_FILLED = new Set(['topic', 'payload']); + +/** + * The payload paths the holes of `templates` read, in order of first + * appearance, each once. `payload.x` and `x` are one path (the render context + * spreads the payload at its top level); `topic` and the bare `payload` are not + * inputs. + */ +export function samplePlaceholders(...templates: unknown[]): string[] { + const paths: string[] = []; + for (const template of templates) { + if (typeof template !== 'string' || template === '') continue; + for (const match of template.matchAll(HOLE)) { + const hole = match[1]; + if (DOOR_FILLED.has(hole)) continue; + const path = hole.startsWith('payload.') ? hole.slice('payload.'.length) : hole; + if (path === '' || paths.includes(path)) continue; + paths.push(path); + } + } + return paths; +} + +/** + * The sample payload: each path with a typed value, a dotted path nested. An + * empty input is left out, so its hole renders empty, as it does in a send + * whose payload lacks the value. A path that would nest under a value already + * set as text is left out too, so no typed value is overwritten. + */ +export function samplePayload(paths: readonly string[], values: Readonly>): Record { + const payload: Record = {}; + for (const path of paths) { + const value = values[path]; + if (value === undefined || value === '') continue; + const keys = path.split('.'); + let node: Record | undefined = payload; + for (const key of keys.slice(0, -1)) { + const next: unknown = node[key]; + if (next === undefined) { + const child: Record = {}; + node[key] = child; + node = child; + } else if (next !== null && typeof next === 'object') { + node = next as Record; + } else { + node = undefined; + break; + } + } + const leaf = keys[keys.length - 1]; + if (node && node[leaf] === undefined) node[leaf] = value; + } + return payload; +} + +/** What the door answered, or why there is no answer. */ +type Answer = + | { kind: 'loading' } + | { kind: 'rendered'; subject: string; html?: string; text?: string } + | { kind: 'refused'; code?: string; message: string }; + +/** The columns the door renders, and the stamp a save moves. */ +interface SavedRow { + key: string; + id: string | undefined; + subject: unknown; + body: unknown; +} + +function savedRow(row: Record | undefined): SavedRow { + const id = typeof row?.id === 'string' && row.id !== '' ? row.id : undefined; + const stamp = row?.updated_at; + const key = + typeof stamp === 'string' && stamp !== '' + ? JSON.stringify([id, stamp]) + : JSON.stringify([id, row?.subject, row?.body, row?.format, row?.topic]); + return { key, id, subject: row?.subject, body: row?.body }; +} + +async function askDoor(doFetch: ApiFetch, id: string, payload: Record): Promise { + let res: Response; + try { + res = await doFetch(notificationTemplatePreviewUrl(id), { + method: 'POST', + headers: { accept: 'application/json', 'content-type': 'application/json' }, + credentials: 'include', + body: JSON.stringify({ payload }), + }); + } catch (err) { + return { kind: 'refused', message: err instanceof Error ? err.message : String(err) }; + } + let body: { success?: unknown; data?: unknown; error?: { code?: unknown; message?: unknown } } | null = null; + try { + body = await res.json(); + } catch { + body = null; + } + const data = body?.data as { subject?: unknown; html?: unknown; text?: unknown } | undefined; + if (res.ok && body?.success !== false && data && typeof data.subject === 'string') { + return { + kind: 'rendered', + subject: data.subject, + ...(typeof data.html === 'string' ? { html: data.html } : {}), + ...(typeof data.text === 'string' ? { text: data.text } : {}), + }; + } + const code = typeof body?.error?.code === 'string' ? body.error.code : undefined; + const message = + typeof body?.error?.message === 'string' && body.error.message !== '' ? body.error.message : `HTTP ${res.status}`; + return { kind: 'refused', code, message }; +} + +/** The pane. Reads the record off `dependentValues`, as every widget-hinted read face does. */ +export function NotificationTemplatePreviewField({ dependentValues }: Pick) { + const { t } = useFieldTranslation(); + const apiFetch = React.useContext(SchemaRendererContext)?.apiFetch; + const baseId = React.useId(); + + // The saved row, replaced only when a save moves it (see the header). + const current = savedRow(dependentValues); + const [saved, setSaved] = React.useState(current); + if (saved.key !== current.key) setSaved(current); + + const placeholders = samplePlaceholders(saved.subject, saved.body); + const [values, setValues] = React.useState>({}); + // The values the last request carried; a new object only when asked. + const [submitted, setSubmitted] = React.useState>({}); + const [answer, setAnswer] = React.useState({ kind: 'loading' }); + + const id = saved.id; + const payloadJson = JSON.stringify(samplePayload(placeholders, submitted)); + + React.useEffect(() => { + if (!apiFetch || !id) return; + let live = true; + setAnswer({ kind: 'loading' }); + void askDoor(apiFetch, id, JSON.parse(payloadJson) as Record).then((next) => { + if (live) setAnswer(next); + }); + return () => { + live = false; + }; + }, [apiFetch, id, saved.key, payloadJson, submitted]); + + const shell = (children: React.ReactNode) => ( +
+

+ {t('fields.notificationTemplatePreview.title', { defaultValue: 'Preview' })} +

+ {children} +
+ ); + + if (!id) { + return shell( +

+ {t('fields.notificationTemplatePreview.unsaved', { defaultValue: 'Save the template to preview it.' })} +

, + ); + } + if (!apiFetch) { + return shell( +

+ {t('fields.notificationTemplatePreview.unavailable', { defaultValue: 'The preview is not available here.' })} +

, + ); + } + + return shell( + <> +

+ {t('fields.notificationTemplatePreview.intro', { + defaultValue: 'The saved template, rendered by the server that sends it. Save the template to refresh it.', + })} +

+
{ + event.preventDefault(); + setSubmitted({ ...values }); + }} + > +
+ {t('fields.notificationTemplatePreview.samples', { defaultValue: 'Sample values' })} +
+ {placeholders.length === 0 ? ( +

+ {t('fields.notificationTemplatePreview.noPlaceholders', { defaultValue: 'This template has no placeholders.' })} +

+ ) : ( +
+ {placeholders.map((path, i) => ( +
+ + setValues((prev) => ({ ...prev, [path]: event.target.value }))} + /> +
+ ))} +
+ )} + +
+ + , + ); +} + +function PreviewAnswer({ answer, t }: { answer: Answer; t: ReturnType['t'] }) { + if (answer.kind === 'loading') { + return ( +

+ {t('fields.notificationTemplatePreview.loading', { defaultValue: 'Rendering…' })} +

+ ); + } + if (answer.kind === 'refused') { + return ( +

+ {answer.code + ? t('fields.notificationTemplatePreview.refused', { + defaultValue: 'Not rendered: {{message}} ({{code}})', + message: answer.message, + code: answer.code, + }) + : t('fields.notificationTemplatePreview.failed', { + defaultValue: 'Not rendered: {{message}}', + message: answer.message, + })} +

+ ); + } + return ( +
+
+
+ {t('fields.notificationTemplatePreview.subject', { defaultValue: 'Subject' })} +
+
{answer.subject}
+
+
+
+ {t('fields.notificationTemplatePreview.body', { defaultValue: 'Body' })} +
+
+ {answer.html !== undefined ? ( +
+ +
+ ) : ( +
{answer.text ?? ''}
+ )} +
+
+
+ ); +} + +/** The field the html face is drawn as: the door's answer, not a stored column. */ +const HTML_FACE_FIELD = { name: 'html', type: 'html' } as CellRendererProps['field']; From f5fc4e3ba2c3cfdb01b895248617cbf63f73f1fe Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 12:43:05 +0000 Subject: [PATCH 3/5] feat(service-messaging): the notification template body declares its preview read face Claude-Session: https://claude.ai/code/session_01L9qibyrf8y7cWLVu7DMgBN Co-authored-by: Claude --- .../src/objects/notification-template.object.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/services/service-messaging/src/objects/notification-template.object.ts b/packages/services/service-messaging/src/objects/notification-template.object.ts index 82d0daaa63c..644b66c8814 100644 --- a/packages/services/service-messaging/src/objects/notification-template.object.ts +++ b/packages/services/service-messaging/src/objects/notification-template.object.ts @@ -186,6 +186,12 @@ export const NotificationTemplate = ObjectSchema.create({ description: 'Template body, interpreted per `format`. ' + 'Variables: {{ title }} and {{ body }} (the notification\'s own title and text), {{ topic }}, ' + 'and {{ payload. }} for any other value its topic sends.', + // [#39569, ruling 7405856818 on #39412 item 2 = B] The record + // page draws the body with the saved row's preview under it, as + // the preview door (`notification-template-preview-routes.ts`) + // renders it against sample values. A read face only: the edit + // form keeps the markdown editor (the hint degrades to `type`). + widget: 'notification-template-preview', }), format: Field.select(['markdown', 'html', 'text', 'mjml'], { From d60e51cb05f0bed035dbb5bcfe5721ab8e5a3aea Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 12:51:34 +0000 Subject: [PATCH 4/5] feat(fields, i18n): the preview pane reads its words from the packs; census rows and changeset Claude-Session: https://claude.ai/code/session_01L9qibyrf8y7cWLVu7DMgBN Co-authored-by: Claude --- ...9569-notification-template-preview-pane.md | 19 ++++++ .../cellRenderers.objectLiteral-8596.test.tsx | 4 ++ ui/packages/fields/src/index.tsx | 5 +- .../NotificationTemplatePreviewField.tsx | 24 +++----- ...icationTemplatePreviewField-39569.test.tsx | 61 ++++++++++++++++--- ui/packages/i18n/src/locales/ar.ts | 14 +++++ ui/packages/i18n/src/locales/de.ts | 14 +++++ ui/packages/i18n/src/locales/en.ts | 14 +++++ ui/packages/i18n/src/locales/es.ts | 14 +++++ ui/packages/i18n/src/locales/fr.ts | 14 +++++ ui/packages/i18n/src/locales/ja.ts | 14 +++++ ui/packages/i18n/src/locales/ko.ts | 14 +++++ ui/packages/i18n/src/locales/pt-BR.ts | 14 +++++ ui/packages/i18n/src/locales/ru.ts | 14 +++++ ui/packages/i18n/src/locales/zh-Hans.ts | 14 +++++ ui/packages/i18n/src/locales/zh-Hant.ts | 14 +++++ .../summaryChip.badgeFitCensus-8464.test.tsx | 8 ++- 17 files changed, 248 insertions(+), 27 deletions(-) create mode 100644 .changeset/39569-notification-template-preview-pane.md diff --git a/.changeset/39569-notification-template-preview-pane.md b/.changeset/39569-notification-template-preview-pane.md new file mode 100644 index 00000000000..f7886951863 --- /dev/null +++ b/.changeset/39569-notification-template-preview-pane.md @@ -0,0 +1,19 @@ +--- +'@object-ui/fields': patch +'@object-ui/i18n': patch +'@objectstack/service-messaging': patch +--- + +feat(fields, service-messaging): a notification template's record page previews the saved template as it would be sent + +Clause-②: no +Metadata-protocol: none + +Who sees it: an administrator opening a notification template under Setup → Notification Templates. + +- **Under the body, a Preview pane shows the saved subject and body as the messaging service renders them for a send.** The server's preview route renders them with the same function the email and SMS channels use. Nothing is sent and nothing is written. +- **Each placeholder in the saved subject and body gets a sample-value input** (`{{ amount }}` and `{{ payload.amount }}` share one input; `{{ topic }}` is filled from the template's own topic). Typing sends nothing; **Preview with these values** renders again with what was typed. +- **The pane refreshes when the template is saved**, not while you type in the edit form. A refusal (no access to the template, a template that no longer exists) is shown as its own text and code. +- An `html` or `mjml` template shows the rendered HTML through the console's sanitizer; a `markdown` or `text` template shows the plain text the channels send. +- The edit form is unchanged: the body keeps its markdown editor. The pane is the body's read face on the record page, declared on `sys_notification_template.body` as `widget: 'notification-template-preview'`. A list cell of the body draws the body alone. +- The pane's words are translated in every console language (`fields.notificationTemplatePreview.*`). diff --git a/ui/packages/fields/src/__tests__/cellRenderers.objectLiteral-8596.test.tsx b/ui/packages/fields/src/__tests__/cellRenderers.objectLiteral-8596.test.tsx index 7c7e368cea2..a793672b294 100644 --- a/ui/packages/fields/src/__tests__/cellRenderers.objectLiteral-8596.test.tsx +++ b/ui/packages/fields/src/__tests__/cellRenderers.objectLiteral-8596.test.tsx @@ -308,6 +308,9 @@ const OBJECT_LITERAL_CENSUS: ReadonlyArray = ['position-ref', 'sales_manager'], ['permission-ref', 'admin_full_access'], ['filter-condition', '{"priority":"urgent"}'], + ['notification-template-preview', '**bold**'], ]; describe('objectui#8596 — an object literal is not a cell value, and these renderers invented one', () => { diff --git a/ui/packages/fields/src/index.tsx b/ui/packages/fields/src/index.tsx index f1ac0ad618f..d182778eb5c 100644 --- a/ui/packages/fields/src/index.tsx +++ b/ui/packages/fields/src/index.tsx @@ -4373,13 +4373,14 @@ registerFieldRenderer('permission-ref', PermissionRefCell); registerFieldRenderer('filter-condition', FilterConditionCell); // A notification template's body, with the server's preview of the saved row // under it on the record page (objectstack#39569). The pane loads lazily, off -// the eager closure; a grid cell draws the body alone and asks nothing. +// the eager closure. A grid cell, and a host that hands no row, draw the body +// alone and ask nothing: the pane previews the row it is handed. const LazyNotificationTemplatePreview = recoverableLazy(() => import('./widgets/NotificationTemplatePreviewField.js').then((m) => ({ default: m.NotificationTemplatePreviewField })), ); function NotificationTemplatePreviewCell(props: CellRendererProps): React.ReactElement { const body = ; - if (props.inGridColumn) return body; + if (props.inGridColumn || !props.dependentValues) return body; return (
{body} diff --git a/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx b/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx index b548ccb5211..50cb4acfb75 100644 --- a/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx +++ b/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx @@ -214,7 +214,7 @@ export function NotificationTemplatePreviewField({ dependentValues }: Pick

- {t('fields.notificationTemplatePreview.title', { defaultValue: 'Preview' })} + {t('fields.notificationTemplatePreview.title')}

{children} @@ -223,14 +223,14 @@ export function NotificationTemplatePreviewField({ dependentValues }: Pick - {t('fields.notificationTemplatePreview.unsaved', { defaultValue: 'Save the template to preview it.' })} + {t('fields.notificationTemplatePreview.unsaved')}

, ); } if (!apiFetch) { return shell(

- {t('fields.notificationTemplatePreview.unavailable', { defaultValue: 'The preview is not available here.' })} + {t('fields.notificationTemplatePreview.unavailable')}

, ); } @@ -238,9 +238,7 @@ export function NotificationTemplatePreviewField({ dependentValues }: Pick

- {t('fields.notificationTemplatePreview.intro', { - defaultValue: 'The saved template, rendered by the server that sends it. Save the template to refresh it.', - })} + {t('fields.notificationTemplatePreview.intro')}

- {t('fields.notificationTemplatePreview.samples', { defaultValue: 'Sample values' })} + {t('fields.notificationTemplatePreview.samples')}
{placeholders.length === 0 ? (

- {t('fields.notificationTemplatePreview.noPlaceholders', { defaultValue: 'This template has no placeholders.' })} + {t('fields.notificationTemplatePreview.noPlaceholders')}

) : (
@@ -273,7 +271,7 @@ export function NotificationTemplatePreviewField({ dependentValues }: Pick )} @@ -285,7 +283,7 @@ function PreviewAnswer({ answer, t }: { answer: Answer; t: ReturnType - {t('fields.notificationTemplatePreview.loading', { defaultValue: 'Rendering…' })} + {t('fields.notificationTemplatePreview.loading')}

); } @@ -294,12 +292,10 @@ function PreviewAnswer({ answer, t }: { answer: Answer; t: ReturnType {answer.code ? t('fields.notificationTemplatePreview.refused', { - defaultValue: 'Not rendered: {{message}} ({{code}})', message: answer.message, code: answer.code, }) : t('fields.notificationTemplatePreview.failed', { - defaultValue: 'Not rendered: {{message}}', message: answer.message, })}

@@ -309,13 +305,13 @@ function PreviewAnswer({ answer, t }: { answer: Answer; t: ReturnType
- {t('fields.notificationTemplatePreview.subject', { defaultValue: 'Subject' })} + {t('fields.notificationTemplatePreview.subject')}
{answer.subject}
- {t('fields.notificationTemplatePreview.body', { defaultValue: 'Body' })} + {t('fields.notificationTemplatePreview.body')}
{answer.html !== undefined ? ( diff --git a/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx b/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx index 375e01406b5..735600740d1 100644 --- a/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx +++ b/ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx @@ -31,6 +31,7 @@ import React from 'react'; import { render, screen, fireEvent, cleanup, waitFor, act } from '@testing-library/react'; import '@testing-library/jest-dom'; import { SchemaRendererProvider } from '@object-ui/react'; +import { I18nProvider } from '@object-ui/i18n'; import { NotificationTemplatePreviewField, notificationTemplatePreviewUrl, @@ -70,17 +71,28 @@ const ROW = { updated_at: '2026-12-04T10:00:00.000Z', }; -function mount(apiFetch: ReturnType['fetch'] | undefined, row: Record = ROW) { +/** The host the pane is drawn in: the console's i18n and its authenticated fetch. */ +function Host({ apiFetch, language = 'en', children }: { apiFetch?: ReturnType['fetch']; language?: string; children: React.ReactNode }) { + return ( + + + {children} + + + ); +} + +function mount(apiFetch: ReturnType['fetch'] | undefined, row: Record = ROW, language = 'en') { const view = render( - + - , + , ); const rerender = (next: Record) => view.rerender( - + - , + , ); return { ...view, rerender }; } @@ -235,9 +247,9 @@ describe('the `notification-template-preview` widget hint is the body’s read f const { fetch, calls } = door(ok({ subject: 'Invoice paid', text: 'Hi' })); const Cell = getCellRenderer(resolveCellRendererType(FIELD)); render( - + - , + , ); expect(await screen.findByTestId('notification-template-preview-subject')).toHaveTextContent('Invoice paid'); expect(calls).toHaveLength(1); @@ -247,12 +259,43 @@ describe('the `notification-template-preview` widget hint is the body’s read f const { fetch, calls } = door(ok({ subject: 'Invoice paid', text: 'Hi' })); const Cell = getCellRenderer(resolveCellRendererType(FIELD)); render( - + - , + , ); await act(async () => {}); expect(screen.queryByTestId('notification-template-preview')).toBeNull(); expect(calls).toHaveLength(0); }); + + it('a host that hands no row draws the body alone and asks nothing', async () => { + const { fetch, calls } = door(ok({ subject: 'Invoice paid', text: 'Hi' })); + const Cell = getCellRenderer(resolveCellRendererType(FIELD)); + render( + + + , + ); + await act(async () => {}); + expect(screen.queryByTestId('notification-template-preview')).toBeNull(); + expect(calls).toHaveLength(0); + }); +}); + +describe('the pane speaks the reader’s language', () => { + it('en reads the pack’s words, and a refusal carries the door’s own text', async () => { + const { fetch } = door(refused(404, 'RECORD_NOT_FOUND', 'No such template.')); + mount(fetch); + expect(await screen.findByRole('heading', { name: 'Preview' })).toBeInTheDocument(); + expect(await screen.findByRole('alert')).toHaveTextContent('Not rendered: No such template. (RECORD_NOT_FOUND)'); + }); + + it('zh-CN reads Chinese, with no English word of the pane left', async () => { + const { fetch } = door(ok({ subject: 's', text: 't' })); + mount(fetch, ROW, 'zh-CN'); + expect(await screen.findByRole('heading', { name: '预览' })).toBeInTheDocument(); + expect(screen.getByTestId('notification-template-preview-render')).toHaveTextContent('用这些值预览'); + expect(screen.queryByText('Preview with these values')).toBeNull(); + expect(screen.queryByText('Sample values')).toBeNull(); + }); }); diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 799d7334c5c..6747525628c 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -425,6 +425,20 @@ const ar = { replace: "تعيين نطاق زمني", zoneNotInList: "{{zone}} (ليست في القائمة)", }, + notificationTemplatePreview: { + title: "معاينة", + intro: "القالب المحفوظ كما يعرضه الخادم الذي يرسله. احفظ القالب لتحديث المعاينة.", + samples: "قيم نموذجية", + noPlaceholders: "لا يحتوي هذا القالب على عناصر نائبة.", + render: "معاينة بهذه القيم", + loading: "جارٍ العرض…", + subject: "الموضوع", + body: "النص", + refused: "لم يتم العرض: {{message}} ({{code}})", + failed: "لم يتم العرض: {{message}}", + unsaved: "احفظ القالب لمعاينته.", + unavailable: "المعاينة غير متاحة هنا.", + }, recipient: { selectTypeFirst: "اختر نوع المستلم أولاً.", loading: "جارٍ التحميل…", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 22fdd9a4bdf..c6824b3473a 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -403,6 +403,20 @@ const de = { replace: "Zeitraum festlegen", zoneNotInList: "{{zone}} (nicht in der Liste)", }, + notificationTemplatePreview: { + title: "Vorschau", + intro: "Die gespeicherte Vorlage, gerendert vom Server, der sie versendet. Speichern Sie die Vorlage, um die Vorschau zu aktualisieren.", + samples: "Beispielwerte", + noPlaceholders: "Diese Vorlage enthält keine Platzhalter.", + render: "Mit diesen Werten anzeigen", + loading: "Wird gerendert…", + subject: "Betreff", + body: "Text", + refused: "Nicht gerendert: {{message}} ({{code}})", + failed: "Nicht gerendert: {{message}}", + unsaved: "Speichern Sie die Vorlage, um eine Vorschau zu sehen.", + unavailable: "Die Vorschau ist hier nicht verfügbar.", + }, recipient: { selectTypeFirst: "Wählen Sie zuerst einen Empfängertyp.", loading: "Wird geladen…", diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 72819ed34c4..54533d0c136 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -585,6 +585,20 @@ const en = { replace: 'Set a time range', zoneNotInList: '{{zone}} (not in the list)', }, + notificationTemplatePreview: { + title: 'Preview', + intro: 'The saved template, rendered by the server that sends it. Save the template to refresh it.', + samples: 'Sample values', + noPlaceholders: 'This template has no placeholders.', + render: 'Preview with these values', + loading: 'Rendering…', + subject: 'Subject', + body: 'Body', + refused: 'Not rendered: {{message}} ({{code}})', + failed: 'Not rendered: {{message}}', + unsaved: 'Save the template to preview it.', + unavailable: 'The preview is not available here.', + }, recipient: { selectTypeFirst: 'Select a recipient type first.', loading: 'Loading…', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index fe0f67789ec..3fb3c21f00f 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -412,6 +412,20 @@ const es = { replace: "Definir un intervalo horario", zoneNotInList: "{{zone}} (no está en la lista)", }, + notificationTemplatePreview: { + title: "Vista previa", + intro: "La plantilla guardada, generada por el servidor que la envía. Guarda la plantilla para actualizarla.", + samples: "Valores de ejemplo", + noPlaceholders: "Esta plantilla no tiene marcadores de posición.", + render: "Vista previa con estos valores", + loading: "Generando…", + subject: "Asunto", + body: "Cuerpo", + refused: "No se generó: {{message}} ({{code}})", + failed: "No se generó: {{message}}", + unsaved: "Guarda la plantilla para ver la vista previa.", + unavailable: "La vista previa no está disponible aquí.", + }, recipient: { selectTypeFirst: "Selecciona primero un tipo de destinatario.", loading: "Cargando…", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 0b36606f1b1..890c8572240 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -407,6 +407,20 @@ const fr = { replace: "Définir une plage horaire", zoneNotInList: "{{zone}} (absent de la liste)", }, + notificationTemplatePreview: { + title: "Aperçu", + intro: "Le modèle enregistré, rendu par le serveur qui l’envoie. Enregistrez le modèle pour actualiser l’aperçu.", + samples: "Valeurs d’exemple", + noPlaceholders: "Ce modèle ne contient aucun espace réservé.", + render: "Aperçu avec ces valeurs", + loading: "Rendu en cours…", + subject: "Objet", + body: "Corps", + refused: "Non rendu : {{message}} ({{code}})", + failed: "Non rendu : {{message}}", + unsaved: "Enregistrez le modèle pour en voir l’aperçu.", + unavailable: "L’aperçu n’est pas disponible ici.", + }, recipient: { selectTypeFirst: "Sélectionnez d'abord un type de destinataire.", loading: "Chargement…", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 2446bb32555..a16151248d0 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -403,6 +403,20 @@ const ja = { replace: "時間帯を設定", zoneNotInList: "{{zone}}(一覧にありません)", }, + notificationTemplatePreview: { + title: "プレビュー", + intro: "保存済みのテンプレートを、送信するサーバーがレンダリングしたものです。テンプレートを保存すると更新されます。", + samples: "サンプル値", + noPlaceholders: "このテンプレートにはプレースホルダーがありません。", + render: "この値でプレビュー", + loading: "レンダリング中…", + subject: "件名", + body: "本文", + refused: "レンダリングできませんでした: {{message}}({{code}})", + failed: "レンダリングできませんでした: {{message}}", + unsaved: "テンプレートを保存するとプレビューできます。", + unavailable: "ここではプレビューを利用できません。", + }, recipient: { selectTypeFirst: "先に受信者タイプを選択してください。", loading: "読み込み中…", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index 774ccfe54c0..f8c444e960c 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -403,6 +403,20 @@ const ko = { replace: "시간 범위 설정", zoneNotInList: "{{zone}} (목록에 없음)", }, + notificationTemplatePreview: { + title: "미리 보기", + intro: "저장된 템플릿을 발송하는 서버가 렌더링한 결과입니다. 템플릿을 저장하면 새로 고쳐집니다.", + samples: "샘플 값", + noPlaceholders: "이 템플릿에는 자리 표시자가 없습니다.", + render: "이 값으로 미리 보기", + loading: "렌더링 중…", + subject: "제목", + body: "본문", + refused: "렌더링되지 않음: {{message}} ({{code}})", + failed: "렌더링되지 않음: {{message}}", + unsaved: "템플릿을 저장하면 미리 볼 수 있습니다.", + unavailable: "여기서는 미리 보기를 사용할 수 없습니다.", + }, recipient: { selectTypeFirst: "먼저 수신자 유형을 선택하세요.", loading: "로딩 중…", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 0792604de06..f1fdb36b76e 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -407,6 +407,20 @@ const pt = { replace: "Definir um intervalo de horário", zoneNotInList: "{{zone}} (fora da lista)", }, + notificationTemplatePreview: { + title: "Pré-visualização", + intro: "O modelo salvo, renderizado pelo servidor que o envia. Salve o modelo para atualizar a pré-visualização.", + samples: "Valores de exemplo", + noPlaceholders: "Este modelo não tem marcadores.", + render: "Pré-visualizar com estes valores", + loading: "Renderizando…", + subject: "Assunto", + body: "Corpo", + refused: "Não renderizado: {{message}} ({{code}})", + failed: "Não renderizado: {{message}}", + unsaved: "Salve o modelo para pré-visualizá-lo.", + unavailable: "A pré-visualização não está disponível aqui.", + }, recipient: { selectTypeFirst: "Selecione primeiro um tipo de destinatário.", loading: "Carregando…", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 481a918c4a9..65bb4d935b4 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -414,6 +414,20 @@ const ru = { replace: "Задать диапазон времени", zoneNotInList: "{{zone}} (нет в списке)", }, + notificationTemplatePreview: { + title: "Предпросмотр", + intro: "Сохранённый шаблон в том виде, в каком его отображает сервер, который его отправляет. Сохраните шаблон, чтобы обновить предпросмотр.", + samples: "Примеры значений", + noPlaceholders: "В этом шаблоне нет заполнителей.", + render: "Просмотреть с этими значениями", + loading: "Отображение…", + subject: "Тема", + body: "Текст", + refused: "Не отображено: {{message}} ({{code}})", + failed: "Не отображено: {{message}}", + unsaved: "Сохраните шаблон, чтобы увидеть предпросмотр.", + unavailable: "Предпросмотр здесь недоступен.", + }, recipient: { selectTypeFirst: "Сначала выберите тип получателя.", loading: "Загрузка…", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index f36cd301670..7370684f6d6 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -413,6 +413,20 @@ const zh = { replace: '设置时间段', zoneNotInList: '{{zone}}(不在列表中)', }, + notificationTemplatePreview: { + title: '预览', + intro: '已保存的模板,由发送它的服务器渲染。保存模板即可刷新预览。', + samples: '示例值', + noPlaceholders: '此模板没有占位符。', + render: '用这些值预览', + loading: '正在渲染…', + subject: '主题', + body: '正文', + refused: '未能渲染:{{message}}({{code}})', + failed: '未能渲染:{{message}}', + unsaved: '保存模板后即可预览。', + unavailable: '此处无法预览。', + }, recipient: { selectTypeFirst: '请先选择接收方类型。', loading: '加载中…', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 764dd11e1bd..3ce8948e989 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -413,6 +413,20 @@ const zhHant = { replace: '設定時間段', zoneNotInList: '{{zone}}(不在列表中)', }, + notificationTemplatePreview: { + title: '預覽', + intro: '已儲存的模板,由傳送它的伺服器渲染。儲存模板即可重新整理預覽。', + samples: '示例值', + noPlaceholders: '此模板沒有佔位符。', + render: '用這些值預覽', + loading: '正在渲染…', + subject: '主題', + body: '正文', + refused: '未能渲染:{{message}}({{code}})', + failed: '未能渲染:{{message}}', + unsaved: '儲存模板後即可預覽。', + unavailable: '此處無法預覽。', + }, recipient: { selectTypeFirst: '請先選擇接收方型別。', loading: '載入中…', diff --git a/ui/packages/plugin-detail/src/__tests__/summaryChip.badgeFitCensus-8464.test.tsx b/ui/packages/plugin-detail/src/__tests__/summaryChip.badgeFitCensus-8464.test.tsx index ca6c80887cc..32559eb9c5c 100644 --- a/ui/packages/plugin-detail/src/__tests__/summaryChip.badgeFitCensus-8464.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/summaryChip.badgeFitCensus-8464.test.tsx @@ -172,6 +172,9 @@ const CENSUS: ReadonlyArray Date: Fri, 4 Dec 2026 14:16:22 +0000 Subject: [PATCH 5/5] fix(fields): drop the unused initializer on askDoor's body (no-useless-assignment) Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L9qibyrf8y7cWLVu7DMgBN --- .../fields/src/widgets/NotificationTemplatePreviewField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx b/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx index 50cb4acfb75..10e34f1625d 100644 --- a/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx +++ b/ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx @@ -154,7 +154,7 @@ async function askDoor(doFetch: ApiFetch, id: string, payload: Record