From f7a6feedf436ef4c7fe129c8d6d04af2bd30ebb9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 03:29:27 +0000 Subject: [PATCH 1/2] fix(plugin-detail): the laid-out record page draws one approval band by its first drawing details body The details column of the laid-out record page now wraps its nodes in ApprovalBandOnceScope, the rule a page drawn as written already uses, so a first record:details that draws no band (withheld by requiredPermissions, or drawing its own header) leaves the band to the next part instead of taking it off the page. ApprovalBandContext, which only the per-part suppression read, is removed. Pins the page:tabs fallback through the real renderers. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oLLK7uoxp33riiBJL --- ui/packages/plugin-detail/src/DetailView.tsx | 21 ++-- .../plugin-detail/src/RecordPageColumns.tsx | 24 ++-- ...DetailView.approvalBandOnce-35484.test.tsx | 88 +++++++++++++- .../src/__tests__/RecordPageColumns.test.tsx | 107 +++++++++++++++++- .../plugin-detail/src/defaultRecordPage.ts | 45 +++----- 5 files changed, 218 insertions(+), 67 deletions(-) diff --git a/ui/packages/plugin-detail/src/DetailView.tsx b/ui/packages/plugin-detail/src/DetailView.tsx index 4c410ca82b2..e5066e693a4 100644 --- a/ui/packages/plugin-detail/src/DetailView.tsx +++ b/ui/packages/plugin-detail/src/DetailView.tsx @@ -37,7 +37,7 @@ import { } from 'lucide-react'; import { DetailSection } from './DetailSection'; import { EmptySectionsFold, EmptySectionsLine } from './EmptySectionsFold'; -import { ApprovalBandContext, EmptySectionsLineContext, useApprovalBandOnce, useDefaultRecordPage } from './defaultRecordPage'; +import { EmptySectionsLineContext, useApprovalBandOnce, useDefaultRecordPage } from './defaultRecordPage'; import { DetailTabs } from './DetailTabs'; import { SectionGroup } from './SectionGroup'; import { HeaderHighlight } from './HeaderHighlight'; @@ -327,11 +327,9 @@ export const DetailView: React.FC = ({ // approval band below is live, per-viewer workflow state, not document // content, so it does not print. const isPrintPage = usePrintPage() !== null; - // objectstack#35253 — `false` on every details part of a split default page - // but the first: the approval band is the record's, drawn once per page. - // objectstack#35483 / objectstack#35484 — and on a page drawn as written, - // the first body to reach the band's place draws it (`ApprovalBandOnceScope`). - const drawsApprovalBand = React.useContext(ApprovalBandContext); + // objectstack#35253, objectstack#35483, objectstack#35484 — the approval + // band is the record's, drawn once per page: under a page's + // `ApprovalBandOnceScope` the first body to reach the band's place draws it. const approvalBandOnce = useApprovalBandOnce(); // objectstack#27055, objectstack#35019 — a record page's details body folds // its entirely empty sections into one line (`EmptySectionsLine`): every @@ -1757,12 +1755,11 @@ export const DetailView: React.FC = ({ status field through `record:details`, the way `record:path` leaves the current stage to it. - objectstack#35253 — and once per page: a default page split around a - body table draws it on its first details part only - (`ApprovalBandContext`), and on a page drawn as written by its - first details body (`ApprovalBandOnceScope`). */} - {inlineEdit && schema.showHeader === false && !isPrintPage && drawsApprovalBand && approvalBandOnce.mark} - {inlineEdit && schema.showHeader === false && !isPrintPage && drawsApprovalBand && approvalBandOnce.draws && (() => { + objectstack#35253 — and once per page: under the page's + `ApprovalBandOnceScope`, by the first details body that reaches + this place (objectstack#35483, objectstack#35484). */} + {inlineEdit && schema.showHeader === false && !isPrintPage && approvalBandOnce.mark} + {inlineEdit && schema.showHeader === false && !isPrintPage && approvalBandOnce.draws && (() => { // Two independent facts, not one (objectui#2902): // // isPending — an approval is running on this record. diff --git a/ui/packages/plugin-detail/src/RecordPageColumns.tsx b/ui/packages/plugin-detail/src/RecordPageColumns.tsx index 94bc0825acc..bd25fe5c94a 100644 --- a/ui/packages/plugin-detail/src/RecordPageColumns.tsx +++ b/ui/packages/plugin-detail/src/RecordPageColumns.tsx @@ -23,7 +23,7 @@ import { } from './synth/recordPageColumns'; import { useDetailTranslation } from './useDetailTranslation'; import { RecordBodyTablesContext, RelatedEnlargeContext, RelatedListEnlargedContext } from './relatedListCompact'; -import { ApprovalBandContext, DefaultRecordPageContext, DetailsColumnCapContext } from './defaultRecordPage'; +import { ApprovalBandOnceScope, DefaultRecordPageContext, DetailsColumnCapContext } from './defaultRecordPage'; import { RECORD_TAB_OVERVIEW, RecordTabRow, type RecordTab, type RecordTabArrangeEdit } from './RecordTabRow'; import { RECORD_TAB_APPROVALS, @@ -243,22 +243,16 @@ function drawNodes(nodes: any[]): React.ReactNode { /** * The details column's nodes (objectstack#35253): the synthesized page splits * its details around a body table, one `record:details` per run of sections, - * and the record's approval band is drawn by the FIRST part alone — above the - * table — so the page shows one band, not one per part. A context provider - * adds no DOM, so the column's siblings stay siblings (`drawNodes`). + * and the record's approval band is drawn once per page — by the first details + * body that reaches the band's place (`ApprovalBandOnceScope`), above the + * table. objectstack#35483 / objectstack#35484 — the same rule as a page drawn + * as written: a first `record:details` that draws no body (withheld by its + * `requiredPermissions`, or drawing its own header) leaves the band to the next + * part instead of taking it off the page. A context provider adds no DOM, so + * the column's siblings stay siblings (`drawNodes`). */ function drawDetailsNodes(nodes: any[]): React.ReactNode { - const firstDetails = nodes.findIndex((node) => node?.type === 'record:details'); - return nodes.map((node, index) => { - const key = (node && typeof node === 'object' && node.id) || index; - const drawn = ; - if (node?.type !== 'record:details' || index === firstDetails) return drawn; - return ( - - {drawn} - - ); - }); + return {drawNodes(nodes)}; } const LINE_BUTTON = diff --git a/ui/packages/plugin-detail/src/__tests__/DetailView.approvalBandOnce-35484.test.tsx b/ui/packages/plugin-detail/src/__tests__/DetailView.approvalBandOnce-35484.test.tsx index 6911bcbcb1c..8bac0a4a8ea 100644 --- a/ui/packages/plugin-detail/src/__tests__/DetailView.approvalBandOnce-35484.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/DetailView.approvalBandOnce-35484.test.tsx @@ -16,15 +16,24 @@ * still reads editable, and a first node that draws no band leaves the band * to the next. Measured on the body the `record:details` block mounts * (`showHeader: false`, inline edit on); the host wiring is pinned in - * `app-shell/src/views/RecordDetailView.approvalBandOnce-35484.test.tsx`. + * `app-shell/src/views/RecordDetailView.recordOpenRequests-12701.test.tsx` + * (an authored page, drawn by the same host branch as the tabs fallback). + * The second describe draws the synthesized page's `page:tabs` fallback + * through the real renderers (objectstack#35483). */ import * as React from 'react'; -import { describe, it, expect, afterEach } from 'vitest'; -import { render, screen, cleanup } from '@testing-library/react'; -import { InlineEditProvider } from '@object-ui/react'; +import { describe, it, expect, afterEach, vi } from 'vitest'; +import { render, screen, cleanup, waitFor } from '@testing-library/react'; +import { InlineEditProvider, RecordContextProvider, SchemaRenderer } from '@object-ui/react'; +import '../index'; import { DetailView } from '../DetailView'; import { ApprovalBandOnceScope } from '../defaultRecordPage'; +import { buildDefaultPageColumns } from '../synth/recordPageColumns'; +import { buildDefaultPageSchema } from '../synth/buildDefaultPageSchema'; + +/** `useRecordEditable`'s explain probe, answered with its fail-open 501 (the binding suites do the same). */ +vi.stubGlobal('fetch', (async () => new Response(null, { status: 501 })) as unknown as typeof globalThis.fetch); afterEach(cleanup); @@ -97,3 +106,74 @@ describe('one approval band on a page drawn as written (objectstack#35484, objec expect(container.querySelectorAll('[data-approval-band-mark]').length).toBe(2); }); }); + +/** + * objectstack#35483 — the synthesized page that falls back to its `page:tabs` + * strip. `buildDefaultPageColumns` lays out every page the synthesizer writes + * on its own; a slotted page that places a `page:tabs` node in a strip slot + * (`highlights` here) carries two strips, which the partition cannot read, so + * the host draws the page as written, inside `ApprovalBandOnceScope`. Split + * around a body table, its 概览 tab holds two `record:details` parts: drawn by + * the real `record:details` and `page:tabs` renderers, the band is drawn once. + */ +describe('one approval band on the synthesized page\'s page:tabs fallback (objectstack#35483)', () => { + const quote = { + name: 'quote', + fields: { + name: { type: 'text', label: 'Name', group: 'basic' }, + terms: { type: 'textarea', label: 'Terms', group: 'terms' }, + }, + fieldGroups: [{ key: 'basic' }, { key: 'lines', relatedList: 'quote_line_item' }, { key: 'terms' }], + }; + const SECTIONS = [ + { name: 'basic', label: 'Basic', fields: ['name'] }, + { name: 'terms', label: 'Terms', fields: ['terms'] }, + ]; + const LINES = { objectName: 'quote_line_item', relationshipField: 'quote', title: 'Lines', isPrimary: true }; + const STRIP_TABS = { type: 'page:tabs', properties: { items: [{ label: 'Extra', value: 'extra', children: [] }] } }; + const fallback = (related: unknown[]) => + buildDefaultPageSchema(quote as any, { sections: SECTIONS as any, related: related as any, slots: { highlights: [STRIP_TABS] } as any }); + const overviewOf = (page: any) => page.regions[0].components.filter((n: any) => n.type === 'page:tabs').at(-1).properties.items[0].children; + const DATA = { id: 'Q1', name: 'Q-1', terms: 'net 30' }; + const drawLocked = (page: unknown, scoped = true) => + render( + + [], findOne: async () => DATA } as any} + > + {scoped ? : } + + , + ); + const marks = () => document.querySelectorAll('[data-approval-band-mark]'); + + it('the page cannot be laid out, and its overview holds two details parts around the body table', () => { + const page = fallback([LINES]); + expect(buildDefaultPageColumns(page)).toBeNull(); + expect(overviewOf(page).map((n: any) => n.type)).toEqual(['record:details', 'record:related_list', 'record:details']); + }); + + it('two details parts under the host scope: "Locked for approval" once', async () => { + drawLocked(fallback([LINES])); + await waitFor(() => expect(marks()).toHaveLength(2)); + expect(screen.getAllByText('Locked for approval')).toHaveLength(1); + }); + + it('CONTROL: the same page outside the scope draws it on each part (what the scope holds)', async () => { + drawLocked(fallback([LINES]), false); + await waitFor(() => expect(screen.getAllByText('Locked for approval')).toHaveLength(2)); + }); + + it('CONTROL: one details part on the fallback page draws its one band', async () => { + const page = fallback([]); + expect(buildDefaultPageColumns(page)).toBeNull(); + expect(overviewOf(page).map((n: any) => n.type)).toEqual(['record:details']); + drawLocked(page); + await waitFor(() => expect(marks()).toHaveLength(1)); + expect(screen.getAllByText('Locked for approval')).toHaveLength(1); + }); +}); diff --git a/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx b/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx index b986189abb7..bb7bef303b5 100644 --- a/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx @@ -15,10 +15,10 @@ * column beside the other tabs on a wide full page (objectstack#35890), and * that no width draws the right rail of summary cards any more. * - * One describe (objectstack#35253) opts each `record:details` stub into - * mounting the `DetailView` the real block mounts (`showHeader: false`, - * inline edit on), so the approval band it draws is measured on the laid-out - * page; every other describe keeps the bare stub. + * Two describes (objectstack#35253, objectstack#35483) opt each + * `record:details` stub into mounting the `DetailView` the real block mounts + * (`showHeader: false`, inline edit on), so the approval band it draws is + * measured on the laid-out page; every other describe keeps the bare stub. */ import * as React from 'react'; @@ -30,7 +30,7 @@ import { RecordContextProvider } from '@object-ui/react'; const harness = vi.hoisted(() => ({ /** Set by the objectstack#35253 describe: a `record:details` stub mounts `body`. */ detailBodies: false, - body: null as React.ComponentType | null, + body: null as React.ComponentType<{ schema: any }> | null, /** The content width every element reports (jsdom lays nothing out). */ width: 0, })); @@ -42,7 +42,7 @@ vi.mock('@object-ui/react', async (importOriginal) => { return (
{schema?.properties?.objectName ?? schema?.type} - {Body && } + {Body && }
); }; @@ -428,3 +428,98 @@ describe('RecordPageColumns — the approval band is drawn once per page (object expect(screen.getAllByText('In approval · editable')).toHaveLength(1); }); }); + +/** + * objectstack#35483 / objectstack#35484 — the band is not dropped when the + * FIRST details part draws no body. A slotted page's `details` slot places the + * author's own `record:details` nodes in the laid-out details column; the first + * may draw no band of its own: its `requiredPermissions` withheld (the real + * block draws its insufficient-permissions notice in place of the body, + * `record-blocks.requiredPermissions-gate.test.tsx`) or `showHeader: true` + * (the body draws its own header, and no band). The column draws the band once + * by the first body that reaches its place (`ApprovalBandOnceScope`), so the + * next part draws it. Before, every part after the first was told not to draw + * it and such a page showed no band at all, on a locked record. + */ +describe('RecordPageColumns — a first details part that draws no band leaves it to the next (objectstack#35483, objectstack#35484)', () => { + /** What `record:details` mounts for its node: the notice when withheld, else its body. */ + const PartBody = ({ schema }: { schema: any }) => { + const p = { ...schema, ...(schema?.properties ?? {}) }; + if (Array.isArray(p.requiredPermissions) && p.requiredPermissions.length > 0) { + return

Insufficient permissions to view details.

; + } + return ( + + ); + }; + beforeEach(() => { + harness.detailBodies = true; + harness.body = PartBody; + }); + afterEach(() => { + harness.detailBodies = false; + harness.body = null; + }); + + const quote = { name: 'quote', fields: { name: { type: 'text', label: 'Name' }, terms: { type: 'textarea', label: 'Terms' } } }; + const part = (id: string, props: Record = {}) => ({ + type: 'record:details', + id, + properties: { sections: [{ name: id, label: id, fields: [id === 'first' ? 'name' : 'terms'] }], ...props }, + }); + const slotted = (details: any[]) => buildDefaultPageColumns(buildDefaultPageSchema(quote, { slots: { details } } as any))!; + const drawPage = (columns: ReturnType, approval: { locked?: boolean; approvalPending?: boolean; canEdit?: boolean }) => + render( + + + , + ); + /** The details parts (by node id) whose subtree shows `text`. */ + const partsShowing = (container: HTMLElement, text: string) => + Array.from(column(container, 'details')!.querySelectorAll('[data-node="record:details"]')) + .map((node, index) => ({ node, index })) + .filter(({ node }) => node.textContent?.includes(text)) + .map(({ index }) => index); + + it('the slotted page lays its two details nodes out in the details column', () => { + expect(slotted([part('first'), part('second')]).details.map((n: any) => n.id)).toEqual(['first', 'second']); + }); + + for (const [why, props] of [ + ['withheld by its requiredPermissions', { requiredPermissions: ['quote.audit'] }], + ['drawing its own header', { showHeader: true }], + ] as const) { + it(`a first part ${why}: "Locked for approval" once, on the second part`, () => { + const { container } = drawPage(slotted([part('first', props), part('second')]), { locked: true }); + expect(screen.getAllByText('Locked for approval')).toHaveLength(1); + expect(partsShowing(container, 'Locked for approval')).toEqual([1]); + }); + } + + it('a `lockRecord: false` approval behind a withheld first part reads editable, once — never locked', () => { + drawPage(slotted([part('first', { requiredPermissions: ['quote.audit'] }), part('second')]), { approvalPending: true, locked: false, canEdit: true }); + expect(screen.queryByText('Locked for approval')).toBeNull(); + expect(screen.getAllByText('In approval · editable')).toHaveLength(1); + }); + + it('CONTROL: two drawing parts keep the band on the first, once', () => { + const { container } = drawPage(slotted([part('first'), part('second')]), { locked: true }); + expect(screen.getAllByText('Locked for approval')).toHaveLength(1); + expect(partsShowing(container, 'Locked for approval')).toEqual([0]); + }); + + it('CONTROL: a single slotted details part draws its one band', () => { + drawPage(slotted([part('first')]), { locked: true }); + expect(screen.getAllByText('Locked for approval')).toHaveLength(1); + }); + + it('CONTROL: a single withheld part draws no band and no body (nothing on the page reaches its place)', () => { + drawPage(slotted([part('first', { requiredPermissions: ['quote.audit'] })]), { locked: true }); + expect(screen.queryByText('Locked for approval')).toBeNull(); + expect(screen.getByText('Insufficient permissions to view details.')).toBeTruthy(); + }); +}); diff --git a/ui/packages/plugin-detail/src/defaultRecordPage.ts b/ui/packages/plugin-detail/src/defaultRecordPage.ts index 7844fbf6912..71302241761 100644 --- a/ui/packages/plugin-detail/src/defaultRecordPage.ts +++ b/ui/packages/plugin-detail/src/defaultRecordPage.ts @@ -48,36 +48,21 @@ export function useDefaultRecordPage(): boolean { export const EmptySectionsLineContext = React.createContext(false); /** - * Whether the `DetailView` drawn here draws the record's approval band (the - * "Locked for approval" / "In approval" status chip, its recall lever and its - * tally) when its own header is suppressed (objectstack#35253). - * - * The band is the RECORD's state, so a record page draws it once. The - * synthesized default page splits its details around a body table — one - * `record:details` node per run of sections — and every part used to draw it, - * so the page read as if two locks applied. The laid-out page - * (`RecordPageColumns`) sets `false` around every details part after the - * first, which keeps the band above the body table. Default `true`: a - * standalone `DetailView` and the drawer keep their band, and an authored - * page's details bodies draw one between them ({@link ApprovalBandOnceScope}). Whether the band reads locked or editable is untouched — that is - * `resolveApprovalLock`'s rule (a `lockRecord: false` node is never locked). - * - * Module-internal, the way `EmptySectionsLineContext` is: neither a - * `DetailView` prop nor a `DetailViewSchema` key, and not in the barrel. - */ -export const ApprovalBandContext = React.createContext(true); - -/** - * One approval band per page drawn as written (objectstack#35483, - * objectstack#35484). A page the host draws through one `SchemaRenderer` — an - * authored page, or a synthesized page whose strip cannot be laid out — cannot - * set {@link ApprovalBandContext} per details node, so each `record:details` - * body drew its own band. Under {@link ApprovalBandOnceScope} every body that - * reaches the band's place marks it, and only the FIRST mark in document order - * draws the band: a first node that draws no body leaves no mark, and a - * `lockRecord: false` first node draws its own (editable) band, the page's one. - * The band keeps its recall lever and its tally. Outside a scope every body - * draws its band as before. + * One approval band per record page (objectstack#35253, objectstack#35483, + * objectstack#35484): the band (the "Locked for approval" / "In approval" + * status chip, its recall lever and its tally, drawn by a `DetailView` whose + * own header is suppressed) is the RECORD's state, so a page draws it once, + * however many `record:details` bodies it places. Every page host mounts + * {@link ApprovalBandOnceScope} around its details: the laid-out page around + * its details column (`RecordPageColumns`), and the host around a page drawn + * as written (an authored page, or a synthesized page whose strip cannot be + * laid out). Under the scope every body that reaches the band's place marks + * it, and only the FIRST mark in document order draws the band: a first node + * that draws no body leaves no mark, and a `lockRecord: false` first node + * draws its own (editable) band, the page's one. The band keeps its recall + * lever and its tally. Outside a scope — a standalone `DetailView` (the `detail-view` + * node, an overlay panel) — every body draws its band as before. Whether the band reads locked + * or editable is untouched: that is `resolveApprovalLock`'s rule. */ export interface ApprovalBandOnce { /** Mark a body's band place; returns the unmark. `onChange` re-renders the body when the first mark moves. */ From 02f7053d6ca2a67782caa182ea8af9fd950744b1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 03:39:20 +0000 Subject: [PATCH 2/2] chore(changeset): plugin-detail patch for the approval band on the laid-out page Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oLLK7uoxp33riiBJL --- .changeset/35483-approval-band-once.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/35483-approval-band-once.md diff --git a/.changeset/35483-approval-band-once.md b/.changeset/35483-approval-band-once.md new file mode 100644 index 00000000000..e18b0c813cb --- /dev/null +++ b/.changeset/35483-approval-band-once.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-detail': patch +--- + +fix(plugin-detail): a laid-out record page whose first details block draws no body still shows the approval band + +Clause-②: no +Metadata-protocol: none + +The laid-out record page draws the record's approval band ("Locked for approval" / "In approval · editable", with its recall lever and tally) once per page. It used to give the band to the first `record:details` node of the details column and tell every later one not to draw it, so on a slotted page whose `details` slot puts first a `record:details` the reader may not see (its `requiredPermissions` withheld) or one that draws its own header (`showHeader: true`), a locked record showed no band at all. The details column now draws the band by the first details body that reaches its place, the rule a page drawn as written already follows: the next part draws it. Every other page reads as before, the band stays above a body table, and whether the band reads locked or editable (a `lockRecord: false` approval node) is unchanged.