Skip to content

Commit d763ee7

Browse files
fix(console): record tabs join the design mode; list draft actions read Reset / Update view (#37085)
repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW Fixes #36737 Clause-②: no Metadata-protocol: none ## 维护者速读 - 管理员在记录页进入「设计布局」后,页签行直接变成可拖动、隐藏、改名的编辑器,页面顶部只有一条紫色横条;「⋯」里不再有「配置页签」。列表改了排序等之后,右侧按钮读「重置 / 更新视图」;当前视图不能被更新时(如安装包自带的视图),按钮读「另存为我的视图」,手机上读「保存」。 - 属于「设计模式」史诗:按维护者「照 Twenty 归类」的裁决,消除记录页两条保存横条叠在一起的问题。 - 页签草稿和菜单、页头按钮一起由设计模式的「保存」写入、「取消」丢弃;保存失败时设计模式会提示并保留草稿,不会写坏数据,合并后可整体回滚。 - 无 ## What changes - **Record tabs join the design mode.** `useRecordTabsConfig` (`ui/packages/app-shell/src/views/RecordTabsConfig.tsx`) no longer has an entry or a bar of its own. While the design mode is on, on a record page where the old gates hold, the tab row is `RecordTabsEditor` in place. The gates are: workspace admin who may author metadata, desktop full page, not a drawer or pane, not an authored page, the customization-door wall on an installed object, and not while the record's own edit state is open (the gate the old ⋯ entry kept). The draft is staged with `useDesignModeChange` under `record-tabs:OBJECT` (one staged change per object, beside `object-pins:OBJECT` and the app menu), so it survives a move to another page of the app. Its `commit` is the existing `saveRecordTabs` (own package `relatedLists`, or the base's paired `.custom` object extension through `saveObjectExtensionArrangement`), so both save paths are unchanged and are now called by the mode's 「保存」. The mode's 「取消」 drops it. An edit back to where the editor opened unstages it. A failed save keeps the draft staged and the mode on, and says why through the mode's own message. The editor's controls stay off until its lazily loaded metadata client has arrived, and while the mode saves. - **Removed:** `RecordTabsConfigBar`, `RECORD_TABS_CONFIG_ACTION` (`sys_configure_tabs`) and its ⋯ item in `RecordDetailView.tsx`, the bar's top offset for the shared chrome, and the tabs' own unsaved-edits guard (the mode's guard covers leaving the app). The Studio gates are now read only while the mode is on, so a record page outside the mode reads no package list for this. - **List draft actions renamed, not gated.** `ListDraftActions` reads 「重置 / 更新视图」 (en: Reset / Update view) by changing the values of the existing keys `console.objectView.draft.discard` and `console.objectView.draft.save` in all eleven packs (zh-Hant regenerated by `gen:zh-hant`). No key is added or removed. - Where the open view cannot take the change (no `onSaveToView`: a view a read-only package ships, or a reader who may not write it), the button carries the save its menu holds, 「另存为我的视图」 (`saveAsMyView`), so it never promises an update it does not offer. - The narrow face (the phone's chip row) reads 「保存」 (`common.save`) in that case. At 375 px the longer name squeezed the view switcher beside it from 76 px to 44 px, down to its count; measured in the browser. - The menu keeps 「保存到这个视图」 where offered and 「另存为我的视图」. - `ObjectView` never gated the draft on the design mode, so there is no refusal to remove. A pin holds that the actions stay live under the mode's bar. - Docs: `layout/designMode.tsx`'s module doc names the record tabs among the staged surfaces and the list's view actions as outside the mode. No `content/docs/**` or `skills/**` page teaches 「配置页签」 as a separate entry (searched both for `Configure tabs` and `配置页签`: zero hits). - The existing ruling at `designMode.tsx` (a dashboard's and a report's editors stay outside the mode and exclude it, #36692) is untouched. The #36363 ruling (4) rename gate in the tabs editor is kept. - `origin/main` is merged in (merge commit, no rebase). The merge touched no file of this diff's own. Files to read first, by risk: 1. `ui/packages/app-shell/src/views/RecordTabsConfig.tsx`, the `useRecordTabsConfig` hook: the staged value carries `packageId`, `mode`, `catalog`, `initial` and `draft`, so the mode's Save can write it from any page of the app. The commit closes over the metadata client captured at the edit. 2. `ui/packages/app-shell/src/views/RecordDetailView.tsx`: the ⋯ item and the bar are removed, and the editor yields to the record's edit state. `tabsConfig.active` now means "the mode is on and this object's tabs may be arranged here". 3. `ui/packages/app-shell/src/views/ListDraftActions.tsx`: the two labels, `saveLabel` and `compactSaveLabel`. Two-minute check: in the showcase app as admin, open an account record and choose 功能展示 ▾ → 设计布局. Expected: one purple bar, a tab row of draggable chips, and no 「配置页签」 under ⋯. On the task list, sort by 截止日期: the button reads 「另存为我的视图」 on the shipped view, and 「更新视图」 on your own view. ## Screenshots Showcase app, admin, zh-CN, per-agent `--fresh` stack, Console from this branch's source. - Account record in the design mode: the tab row is the editor and there is one bar. The object is installed, so the tabs carry 原始包 tags. ![record page in design mode](https://github.com/objectstack-ai/objectstack/blob/3b99443aceda9670b0c2db4630c07d03f53a8e52/screenshots/36737/01-record-design-mode-tab-editor.png?raw=true) - The record's ⋯ in the design mode: 刷新 / 分享 / 更改负责人 / 删除, with no 配置页签. ![record more menu](https://github.com/objectstack-ai/objectstack/blob/3b99443aceda9670b0c2db4630c07d03f53a8e52/screenshots/36737/02-record-design-mode-more-menu.png?raw=true) - Task list, shipped view, in the design mode after a sort change: 重置 + 另存为我的视图. The menu reads 未保存的改动: 排序 / 另存为我的视图. ![shipped view](https://github.com/objectstack-ai/objectstack/blob/3b99443aceda9670b0c2db4630c07d03f53a8e52/screenshots/36737/03-list-shipped-view-save-as-my-view.png?raw=true) - Task list, the reader's own view, in the design mode after a sort change: 重置 + 更新视图. The menu reads 保存到这个视图 / 另存为我的视图. ![own view](https://github.com/objectstack-ai/objectstack/blob/3b99443aceda9670b0c2db4630c07d03f53a8e52/screenshots/36737/04-list-own-view-update-view.png?raw=true) - Phone, 375 px, shipped view with a sort draft: the chip row ends with 保存 ▾, and the view switcher keeps 「全…」 with its count. The design mode is never on a phone. ![phone chip row](https://github.com/objectstack-ai/objectstack/blob/3b99443aceda9670b0c2db4630c07d03f53a8e52/screenshots/36737/05-phone-375-chip-row.png?raw=true) The images live on the assets-only branch `claude/issue-36737-screenshots` at commit `3b99443a`. That branch is never merged and opens no pull request. ## Tests New pins (#36737), each in the component's existing harness file as a top-level `describe`, except the record page pins, which have their own file named for the card: - `views/__tests__/RecordTabsConfig-36499.test.tsx`: the harness mounts the real `useDesignModeController` and `DesignModeBar`. - The tab row is the editor under the one bar, with no tabs bar of its own. - The mode's 保存 writes the tabs draft together with another staged change, once and in the order staged (own package: `save object account` with `{ mode: 'draft', packageId: 'app.crm', ifNoneMatch: '*' }`, then `publish`), and leaves the mode. - 取消 drops the draft and writes nothing. This covers both a tab the admin hid and a tab hidden by default that the admin showed again; re-entering opens the object as it was. - A failed save keeps the editor on the draft and the mode on, and the mode says why. - The draft survives leaving the page and coming back. - The #36499 cases are kept and rewritten for the mode, and leaving the app asks with the mode's message. - `views/__tests__/RecordTabsConfigInstalled-36499.test.tsx`: the mode's 保存 writes the installed object's `.custom` extension (`ensure` → `save object_extension lead` in `app.hotcrm.custom` → `publish`). 取消 sends no ensure and no write. - `views/RecordDetailView.designModeTabs-36737.test.tsx`: the real `RecordDetailView` on a full page. - In the mode the tab row is the editor with one bar, and ⋯ has no 「Configure tabs」. Out of the mode (the control), the page's own tab row is drawn and ⋯ has no entry either. - While the record's edit state is open, the tab row is not the editor. Leaving the edit state brings the editor back, with the mode on throughout. - `views/ListDraftActions.noSave-35955.test.tsx`, through the real packs: - zh reads 重置 / 更新视图, and the menu keeps 保存到这个视图 and 另存为我的视图. en reads Reset / Update view, and the narrow face is one Update view whose menu holds Reset. - With no save-to-view, the wide face reads 另存为我的视图 / Save as my view and the narrow face reads 保存 / Save. With one, both faces read 更新视图 / Update view. - `views/ObjectView.footerCalculationDraft-36194.test.tsx`: under an entered design mode, the list draft's actions are drawn and live. The mode's 保存 stays off, 「保存到这个视图」 writes `sys_personal_view` on its own, and the mode stays on. Ablations, run once and not kept. Each ran on the committed fix through `scripts/ablation-replace.mjs`, and each restore was proved by blob == HEAD with `git diff HEAD` empty: - The tabs change's `saveRecordTabs(` commit made a no-op: both 保存 pins went red (`Tests 2 failed | 13 passed`). - The wide label's save-as branch replaced by `draft.save`: both label pins went red (`Tests 2 failed | 4 passed`). The first attempt was refused by the tool as a no-op, because its replacement text was already in the file. It was re-run with a distinct replacement. - The narrow label's `common.save` branch replaced by `saveAsMyView`: both label pins went red (`Tests 2 failed | 4 passed`). - The record page's `!recordEditState` gate removed: the edit-state pin went red (`Tests 1 failed | 2 passed`). All subjects resolve from `src` through relative imports, so no `dist` leg applies. <details><summary>Local readings (head af3d3f9)</summary> - Card test files (5) at the head: `Test Files 5 passed (5)`, `Tests 33 passed (33)`. - app-shell tests that import the touched modules (RecordTabsConfig*, recordTabs*, ListDraftActions, designMode*, DesignModeBar, RecordDetailView, ObjectView harness), after the merge of `origin/main`: `Test Files 119 passed (119)`, `Tests 1110 passed (1110)`. Run in one lock hold with the two below, VERDICT command-exit 0. - `pnpm --filter @object-ui/i18n test`: `Test Files 110 passed (110)`. - `pnpm --filter @object-ui/app-shell --filter @object-ui/i18n run type-check`: both scripts echoed and finished. - `dispatch-gates --commands` (41 families) at the round's head: 40 exit 0. `pnpm --dir ui exec vitest run scripts/` was killed by the shared box's memory limit (SIGKILL) during the run; re-run alone under the lock: `Test Files 172 passed | 2 skipped (174)`, `Tests 5130 passed | 2 skipped`, exit 0. `--ran` reconciliation: 41 derived, 41 run, 0 UNRUN. </details> ## Acceptance notes - The card's text says the split menu keeps 「保存为我的视图」. The served zh label is 「另存为我的视图」 (`saveAsMyView`), and it is kept unchanged. - Three keys now have no call site: `designMode.recordTabs.entry`, `.leaveUnsaved` and `.saveFailed`. They are left in the pack, because removing a key from the published `@object-ui/i18n` pack would narrow it, which is outside this card's `Clause-②: no`. `designMode.recordTabs.title` stays live as the editor region's accessible name. - `leadsMenu: true` in `@object-ui/components`' page header (`containers.tsx`) now has no producer: the removed ⋯ item was its only one. This is a zero-pull mechanism, not filed. - While the mode is on, a record page with editable tabs draws in the default order, with the reader's own arrangement set aside, as the old edit state did, so the preview is what Save writes for everyone. - On the phone, the view switcher still truncates a long view name next to the draft button (「全…」 beside 保存). Before the narrow-face label it was squeezed down to the count alone. --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent f92d271 commit d763ee7

22 files changed

Lines changed: 914 additions & 394 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(console): a record page's tabs are arranged in the design mode, under its one bar; a list's draft actions read Reset / Update view
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The design mode and the record page's 「Configure tabs」 each drew a purple bar with its own Cancel and Save, and the two stacked when both were open. A list's draft actions (Discard / Save) showed under the design mode's bar as a second page save. Following Twenty's grouping (the maintainer's ruling 「照 Twenty 归类」):
12+
13+
- The record page's tabs are part of the design mode. While the mode is on, the tab row of a record's desktop full page is the tabs editor in place, for an administrator who may arrange that object's tabs (the same gates as before: a workspace administrator who may author metadata, the desktop full page, not a drawer or pane, not an authored page, and the customization-door wall on an installed object). The draft is staged with the mode's other changes (the app menu, the header buttons): the mode's Save writes it with them, to the object's own package (`relatedLists`, published) or, on an installed object, to the base's paired `.custom` object extension, as before; the mode's Cancel drops it. The draft stays staged while the administrator moves to another page of the app. The record's ⋯ no longer offers 「Configure tabs」, and the separate 「Configure tabs」 bar is gone. A failed save says so through the mode's own message and keeps the draft staged.
14+
- A list's draft actions are the view's own, as Twenty's 「Reset / Update view」: they now read 「重置 / 更新视图」 (en: Reset / Update view; every bundled language pack is updated), and they stay drawn and live while the design mode is on. The Update view menu keeps 「Save to this view」 and 「Save as my view」. Where the open view cannot take the change (a view a read-only package ships, or a reader who may not write it), the button reads 「另存为我的视图」 (Save as my view), the one save its menu holds; on the phone's chip row it reads 「保存」 (Save) there, so the view switcher beside it keeps its name.
15+
16+
Locale values changed in `@object-ui/i18n` (no key added or removed): `console.objectView.draft.discard` and `console.objectView.draft.save`, in all eleven bundled packs. No props or package exports change. While a record's own edit state is open, its tab row is not the tabs editor.

‎ui/packages/app-shell/src/layout/designMode.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
*
1818
* It holds the changes made under it, and nothing else. Each change is staged
1919
* under a key by the surface that makes it ({@link useDesignModeChange}): the
20-
* menu editor, the page header's pinned actions. A staged change carries its
21-
* own `commit`, the write that makes it real, so the mode needs to know
22-
* nothing about what a change is:
20+
* menu editor, the page header's pinned actions, a record page's tabs (its
21+
* tab row is their editor while the mode is on, objectstack#36737, as Twenty
22+
* customizes record page layouts under its one layout bar). A staged change
23+
* carries its own `commit`, the write that makes it real, so the mode needs
24+
* to know nothing about what a change is:
2325
*
2426
* - 「Save」 commits every staged change, in the order they were first
2527
* staged, then leaves the mode. A commit that fails stops the save there:
@@ -59,6 +61,11 @@
5961
* ({@link useHoldDesignModeOut}), and entering refuses, saying to save or
6062
* cancel those changes first.
6163
*
64+
* A list's view actions are neither the mode's nor excluded by it: a view
65+
* saves on its own, so its 「Reset / Update view」 stay live under the mode's
66+
* bar, and name the view, not the page (objectstack#36737, as Twenty's view
67+
* bar does).
68+
*
6269
* Who may enter is the header button's gate (`useAppStudioEntry`, a workspace
6370
* administrator holding `manage_metadata`), read where the button is drawn
6471
* (`ShellPageActions`). The app's package need not be writable: a read-only
Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
/**
2-
* objectstack#35955 — Discard and Save where no save is offered (personal
2+
* objectstack#35955 — the draft's actions where no save is offered (personal
33
* views not ready, or no grant to create one on a shared view): both faces
4-
* are Discard alone. The narrow face never draws a Save that holds nothing
5-
* to save.
4+
* are Reset alone. The narrow face never draws a save button that holds
5+
* nothing to save.
66
*/
77

88
import * as React from 'react';
99
import { describe, it, expect, vi, afterEach } from 'vitest';
1010
import { render, cleanup, fireEvent, screen } from '@testing-library/react';
11+
import { I18nProvider } from '@object-ui/i18n';
1112
import { ListDraftActions } from './ListDraftActions';
1213

1314
afterEach(() => cleanup());
1415

15-
describe('Discard and Save with no save offered (objectstack#35955)', () => {
16-
it('draws Discard on both faces and no Save at all', () => {
16+
describe('Reset and Update view with no save offered (objectstack#35955)', () => {
17+
it('draws Reset on both faces and no save button at all', () => {
1718
const onDiscard = vi.fn();
1819
render(<ListDraftActions parts={['sort']} onDiscard={onDiscard} />);
1920

@@ -27,11 +28,96 @@ describe('Discard and Save with no save offered (objectstack#35955)', () => {
2728
expect(onDiscard).toHaveBeenCalledTimes(1);
2829
});
2930

30-
it('CONTROL: with a save offered, the narrow face is one Save whose menu holds Discard', () => {
31+
it('CONTROL: with a save offered, the narrow face is one save button whose menu holds Reset', () => {
3132
render(<ListDraftActions parts={['sort']} onDiscard={() => {}} onSaveAsMyView={() => {}} />);
3233

3334
expect(screen.getByTestId('list-draft-compact')).toBeTruthy();
34-
// Discard lives inside that menu, not beside it.
35+
// Reset lives inside that menu, not beside it.
3536
expect(screen.queryByTestId('list-draft-compact-discard')).toBeNull();
3637
});
3738
});
39+
40+
/**
41+
* objectstack#36737 — the draft's actions read as the view's own (Twenty's
42+
* 「Reset / Update view」), not as a second page Save beside the design
43+
* mode's: 「重置 / 更新视图」, and the split menu keeps 「Save as my view」.
44+
* Read through the real language packs.
45+
*/
46+
describe('「重置 / 更新视图」: the view\'s own actions (objectstack#36737)', () => {
47+
const draw = (language: string) =>
48+
render(
49+
<I18nProvider config={{ defaultLanguage: language, detectBrowserLanguage: false }} persistLanguage={false}>
50+
<ListDraftActions parts={['sort']} onDiscard={() => {}} onSaveToView={() => {}} onSaveAsMyView={() => {}} />
51+
</I18nProvider>,
52+
);
53+
const openMenu = (testId: string) => fireEvent.pointerDown(screen.getByTestId(testId), { button: 0, ctrlKey: false, pointerType: 'mouse' });
54+
55+
it('zh: 重置 beside 更新视图, whose menu keeps both saves', async () => {
56+
draw('zh');
57+
expect(screen.getByTestId('list-draft-discard').textContent?.trim()).toBe('重置');
58+
expect(screen.getByTestId('list-draft-save').textContent?.trim()).toBe('更新视图');
59+
openMenu('list-draft-save');
60+
const menu = await screen.findByTestId('list-draft-save-menu');
61+
expect(menu.querySelector('[data-testid="list-draft-save-to-view"]')?.textContent).toBe('保存到这个视图');
62+
expect(menu.querySelector('[data-testid="list-draft-save-as"]')?.textContent).toBe('另存为我的视图');
63+
});
64+
65+
it('en: Reset beside Update view; the narrow face is one Update view whose menu holds Reset', async () => {
66+
draw('en');
67+
expect(screen.getByTestId('list-draft-discard').textContent?.trim()).toBe('Reset');
68+
expect(screen.getByTestId('list-draft-save').textContent?.trim()).toBe('Update view');
69+
expect(screen.getByTestId('list-draft-compact').textContent?.trim()).toBe('Update view');
70+
openMenu('list-draft-compact');
71+
const menu = await screen.findByTestId('list-draft-compact-menu');
72+
expect(menu.querySelector('[data-testid="list-draft-save-as"]')?.textContent).toBe('Save as my view');
73+
expect(menu.querySelector('[data-testid="list-draft-compact-discard"]')?.textContent).toBe('Reset');
74+
});
75+
});
76+
77+
/**
78+
* objectstack#36737 (seat review S1) — the button names the save its menu
79+
* holds: 「更新视图」 where the open view can take the change, else
80+
* 「另存为我的视图」, the one save there is (a view a read-only package ships,
81+
* or a reader who may not write the view). The narrow face, the phone's chip
82+
* row, reads 「保存」 there: the longer name squeezed the view switcher beside
83+
* it down to its count at 375 px (measured: 44 px for the switcher against
84+
* 76 px beside 「更新视图」).
85+
*/
86+
describe('the save button names the save it offers (objectstack#36737)', () => {
87+
const draw = (language: string, saveToView: boolean) =>
88+
render(
89+
<I18nProvider config={{ defaultLanguage: language, detectBrowserLanguage: false }} persistLanguage={false}>
90+
<ListDraftActions
91+
parts={['sort']}
92+
onDiscard={() => {}}
93+
onSaveToView={saveToView ? () => {} : undefined}
94+
onSaveAsMyView={() => {}}
95+
/>
96+
</I18nProvider>,
97+
);
98+
const faces = () => [
99+
screen.getByTestId('list-draft-save').textContent?.trim(),
100+
screen.getByTestId('list-draft-compact').textContent?.trim(),
101+
];
102+
103+
it('zh: 更新视图 where the view can take the change, 另存为我的视图 where it cannot', () => {
104+
draw('zh', true);
105+
expect(faces()).toEqual(['更新视图', '更新视图']);
106+
cleanup();
107+
draw('zh', false);
108+
expect(faces()).toEqual(['另存为我的视图', '保存']);
109+
expect(screen.getByTestId('list-draft-discard').textContent?.trim()).toBe('重置');
110+
});
111+
112+
it('en: Update view where the view can take the change, Save as my view where it cannot', async () => {
113+
draw('en', false);
114+
expect(faces()).toEqual(['Save as my view', 'Save']);
115+
fireEvent.pointerDown(screen.getByTestId('list-draft-save'), { button: 0, ctrlKey: false, pointerType: 'mouse' });
116+
const menu = await screen.findByTestId('list-draft-save-menu');
117+
expect(menu.querySelector('[data-testid="list-draft-save-to-view"]')).toBeNull();
118+
expect(menu.querySelector('[data-testid="list-draft-save-as"]')?.textContent).toBe('Save as my view');
119+
cleanup();
120+
draw('en', true);
121+
expect(faces()).toEqual(['Update view', 'Update view']);
122+
});
123+
});

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

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
/**
2-
* objectstack#35955 — Discard and Save on a Console list, drawn while the list
3-
* holds a DRAFT: a change the reader made on the list (`./listDraftStore.ts`)
4-
* that applies at once and is not saved anywhere. It replaces the
5-
* 「Personalized · Reset」 marker (objectstack#28950) at the end of the
6-
* condition row (objectstack#35878); with no draft the slot is empty.
2+
* objectstack#35955 — Reset and Update view on a Console list, drawn while
3+
* the list holds a DRAFT: a change the reader made on the list
4+
* (`./listDraftStore.ts`) that applies at once and is not saved anywhere. It
5+
* replaces the 「Personalized · Reset」 marker (objectstack#28950) at the end of
6+
* the condition row (objectstack#35878); with no draft the slot is empty.
77
*
8-
* - **Discard** puts the list back as its view declares it (the host's
8+
* - **Reset** puts the list back as its view declares it (the host's
99
* `onDiscard`).
10-
* - **Save** opens its choices: 「Save to this view」 (`onSaveToView`, offered
11-
* only where the host may write the open view) and 「Save as my view」
12-
* (`onSaveAsMyView`, which asks a name first). The menu names what is
13-
* unsaved, so a reader sees what a save keeps.
10+
* - **Update view** opens its choices: 「Save to this view」 (`onSaveToView`,
11+
* offered only where the host may write the open view) and 「Save as my
12+
* view」 (`onSaveAsMyView`, which asks a name first). The menu names what is
13+
* unsaved, so a reader sees what a save keeps. Where the open view cannot
14+
* take the change, the button reads 「Save as my view」, the one save its
15+
* menu holds, so it never promises an update it does not offer (the narrow
16+
* face, short of room, reads 「Save」 there).
17+
*
18+
* The two read as the view's own actions, not as a page's Cancel and Save
19+
* (objectstack#36737, Twenty's 「Reset / Update view」): a view is its own
20+
* thing and saves on its own, so they stay drawn, and live, while the app's
21+
* design mode is on, under the mode's bar (the maintainer's correction:
22+
* 「tweetty 编辑布局时,列表视图还是正常显示保存」).
1423
*
1524
* As the list narrows (the phone list draws this same control in its chip
16-
* row, objectstack#35883), the two faces fold into ONE Save whose menu also
17-
* holds Discard: one control, one save path, at every width. Where no save
18-
* is offered, both faces are Discard alone.
25+
* row, objectstack#35883), the two faces fold into ONE Update view whose menu
26+
* also holds Reset: one control, one save path, at every width. Where no save
27+
* is offered, both faces are Reset alone.
1928
*
2029
* Nothing here is configurable: no metadata key or option reaches it.
2130
*/
@@ -95,7 +104,14 @@ export function ListDraftActions({
95104
};
96105
const discardLabel = t('console.objectView.draft.discard');
97106
const discardTitle = t('console.objectView.draft.discardTitle');
98-
const saveLabel = t('console.objectView.draft.save');
107+
// The button names what its menu does: 「Update view」 where the open view
108+
// can take the change, else the one save there is, 「Save as my view」 (a
109+
// view a read-only package ships, or a reader who may not write it). The
110+
// narrow face (the phone's chip row) says 「Save」 there instead: the longer
111+
// name would squeeze the view switcher beside it down to its count, and its
112+
// menu, which also holds Reset, names the save.
113+
const saveLabel = onSaveToView ? t('console.objectView.draft.save') : t('console.objectView.draft.saveAsMyView');
114+
const compactSaveLabel = onSaveToView ? t('console.objectView.draft.save') : t('common.save');
99115
const offersSave = !!onSaveToView || !!onSaveAsMyView;
100116

101117
const saveItems = (
@@ -123,7 +139,7 @@ export function ListDraftActions({
123139

124140
return (
125141
<span className={cn('flex shrink-0 items-center gap-1', className)} data-testid="list-draft">
126-
{/* The wide face: Discard beside Save ▾. */}
142+
{/* The wide face: Reset beside Update view ▾. */}
127143
<ConditionDiscardButton
128144
label={discardLabel}
129145
title={discardTitle}
@@ -150,8 +166,8 @@ export function ListDraftActions({
150166
</DropdownMenuContent>
151167
</DropdownMenu>
152168
) : null}
153-
{/* The narrow face: one Save, whose menu also holds Discard. With no
154-
save offered, a Save would hold nothing to save: Discard alone. */}
169+
{/* The narrow face: one Update view, whose menu also holds Reset. With
170+
no save offered, it would hold nothing to save: Reset alone. */}
155171
{offersSave ? (
156172
<DropdownMenu>
157173
<DropdownMenuTrigger asChild>
@@ -162,7 +178,7 @@ export function ListDraftActions({
162178
data-testid="list-draft-compact"
163179
className="inline-flex h-6 shrink-0 gap-1 px-2 text-sm @[40rem]/list:hidden"
164180
>
165-
{saveLabel}
181+
{compactSaveLabel}
166182
<ChevronDown className="h-3.5 w-3.5" aria-hidden="true" />
167183
</Button>
168184
</DropdownMenuTrigger>

‎ui/packages/app-shell/src/views/ObjectView.footerCalculationDraft-36194.test.tsx‎

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ vi.mock('./studio-design/packages-io', async (importOriginal) => ({
110110
import { ObjectView } from './ObjectView';
111111
import { ExpressionProvider } from '../providers/ExpressionProvider';
112112
import { listDraftScope, readListDraft, resetListDraftStoreForTests } from './listDraftStore';
113+
import { DesignModeProvider, useDesignModeController } from '../layout/designMode';
114+
import { DesignModeBar } from '../layout/DesignModeBar';
113115

114116
const OBJECT = 'showcase_task';
115117
const SHIPPED_PACKAGE = 'com.example.showcase';
@@ -141,7 +143,7 @@ const PACKAGES = [
141143
{ id: CUSTOM_PACKAGE, name: 'Showcase (custom)', writable: true, namespace: 'showcase' },
142144
];
143145

144-
function mount(viewId: string) {
146+
function mount(viewId: string, wrap: (page: React.ReactNode) => React.ReactNode = (page) => page) {
145147
const dataSource = {
146148
find: vi.fn(async (resource: string) =>
147149
resource === 'sys_personal_view' ? { data: [PERSONAL], total: 1 } : { data: [], total: 0 }),
@@ -156,22 +158,24 @@ function mount(viewId: string) {
156158
render(
157159
<ExpressionProvider user={{ id: 'u1', name: 'Ada', profile: 'admin' }}>
158160
<MemoryRouter initialEntries={[`/apps/demo/${OBJECT}/view/${encodeURIComponent(viewId)}`]}>
159-
<Routes>
160-
<Route
161-
path="/apps/:appName/:objectName/view/:viewId"
162-
element={
163-
<ObjectView
164-
dataSource={dataSource as never}
165-
objects={[{
166-
name: OBJECT,
167-
label: 'Task',
168-
fields: { name: { type: 'text', label: 'Name' }, amount: { type: 'number', label: 'Amount' } },
169-
}]}
170-
onEdit={() => {}}
171-
/>
172-
}
173-
/>
174-
</Routes>
161+
{wrap(
162+
<Routes>
163+
<Route
164+
path="/apps/:appName/:objectName/view/:viewId"
165+
element={
166+
<ObjectView
167+
dataSource={dataSource as never}
168+
objects={[{
169+
name: OBJECT,
170+
label: 'Task',
171+
fields: { name: { type: 'text', label: 'Name' }, amount: { type: 'number', label: 'Amount' } },
172+
}]}
173+
onEdit={() => {}}
174+
/>
175+
}
176+
/>
177+
</Routes>
178+
)}
175179
</MemoryRouter>
176180
</ExpressionProvider>,
177181
);
@@ -342,3 +346,39 @@ describe('objectstack#36195 — a view the reader cannot change in place: the pi
342346
expect(writes).toEqual([]);
343347
});
344348
});
349+
350+
/** The shell's design mode, entered for the app on mount, with its bar drawn above the page. */
351+
function DesignModeOn({ children }: { children: React.ReactNode }) {
352+
const mode = useDesignModeController({ appName: 'demo', appBasePath: '/apps/demo', enabled: true });
353+
const { enter } = mode;
354+
React.useEffect(() => {
355+
enter();
356+
}, [enter]);
357+
return (
358+
<DesignModeProvider value={mode}>
359+
{mode.active && <DesignModeBar mode={mode} />}
360+
{children}
361+
</DesignModeProvider>
362+
);
363+
}
364+
365+
describe('objectstack#36737 — the list draft\'s actions stay live while the design mode is on', () => {
366+
it('under the mode\'s bar, the draft draws its own actions, and 「Save to this view」 writes the view, not the mode', async () => {
367+
const page = mount(PERSONAL.id, (node) => <DesignModeOn>{node}</DesignModeOn>);
368+
await settle();
369+
await waitFor(() => expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument());
370+
await waitFor(() => expect(offersMenu()).toBe(true));
371+
await pick('amount', 'max');
372+
expect(screen.getByTestId('list-draft')).toBeInTheDocument();
373+
expect(screen.getByTestId('list-draft-discard')).toBeEnabled();
374+
// The view's change is no change of the mode's: its 「Save」 stays off.
375+
expect(screen.getByTestId('design-mode-save')).toBeDisabled();
376+
377+
await openSave();
378+
fireEvent.click(await screen.findByTestId('list-draft-save-to-view'));
379+
await waitFor(() => expect(page.dataSource.update).toHaveBeenCalledTimes(1));
380+
expect(page.dataSource.update.mock.calls[0].slice(0, 2)).toEqual(['sys_personal_view', PERSONAL.id]);
381+
// Saved on its own: the mode is still on.
382+
expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument();
383+
});
384+
});

0 commit comments

Comments
 (0)