Skip to content
16 changes: 16 additions & 0 deletions .changeset/35415-approval-request-names-its-record.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@object-ui/components': patch
'@object-ui/app-shell': patch
'@objectstack/plugin-approvals': patch
---

fix(console): the approval request page is named by the record it asks a decision on, and its reject button no longer outweighs approve

Clause-②: yes (widening)
Metadata-protocol: none

- **The page title.** An approval request's page used to be titled by its flow's label ("Purchase approval"), which the strip under it repeated as its Flow chip, while the business record the approver decides on had no title at all. The page header now reads the record's title the approvals get serves (`record_title`), linked to that record once the page itself has read it: a plain click opens it in the app, as the "As submitted" card's "Open record" link does, and a modifier or middle click opens it in a new tab. Where the page's read of the record is refused or finds nothing, or the platform says the record was deleted, the title is plain text with no link, as the record card on the same page draws it. The title makes no read of its own: the reads the page already makes report what they found. Where the get serves no title for the record, or serves only its id, the header keeps the flow's label, so the page never names the record by a raw id. The flow stays named once, by the strip's Flow chip; no subtitle is added, because it would repeat that chip. The request object's declared title (`nameField: 'process_label'`) is unchanged, so lists, search, recent items and the breadcrumb still name a request by its flow.
- **`RecordHeaderState.title`** (`@object-ui/components`, new optional member, with its type `RecordHeaderTitle`). A host that knows a better name for the record than the object's declared title hands `{ text, node? }`; `page:header` draws `node` (or `text`) inside its H1, in the host's top bar and in its own row alike. Absent, or with an empty `text`, the header's own title stands exactly as before.
- **The decision band.** In the approver's band (the request page, and the business record page's approval band), Approve stays the filled primary button and Reject is drawn as an outline button in the destructive text colour, the face the record header already gives a secondary danger lever. A host that does not ask for the band's fold keeps the declared filled danger face.
- **One time format.** The approval timeline's action times use the compact datetime face the page's highlight chips and every `datetime` cell draw (`2026/11/10 下午8:25` under zh-CN), in the host's display time zone, instead of the browser's long form with seconds.
- `@objectstack/plugin-approvals`: comments only, saying where the request page now names its record.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ export const SysApprovalRequest = ObjectSchema.create({
// page fell through to the since-retired `titleFormat`, the machine name and
// the raw subject record id.
//
// The title names no subject record. The request page names the subject on
// the card the `record_id` / `object_name` pair draws in the Details tab,
// which says so when the reader may not read the record or it was deleted;
// a title cannot, so a bare record id is never shown there.
// The title names no subject record: lists and search name a request by its
// flow. On the request's own page the console's header names the subject by
// the `record_title` the approvals get serves for it, linked to it, and
// keeps this title where the get serves none (objectstack#35415), so a bare
// record id is never shown there either.
//
// Where `process_label` is empty — a row written before the column, until the
// boot fill labels it (`display-label-backfill.ts`) — the retired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export const SysApprovalRequestDetailPage: Page = {
name: 'main',
width: 'full',
components: [
// ── The record header: the request's title, and every action placed
// ── The record header: the request's title (the console names the
// request by the business record it is about, linked to it, wherever
// the approvals get serves that record's title, objectstack#35415;
// else by the flow's label, the object's `nameField`), and every action placed
// on the object at `record_header` / `record_more`, read live, as the
// synthesized header drew them. The object places none of its own, so
// only an action another package places there shows (a bare header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,13 @@ async function inboxRow(): Promise<HTMLElement> {
return row;
}

/** The served page has drawn: its decision panel and its H1. */
/**
* The served page has drawn: its decision panel and its H1, which names the
* request by the record it asks a decision on (objectstack#35415).
*/
async function servedPage(): Promise<void> {
await screen.findByTestId('approval-decision-panel', undefined, { timeout: 8000 });
expect((await screen.findByRole('heading', { level: 1 }, { timeout: 8000 })).textContent).toBe(ROW.process_label);
expect((await screen.findByRole('heading', { level: 1 }, { timeout: 8000 })).textContent).toBe(ROW.record_title);
}

/** The served get was read; the sheet's own reads were not, and no sheet (a dialog) is mounted. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,27 +282,49 @@ describe('the served request page links a readable target to its record (objectu
expect(PageSchema.safeParse(SERVED_PAGE).success).toBe(true);
});

it('readable: one link to the app-scoped record path, named by the card title, inside the card', async () => {
it('readable: one link to the app-scoped record path inside the card, named by the card title; the page H1 is the other (objectstack#35415)', async () => {
const id = 'Rd4bl3RecordQQQQ';
targetAnswer = async (rid) => ({ id: rid, name: TARGET_TITLE, amount: 12500 });
const { container } = openServedPage({ record_id: id, status: 'pending', record_title: TARGET_TITLE });
const card = await settledCard(container);

expect(card.getAttribute('data-record-preview')).toBe('readable');
// The card's link, and the page H1, which names the request by its
// record and links to it once the page has read it (objectstack#35415).
await waitFor(() => expect(linksTo(recordPath(id))).toHaveLength(2), { timeout: 8000 });
const links = linksTo(recordPath(id));
expect(links).toHaveLength(1);
expect(card.contains(links[0])).toBe(true);
expect(screen.getByRole('link', { name: TARGET_TITLE })).toBe(links[0]);
const inCard = links.filter((a) => card.contains(a));
expect(inCard).toHaveLength(1);
expect(within(card).getByRole('link', { name: TARGET_TITLE })).toBe(inCard[0]);
const h1 = screen.getByRole('heading', { level: 1 });
expect(h1.textContent).toBe(TARGET_TITLE);
expect(links.filter((a) => h1.contains(a))).toHaveLength(1);
});

it('readable: a plain click opens the record in a drawer over the page, and the page stays put', async () => {
it('readable: a plain click on the page H1 opens the record in the same drawer, and the page stays put (objectstack#35415)', async () => {
const id = 'Rd4bl3RecordQQQQ';
targetAnswer = async (rid) => ({ id: rid, name: TARGET_TITLE, amount: 12500 });
const { container } = openServedPage({ record_id: id, status: 'pending', record_title: TARGET_TITLE });
await settledCard(container);
const requestPath = `/apps/${APP}/${APPROVAL_REQUEST_OBJECT}/record/${REQ}`;

const notPrevented = fireEvent.click(screen.getByRole('link', { name: TARGET_TITLE }), { button: 0 });
const h1 = screen.getByRole('heading', { level: 1 });
const titleLink = await waitFor(() => within(h1).getByRole('link', { name: TARGET_TITLE }), { timeout: 8000 });
const notPrevented = fireEvent.click(titleLink, { button: 0 });
expect(notPrevented).toBe(false);
const drawer = await screen.findByRole('dialog', undefined, { timeout: 8000 });
await waitFor(() => expect(within(drawer).getAllByText(TARGET_TITLE).length).toBeGreaterThan(0), { timeout: 8000 });
expect(screen.getByTestId('router-pathname').textContent).toBe(requestPath);
});

it('readable: a plain click opens the record in a drawer over the page, and the page stays put', async () => {
const id = 'Rd4bl3RecordQQQQ';
targetAnswer = async (rid) => ({ id: rid, name: TARGET_TITLE, amount: 12500 });
const { container } = openServedPage({ record_id: id, status: 'pending', record_title: TARGET_TITLE });
const card = await settledCard(container);
const requestPath = `/apps/${APP}/${APPROVAL_REQUEST_OBJECT}/record/${REQ}`;

const notPrevented = fireEvent.click(within(card).getByRole('link', { name: TARGET_TITLE }), { button: 0 });
expect(notPrevented).toBe(false);
// The drawer opens with the target record in it …
const drawer = await screen.findByRole('dialog', undefined, { timeout: 8000 });
Expand All @@ -311,16 +333,16 @@ describe('the served request page links a readable target to its record (objectu
// … over the request page: the router did not move.
expect(screen.getByTestId('router-pathname').textContent).toBe(requestPath);
// The href still names the record path, for a new tab or a copied link.
expect(linksTo(recordPath(id))).toHaveLength(1);
expect(linksTo(recordPath(id)).filter((a) => card.contains(a))).toHaveLength(1);
});

it('readable: a modified click is the browser\'s — not intercepted, no drawer', async () => {
const id = 'Rd4bl3RecordQQQQ';
targetAnswer = async (rid) => ({ id: rid, name: TARGET_TITLE, amount: 12500 });
const { container } = openServedPage({ record_id: id, status: 'pending', record_title: TARGET_TITLE });
await settledCard(container);
const card = await settledCard(container);

const link = screen.getByRole('link', { name: TARGET_TITLE });
const link = within(card).getByRole('link', { name: TARGET_TITLE });
const notPrevented = fireEvent.click(link, { button: 0, metaKey: true });
expect(notPrevented).toBe(true);
expect(new URL(link.getAttribute('href') as string, 'http://test.local').pathname).toBe(recordPath(id));
Expand All @@ -336,6 +358,10 @@ describe('the served request page links a readable target to its record (objectu
expect(card.getAttribute('data-record-preview')).toBe('unreadable');
expect(card.querySelectorAll('a[href]')).toHaveLength(0);
expect(linksTo(recordPath(id))).toHaveLength(0);
// The H1 names the record by the title the get served, as plain text (objectstack#35415).
const h1 = screen.getByRole('heading', { level: 1 });
expect(h1.textContent).toBe('INV-2020');
expect(h1.querySelectorAll('a[href]')).toHaveLength(0);
});

it('CONTROL: unresolvable (the target read resolves with no record) draws no link to the target anywhere', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,23 @@ describe('the served request page draws the four reference states the sheet draw
expect(PageSchema.safeParse(SERVED_PAGE).success).toBe(true);
});

it('readable (sheet: recordLink): one link to the record path, inside the card, named by its title', async () => {
it('readable (sheet: recordLink): one link to the record path inside the card, named by its title; the H1 names and links the record too', async () => {
const id = 'Rd4bl3Rec12489QQ';
targetAnswer = async (rid) => ({ id: rid, name: TARGET_TITLE, amount: 12500 });
const { container } = openServedPage({ record_id: id, status: 'pending', record_title: TARGET_TITLE });
const card = await settledCard(container);

expect(card.getAttribute('data-record-preview')).toBe('readable');
const links = linksTo(recordPath(id));
expect(links).toHaveLength(1);
expect(card.contains(links[0])).toBe(true);
expect(links[0].textContent).toContain(TARGET_TITLE);
await waitFor(() => expect(linksTo(recordPath(id))).toHaveLength(2), { timeout: 8000 });
const inCard = linksTo(recordPath(id)).filter((a) => card.contains(a));
expect(inCard).toHaveLength(1);
expect(inCard[0].textContent).toContain(TARGET_TITLE);
expect(container.querySelector('[data-record-pointer="deleted"]')).toBeNull();
// The H1 names the flow by its label: not the subject's id, not `flow:NAME`.
// The H1 names the request by its record, linked once the page read it
// (objectstack#35415): not the subject's id, not `flow:NAME`.
const h1 = await pageTitle();
expect(h1.textContent).toBe(FLOW_LABEL);
expect(h1.textContent).toBe(TARGET_TITLE);
expect(linksTo(recordPath(id)).filter((a) => h1.contains(a))).toHaveLength(1);
expect(h1.textContent).not.toContain(id);
expect(h1.textContent).not.toContain(FLOW_SOURCE);
});
Expand Down Expand Up @@ -375,8 +377,12 @@ describe('the served request page draws the four reference states the sheet draw
expect(tab?.textContent).not.toContain(id);
// …and nowhere on the page, the H1 included: the counterpart of the sheet's
// drawer case "tombstones the same reference in the drawer — not one click
// deeper" (`ApprovalsInboxPage.tombstone.test.tsx`, objectui#7108).
expect((await pageTitle()).textContent).toBe(FLOW_LABEL);
// deeper" (`ApprovalsInboxPage.tombstone.test.tsx`, objectui#7108). The H1
// names the record by the title the get served, as plain text: the page
// never read it, so it links nowhere (objectstack#35415).
const h1 = await pageTitle();
expect(h1.textContent).toBe('INV-3030');
expect(h1.querySelectorAll('a[href]')).toHaveLength(0);
expect(document.body.innerHTML).not.toContain(id);
});

Expand Down
15 changes: 12 additions & 3 deletions ui/packages/app-shell/src/views/DeclaredActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,16 @@ const DeclaredActionButton: React.FC<{
* header row.
*/
headerTone?: 'primary' | 'secondary';
/**
* A declared `danger` lever drawn as an outline button in the destructive
* text colour, the header group's secondary face, instead of a filled one
* (objectstack#35415): beside a filled `primary` decision, the approval
* must read as the page's strongest button, not the rejection.
*/
outlineDanger?: boolean;
/** The reject dialog requires its `comment` (`requireRejectReason`). */
requireReason?: boolean;
}> = ({ action, objectName, record, asMenuItem = false, onDrawn, fill = false, headerTone, requireReason = false }) => {
}> = ({ action, objectName, record, asMenuItem = false, onDrawn, fill = false, headerTone, outlineDanger = false, requireReason = false }) => {
const { execute } = useAction();
const [loading, setLoading] = useState(false);
// Localize the SERVER-DECLARED strings through the `_actions.<name>.*`
Expand Down Expand Up @@ -657,9 +664,10 @@ const DeclaredActionButton: React.FC<{
// one. Overrides take one warning treatment instead, the SAME for approve /
// reject / reassign — the point being that it reads as "override", not as
// "the decision you were assigned".
const secondaryDanger = declaredVariant === 'danger' && (headerTone === 'secondary' || outlineDanger);
const variant = isOverride
? 'outline'
: headerTone === 'secondary'
: headerTone === 'secondary' || secondaryDanger
? 'outline'
: declaredVariant === 'primary'
? 'default'
Expand Down Expand Up @@ -760,7 +768,7 @@ const DeclaredActionButton: React.FC<{
className={cn(
headerTone ? 'h-11 sm:h-7' : 'h-11 sm:h-9',
fill && (disabledReason ? 'w-full sm:w-auto' : 'flex-1 sm:flex-none'),
headerTone === 'secondary' && declaredVariant === 'danger' && !isOverride
secondaryDanger && !isOverride
&& 'text-destructive hover:text-destructive',
isOverride
&& 'border-amber-500/60 text-amber-700 hover:bg-amber-50 hover:text-amber-800 dark:text-amber-400 dark:hover:bg-amber-500/10 dark:hover:text-amber-300',
Expand Down Expand Up @@ -1223,6 +1231,7 @@ const DeclaredActionsToolbar: React.FC<
record={record}
onDrawn={reportDrawn}
fill
outlineDanger
/>
))}
{decisionOthers.map((action) => (foldDecisionOthers ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup } from '@testing-library/react';
import { I18nProvider, LocalizationProvider } from '@object-ui/i18n';
import { isMachineLocale, recordLocaleArgumentsAsync } from '@object-ui/test-support';
import { formatDateTime } from '@object-ui/core';
import type { ApprovalRequestLite } from '../hooks/useRecordApprovals';

vi.mock('@object-ui/auth', async (importOriginal) => ({
Expand Down Expand Up @@ -93,12 +94,13 @@ async function timelineUnder(locale: string): Promise<string> {
describe('approval timeline times follow the declared session locale (objectui#9909)', () => {
it('says the de-DE face under a de-DE session', async () => {
const text = await timelineUnder('de-DE');
expect(text, `got: ${text}`).toMatch(/4\.3\.2020, 15:30:00/);
// The compact datetime face every `datetime` cell draws (objectstack#35415).
expect(text, `got: ${text}`).toMatch(/4\.3\.2020 3:30\spm/);
});

it('keeps its en face under an en session', async () => {
const text = await timelineUnder('en');
expect(text, `got: ${text}`).toMatch(/3\/4\/2020, 3:30:00\sPM/);
expect(text, `got: ${text}`).toMatch(/3\/4\/2020 3:30\spm/);
});

/** ⭐ THE PIN: the runner's own locale cannot satisfy it. */
Expand All @@ -114,3 +116,11 @@ describe('approval timeline times follow the declared session locale (objectui#9
expect(calls.filter(isMachineLocale), 'these call sites formatted in the machine locale').toEqual([]);
});
});

describe('approval timeline times read the record page\'s one datetime face (objectstack#35415)', () => {
it('a zh-CN session reads the compact face a `datetime` field draws: no seconds, the 12-hour clock', async () => {
const text = await timelineUnder('zh-CN');
expect(text, `got: ${text}`).toContain(formatDateTime(STORED, { locale: 'zh-CN', style: 'compact' }));
expect(text, `got: ${text}`).not.toMatch(/15:30:00/);
});
});
Loading
Loading