Skip to content

Commit c6075a7

Browse files
feat(console): an administrator configures the record page's tabs in place (#36499, PR 1 of 2) (#36583)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Wq5utqEodnDCBh6heq37AG)_ Refs #36499 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:系统管理员在自建应用的记录详情页「…」里多了「配置页签」,可就地拖动排序、隐藏/恢复、改名后保存,所有人看到新的默认页签顺序;普通成员看不到入口。 - 为什么做:属于「记录页就地配置」专题的第一步(本卡第一个合并请求),替管理员省去进 Studio 改对象定义的绕路。 - 出错会怎样:只影响自建应用对象的记录页页签排列;保存写成对象的已发布定义,管理员可再次进入配置恢复原样,读者自己的拖动顺序不受影响。 - 要你做什么:无。 ## What changes On the desktop full record page of an object whose package is writable, a workspace administrator who may author metadata gets 「Configure tabs」 in the record's 「…」 menu. It is not offered on a phone, in a drawer or a pane, or on an authored record page. Choosing it puts the page in an edit state in place: - A bar across the top, with 「Configure tabs」 on the left and 「Cancel」 and 「Save」 on the right. It has the design-mode bar's look. The design-mode shell is reused unchanged: no change to DesignModeBar, designMode.tsx or unsavedEdits. - The tab row becomes an editor. The administrator can: - drag tabs to reorder them (dnd-kit, keyboard too); - hide a tab into a 「Hidden」 area and show it again from there; - rename a tab; - hide the attachments tab. - Some tabs cannot be moved, hidden or renamed in the editor. They are shown with a lock: - 审批 and 动态, which the page always draws last; - lists another package brings. - 「Adjust field groups」 opens the object in Studio. - The record stays on screen as the preview, in the draft's order. The reader's own arrangement is set aside while the edit state is open. - 「Cancel」 writes nothing. - Leaving with a change held asks first, through the existing unsaved-edits seam. 「Save」 writes the object's `relatedLists` over the object **as stored** (the layered read with `packageId`), never the served object. It saves a draft with the first-write pin (`ifNoneMatch: '*'`) into the object's own package, then publishes it. A refused publish resets that draft, and a pending Studio draft is refused with its own sentence. This mirrors the design-mode menu's save. All writes go through one seam, `resolveRecordTabsSaveTarget`, which returns `{kind: 'package', packageId}` for a writable package and `null` for anything else. PR 2 adds the installed `.custom` target there. How the list is written: - A tab is hidden by leaving it out of the object's own list. - A rename becomes the entry's `label`. - The stored entry's `columns` are kept. - Entries the editor does not arrange (审批 / 动态 names, a list it does not offer) are kept after the entry they followed. - If every tab is hidden, the save still writes a declared list (`['sys_approval_request','sys_activity']`). An empty list would read as "none declared". Renaming follows the design-mode menu's rule (ruling (4) of #36363): only in the deployment's default language, and only where the shown name is the stored one. Files: - `ui/packages/app-shell/src/views/recordTabsConfig.ts`: the pure model (catalog, draft, edits, the entries a save writes, the preview). - `recordTabsConfigSave.ts`: the write. - `RecordTabsConfig.tsx`: the hook, bar and editor. - `recordTabsConfigIo.tsx`: the metadata client, stored list and default language. It sits behind `React.lazy` so the record page's module graph does not gain the metadata client's module. - `RecordDetailView.tsx`: wiring only. - `@object-ui/plugin-detail` `RecordPageColumns` takes an optional `tabRowEditor`, drawn in the tab row's place. - `designMode.recordTabs` keys in all eleven console locales. zh-Hant is generated from zh-Hans. ## Tests New, named for the card: - `ui/packages/app-shell/src/views/__tests__/recordTabsConfig-36499.test.ts` (11): the catalog, the opening draft, edits, the entries a save writes, the preview, and item 6. Item 6 checks that the admin order is the new default, that a reader's dragged order stays over it, and that `EMPTY_RELATED_ARRANGEMENT` (「恢复默认顺序」) gives the admin order. - `.../recordTabsConfigSave-36499.test.ts` (5): the stored object, not the served one; the pinned draft then publish; a pending draft refused; a refused publish resets; a read-only or unlisted package refused before anything is read; the seam. - `.../RecordTabsConfig-36499.test.tsx` (8): the offered gate; the edit state; another package's list fixed; hide → Hidden → restore and Cancel writes nothing; drag + Save writes once; the leave prompt; rename open and closed. - `ui/packages/components/src/__tests__/page-header-overflow-close-36499.test.tsx` (2): an entry that finished on the click closes the 「…」 menu; one still running keeps it open and busy until it settles. No existing test was changed. Patch round (CI at a9fc3dd): - Type Check UI `check:spec-symbols`: the local `ObjectLike` and `Session` collided with spec exports; renamed `RecordTabsObjectDef` and `RecordTabsSession`. - Lint UI `object-ui/no-synthetic-event-trigger` and Test UI 1/16 `adr0054-ratchet`: the Escape the entry dispatched is gone; page:header closes the menu itself (above). - Test UI 11/16 `consoleTopBar.height-12639`: the chrome offset under the tab bar is spelled as the bar's 3rem plus the page's own gap, not `top-14`. - Test UI 4/16 `recordTabsConfigSave-36499`: the `unit` project runs with `isolate: false`, so the test's module mock of the assistant bus missed a module another file had loaded; the refresh announcement is now one of the save's doors. <details><summary>Test runs (final head a9fc3dd unless noted)</summary> - Run under `os-verify-lock` on 745f057, before the lazy split: `vitest run packages/i18n/ plugin-detail RecordPageColumns* app-shell RecordDetailView.* + the three new files` gave 21 failed files. - 20 `RecordDetailView.*` suites failed with "Cannot access 'authFetchSpy' before initialization". The new import chain reached `metadataClientFactory`, which mints its fetch at module load. - zh-Hant was stale. - After the fix (a06a827), the same command under the lock: `Test Files 212 passed (212) · Tests 2898 passed | 13 skipped`, then `@object-ui/app-shell type-check`, VERDICT command-exit 0. - Final head, under the lock: the three new files + `RecordDetailView.recordOpen*`: `Test Files 7 passed (7) · Tests 62 passed (62)`, plus `@object-ui/app-shell type-check`, VERDICT command-exit 0. - Dependency closure `pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' build` after merging origin/main: VERDICT command-exit 0. </details> ## Acceptance notes - **The entry's place in 「…」.** 「Configure tabs」 is the first of the record's own entries. It comes after 「Refresh」, which the record header puts first; measured menu: Refresh, Configure tabs, Share, Change Owner, Delete. A literal first place needs a change in `@object-ui/components` page:header and `@object-ui/react`, outside this card's file surface. This is raised as an open question in the report. - **「Adjust field groups」** opens the object in Studio's Data pillar (`/studio/PKG/data?surface=object:NAME`), on its Records tab. Studio has no URL address for the Form tab yet; #36505 adds it. - **Approvals / activity cannot be hidden** on a self-built object without a spec change (the spec refuses object-form built-in entries, and an own list cannot leave them out). They are shown fixed. Attachments and the object's own related lists hide faithfully by omission. - **Undeclared to declared.** Saving an object that had no `relatedLists` writes one, so a relationship added later is not shown by default. That is the spec's semantics for a declared list. - **The 「…」 menu now closes after an entry that finished on the click.** `page:header` (`@object-ui/components` containers.tsx) prevented the menu's close on every select, so an in-place change left it open over the editor (measured). Now an entry still running (it returned a pending promise) keeps the menu open with its row busy, as before; one that finished closes it, as Refresh does. Pinned by `ui/packages/components/src/__tests__/page-header-overflow-close-36499.test.tsx`. - Only the desktop full page offers the entry. Installed (read-only) packages are not offered it yet (PR 2). ## Verification Gates: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 41 families. Each one ran on the final head and exited 0, and `--ran` reconciles 41 derived, 41 run, 0 NOT-MEASURED (a derived zero). Browser: I booted `examples/app-showcase` (`objectstack dev --ui --seed-admin`, own port and DB) with the console rebuilt from this branch. Setup: - A Studio-style writable package `com.qa.tabs` with `qtab_account` and three lookup children (Contacts, Deals, Tickets), each with one record. - A plain member (admin create-user, then a read permission set assigned). Measured: - **Menu.** The admin's 「…」 reads Refresh, Configure tabs, Share, Change Owner, Delete. The member's reads Refresh, Share. - **Entering the edit state.** Choosing the entry closes the menu and shows the bar and editor, at 1280 and 1440. - **Hide and restore.** Hiding Tickets moves it to 「Hidden」, and Show brings it back. - **Cancel.** It sends no metadata write (request log empty). - **Leaving with a change held.** Leaving to Projects prompts "Leave without saving? Your tab changes will be lost.", and dismissing the prompt stays on the page. - **Reorder, rename, save.** Dragging Deals left (keyboard) and renaming Contacts to People, then Save, sends `PUT /api/v1/meta/object/qtab_account?mode=draft&package=com.qa.tabs` then `POST …/publish`. After a reload the order is Deals, People, Tickets, Attachments, Activity, and the member sees the same order. - **A reader's own order.** - The member moved People left; then the admin hid Tickets and saved. - The member kept their own order: People, Deals, Attachments, Activity. - 「恢复默认顺序」 gave the admin order: Deals, People, Attachments, Activity. - **Showing a hidden tab again.** The admin then showed Tickets again and saved; the order read back as Deals, People, Tickets, Attachments, Activity. - **Field groups.** 「Adjust field groups」 lands on `/_console/studio/com.qa.tabs/data?surface=object%3Aqtab_account`. **2-minute check:** sign in as an admin on a self-built object's record, open 「…」 and choose 「Configure tabs」. Expect a purple bar on top and the tab row turned into draggable chips with a 「Hidden」 line under them. Screenshots (`/mnt/project-files/objectstack-seat2/shots/36499/`): - `01-admin-record-menu-entry-1280.png`, `01-admin-record-menu-entry-1440.png`: the entry in 「…」 - `02-admin-edit-state-1280.png`, `02-admin-edit-state-1440.png`: the edit state - `03-admin-hidden-area-1280.png`: Tickets in 「Hidden」 - `04-admin-reordered-renamed-1280.png`: Deals moved first, Contacts renamed People - `05-admin-after-save-reload-1280.png`: after save + reload - `06-admin-field-groups-studio-1280.png`: 「Adjust field groups」 in Studio - `08-member-menu-no-entry-1280.png`: the member's 「…」 without the entry - `09-member-own-order-kept-1280.png`: the member's own order kept over the new default - `10-member-restore-default-order-1280.png`: 「Restore default order」 - `11-member-admin-order-1280.png`: the admin order after restoring Files to read first, by risk: 1. `ui/packages/app-shell/src/views/recordTabsConfig.ts`, `recordTabsEntries`: what a save writes, including keeping entries the editor does not arrange. 2. `ui/packages/app-shell/src/views/recordTabsConfigSave.ts`, `saveRecordTabs`: the stored read, pinned draft, publish, reset. 3. `ui/packages/app-shell/src/views/RecordDetailView.tsx`: the preview object fed to the derivation and page schema, and the reader arrangement set aside while editing. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmP8GZoB2rUETxwNEDv)_ <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmP8GZoB2rUETxwNEDv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 42b4060 commit c6075a7

23 files changed

Lines changed: 2160 additions & 14 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/plugin-detail': patch
4+
'@object-ui/i18n': patch
5+
'@object-ui/components': patch
6+
---
7+
8+
feat(console): an administrator configures the record page's tabs in place, from the record's 「…」
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: none
12+
13+
On the record page of an object whose package is writable (an object of a self-built app), a workspace administrator who may author metadata finds 「Configure tabs」 among the record's own entries in its 「…」 (desktop full page only; never on a phone, in a drawer or a pane, or on a page its author composed). Chosen, the page enters an edit state in place: a bar across the top with 「Configure tabs」, 「Cancel」 and 「Save」, in the design mode's bar's look, and the tab row turns into an editor. The record stays on screen as the preview, in the administrator's default order.
14+
15+
In the edit state the related tabs are dragged to a new order, hidden into a 「Hidden」 area and shown again from it, and renamed; the attachments tab can be hidden; 审批 and 动态, which the page always draws last, are shown fixed, and so is a list another package brings. 「Adjust field groups」 opens the object in Studio. 「Cancel」 drops the changes and writes nothing; leaving the page with a change held asks first.
16+
17+
「Save」 writes the object's `relatedLists` over the object as stored (never as served), as a draft with the first-write pin, and publishes it, so everyone sees the new default order, names and hidden tabs. An object's own `relatedLists` hides a tab by leaving it out; an entry the editor does not arrange (a 审批 / 动态 name, a list it does not offer) is kept. A reader's own dragged order still lays over the new default, and 「Restore default order」 returns them to it. A tab is renamed only in the app's source language, where its shown name is its stored one, the design-mode menu's rule.
18+
19+
New language-pack keys under `designMode.recordTabs` in all eleven console locales. `RecordPageColumns` takes an optional `tabRowEditor`, drawn in the tab row's place. Objects of installed (read-only) packages are not offered the entry yet.
20+
21+
`page:header`: a `⋯` entry that finished on the click (it returned no pending promise) now closes the menu, as Refresh does; an entry still running keeps the menu open with its row busy until it settles, as before.

‎ui/packages/app-shell/src/views/RecordDetailView.tsx‎

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { SkeletonDetail } from '../skeletons/index.js';
3131
import { ManagedByBadge, useManagedByNote } from '../components/ManagedByBadge.js';
3232
import { isSetupAppSegment } from '../console/setupApp.js';
3333
import { authoredBodyTableIds, deriveRelatedLists } from '../utils/deriveRelatedLists.js';
34+
import { RECORD_TABS_CONFIG_ACTION, useRecordTabsConfig } from './RecordTabsConfig.js';
3435
import { pruneUnregisteredRecordPageObjects, recordPageChildObjects } from './recordPageChildObjects.js';
3536
import { stripDiscussionNodes, hasExplicitAttachments, hasExplicitApprovals } from '../utils/pageSchemaIntrospect.js';
3637
import { ActionConfirmDialog, type ConfirmDialogState } from './ActionConfirmDialog.js';
@@ -904,6 +905,9 @@ function ApprovalGroupBeacon({ onHosted }: { onHosted: (update: (n: number) => n
904905
return null;
905906
}
906907

908+
/** The reader's arrangement is not written while the tab configuration previews the default (objectstack#36499). */
909+
const ignoreArrangementChange = (): void => {};
910+
907911
export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverride, recordIdOverride, embedded }: RecordDetailViewProps) {
908912

909913
const params = useParams<{
@@ -2585,15 +2589,35 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
25852589
// `resolveRecordHeaderActionGates(objectDef, perms)`: the affordance-to-grant
25862590
// map asks both itself (objectui#12082), so this view no longer threads
25872591
// either one by hand.
2592+
// objectstack#36499 — 「Configure tabs」: an administrator arranges this
2593+
// object's record-page tabs in place. While its edit state is on, the page
2594+
// is drawn from the object with the draft's `relatedLists`
2595+
// (`tabsConfig.previewObject`), the preview of what Save writes.
2596+
const canReadChild = useMemo(
2597+
() => (permissionsLoaded ? (name: string) => canOnObject(name, 'read') : undefined),
2598+
[permissionsLoaded, canOnObject],
2599+
);
2600+
const tabsConfig = useRecordTabsConfig({
2601+
objectDef,
2602+
objects,
2603+
enabled: !embedded && !phone && pageColumnsEligible,
2604+
canRead: canReadChild,
2605+
titleOf: (list) => {
2606+
if (list.title) return list.title;
2607+
const childDef = objects.find((o: any) => o.name === list.childObject);
2608+
return childDef ? servedObjectPluralLabel(childDef, language, objectPluralLabel, list.childLabel) : list.childLabel;
2609+
},
2610+
});
2611+
const tabsObjectDef = tabsConfig.previewObject ?? objectDef;
25882612
const childRelations = useMemo(
2589-
() => deriveRelatedLists(objectDef, objects, {
2613+
() => deriveRelatedLists(tabsObjectDef, objects, {
25902614
canRead: permissionsLoaded ? (name) => canOnObject(name, 'read') : undefined,
25912615
// A related list is a list of the child's records, so the multi-FK
25922616
// title it composes names it with the plural, as the single-FK title
25932617
// below does (objectui#11733).
25942618
listLabel: (child) => servedObjectPluralLabel(child, language, objectPluralLabel, child.name),
25952619
}),
2596-
[objectDef, objects, canOnObject, permissionsLoaded, objectPluralLabel, language],
2620+
[tabsObjectDef, objects, canOnObject, permissionsLoaded, objectPluralLabel, language],
25972621
);
25982622

25992623
// [objectui#12244] A write to a CHILD re-reads this record, in place.
@@ -5307,6 +5331,22 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
53075331
: onEdit({ id: pureRecordId }, objectName)),
53085332
} as any);
53095333
}
5334+
// objectstack#36499 — 「Configure tabs」, the first of the host's entries
5335+
// in the `⋯`, for an administrator who may arrange this object's tabs
5336+
// (`useRecordTabsConfig`'s gate: never on a phone, a drawer or a pane).
5337+
if (tabsConfig.offered && !tabsConfig.active && !recordEditState) {
5338+
items.push({
5339+
name: RECORD_TABS_CONFIG_ACTION,
5340+
label: t('designMode.recordTabs.entry', { defaultValue: 'Configure tabs' }),
5341+
icon: 'panels-top-left',
5342+
type: 'script',
5343+
locations: ['record_header'],
5344+
variant: 'outline',
5345+
order: 101,
5346+
component: 'action:menu',
5347+
onClick: () => tabsConfig.enter(),
5348+
} as any);
5349+
}
53105350
// The record's favorites control is the star beside the record's name
53115351
// (objectstack#36246), drawn by `page:header` from the record context
53125352
// below, so the `⋯` holds no second entry. A print page draws no
@@ -5550,7 +5590,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
55505590
: null;
55515591
const composedPage = assignedPage
55525592
? effectivePage
5553-
: buildDefaultPageSchema(objectDef as any, {
5593+
: buildDefaultPageSchema(tabsObjectDef as any, {
55545594
sections: synthParts.sections,
55555595
headerActions: synthParts.headerActions,
55565596
related: synthParts.related,
@@ -6004,6 +6044,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
60046044
<RecordHeaderStateContext.Provider value={recordHeaderState}>
60056045
<RecordReadReportContext.Provider value={objectName === SYS_APPROVAL_REQUEST_OBJECT ? reportRecordRead : null}>
60066046
<div ref={setPageRootEl} className="h-full bg-background overflow-hidden flex flex-col relative" data-record-page-root="">
6047+
{tabsConfig.bar}
60076048
{pageBar}
60086049
{/* In a pane, the record's ⊟ goes into the pane's own top bar. */}
60096050
{embedded && paneBar && <RecordPaneBarToggles>{panelToggles}</RecordPaneBarToggles>}
@@ -6016,7 +6057,15 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
60166057
'absolute right-2 sm:right-4 z-50 flex items-center gap-2',
60176058
// Under a phone's one 44 px bar row; in a pane, over the page's
60186059
// top-right corner, level with its first row (objectstack#35745).
6019-
pageBar ? 'top-12' : headerBarForRecord ? 'top-3' : 'top-2 sm:top-4',
6060+
// While the tab configuration's bar is drawn: its 48 px (3rem)
6061+
// plus the page's own top-2 / sm:top-4 gap under it.
6062+
pageBar
6063+
? 'top-12'
6064+
: tabsConfig.bar
6065+
? 'top-[calc(3rem+0.5rem)] sm:top-[calc(3rem+1rem)]'
6066+
: headerBarForRecord
6067+
? 'top-3'
6068+
: 'top-2 sm:top-4',
60206069
)}
60216070
>
60226071
{sharedChrome}
@@ -6327,8 +6376,11 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
63276376
detailsWidth={detailsWidth}
63286377
onDetailsWidthChange={setDetailsWidth}
63296378
onShownTabChange={setShownRecordTab}
6330-
relatedArrangement={relatedArrangement}
6331-
onRelatedArrangementChange={setRelatedArrangement}
6379+
// objectstack#36499 — the edit state previews the
6380+
// default order, the reader's own arrangement set aside.
6381+
relatedArrangement={tabsConfig.active ? EMPTY_RELATED_ARRANGEMENT : relatedArrangement}
6382+
onRelatedArrangementChange={tabsConfig.active ? ignoreArrangementChange : setRelatedArrangement}
6383+
tabRowEditor={tabsConfig.editor ?? undefined}
63326384
enlargedRelated={enlargedRelatedParam}
63336385
onEnlargeRelated={openEnlargedRelated}
63346386
onCloseEnlargedRelated={closeEnlargedRelated}

0 commit comments

Comments
 (0)