Skip to content

Commit e0050ba

Browse files
fix(console): report editing is its own entry, mutually exclusive with design mode (#36848)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB9qsP28anD5tWRUHq8j1xSU)_ Fixes #36692 Clause-②: no Metadata-protocol: none repo:objectstack#3 · os-support-ai · session_01WGufzhpykmQZe1yMupC2CU ## 维护者速读 - 管理员在应用里点「设计布局」时,添加菜单项的「报表」一栏只列已有报表,不再有「新建报表…」;新建报表改在报表列表页右上角的「新建报表」按钮;仪表盘或报表正在编辑时点「设计布局」会提示先保存或取消,设计布局开着时仪表盘和报表的「编辑」按钮不出现。 - 落实维护者「照 Twenty 分开」的裁决:报表和仪表盘的编辑与设计布局是两个入口,屏幕上任何时候只有一套保存/取消。 - 出错时管理员会看到两套保存按钮或点不出新建报表;本改动不碰任何已保存的数据,合并后可直接撤回。 - 无 ## What changes The maintainer's ruling on the decision card (2026-11-23 11:55Z): 「照 Twenty 分开」. Report and dashboard editing are their own entries, mutually exclusive with design mode, so the screen shows one Save/Cancel set at a time. 1. **Design mode stops hosting the report builder.** The `Reports` list in 「Add menu item」 only links reports that exist. Removed: its 「New report…」 row, the cross-mode hand-off module `designModeReportSlot.ts` (deleted, not left unused), the slot block in `DesignModeMenu`, the slot branch in `ReportNewPage`, and the `report` kind of `designModeMenuCreate.ts` (a dashboard is again the one kind made from a name). 「New dashboard…」 is unchanged (change item 4). 2. **A report is created from its own entry.** The reports index (`AppReportIndexView`) header offers 「New report」, linking to the app's `reports/new`. It is gated as the builder is (`useWorkspaceAdminStatus`: workspace admin, resolved) and shown on an empty index too. The builder's Save and Close in its own header are the only Save/Cancel set; Close goes back to the index. 3. **Two-way exclusion, through one hold on the shell's design-mode store** (`designMode.tsx`): - `useHoldDesignModeOut(open)`: a dashboard's or report's own editor holds the mode out while it is open (or opening). Wired into `useDashboardInPageEdit`, `ReportView` (builder and inspector panel) and `ReportNewPage`. - The mode's `enter` now answers `boolean`: while anything holds the mode out, it refuses with a toast, "Save or cancel your dashboard or report changes before designing the layout." (zh-Hans 「请先保存或取消仪表盘、报表的修改,再设计布局。」). 「Design layout」 in the app menu stays drawn and refuses through it. - While the mode is on, `useDesignModeActive()` hides the dashboard's Edit (`useDashboardEditOffered`), the report page's Edit, and the index's 「New report」. - `ReportNewPage` reached while the mode is on (an in-app navigation keeps the mode) draws no builder: an Empty says "Finish designing the layout first" / "A report is built outside the design mode. Save or cancel the layout, and the builder opens here." It holds the mode out only while it draws the builder, so the bar's Save or Cancel opens the builder in place (L1-a S1, 7122753474). - This also closes the path the card measured: the bar's Cancel ending design mode while a dashboard stays in edit. The bar can no longer appear while an editor is open. 4. **Strings:** `designMode.editorOpen`, `console.reportIndex.newReport`, `report.builder.designModeOnTitle` and `report.builder.designModeOn` were added to all 11 packs (zh-Hant regenerated with `gen:zh-hant`). `designMode.menu.newReport`, `designMode.menu.newReportLeft` and `report.builder.addsToMenu` were removed from all 11 packs. The de quote-pair ledger drops 134 to 133 because `newReportLeft` is gone. Untouched rulings: #36363 ruling (4) (menu labels) and `designModeMenuCreate.ts` ruling C / ADR-0146 D2 「定制都进 .custom」. Docs and skills: neither `content/docs` nor `skills/` teaches "New report… from design mode". The one `New report` hit, `content/docs/data-modeling/analytics.mdx`, is about Studio's dataset picker, so nothing is owed. **Read first (by risk):** 1. `ui/packages/app-shell/src/layout/designMode.tsx`: the `heldOut` counter, `enter`'s refusal and `useHoldDesignModeOut`. 2. `ui/packages/app-shell/src/views/DashboardInPageEditor.tsx`: `useDashboardEditOffered` now also reads the mode. The design mode's 「New dashboard…」 landing (`dashboardEditArrival`) still opens the edit state, because `saveWith` leaves the mode before it navigates and the arrival effect waits on `editOffered`. 3. `ui/packages/app-shell/src/layout/DesignModeMenu.tsx`: the removed report block and picker row. **Two-minute check:** as admin in the showcase app, open Reports. 「New report」 is at the top right. Open a dashboard, press Edit, then choose app menu, then 「Design layout」: a red toast says to save or cancel first, and no purple bar appears. ## Tests New pins go into each component's existing harness as a top-level `describe` where there is one (`designMode-36362`, `SidebarAppMenu-36112`, `DesignModeMenu-36363`, `designModeMenuCreate-36364`, `DashboardView.inPageEdit-36372`). New card-named files were added where the component has only per-card files: `ReportView.designModeExclusion-36692`, `ReportNewPage-36692` and `AppReportIndex.newReport-36692`. - Exclusion while an editor is open: `enter` refuses with the prompt and the mode stays off. This is pinned on the store, on the 「Design layout」 door, on the dashboard edit state (no bar, so no bar Cancel), on the report builder, on the report inspector panel, and on the new-report builder. Two editors hold the mode out until both close, and an editor unmounted while open lets go. - Exclusion while the mode is on: no dashboard Edit, no report Edit, no 「New report」 on the index; each comes back once the mode is left. - The picker: `Reports` lists existing reports not yet in the menu and has no 「New report…」 row. Picking a report stages it with the mode, writes nothing and navigates nowhere. - `ReportNewPage` under the mode (round 2, `ReportNewPage-36692`): mode on at the index, then `reports/new`: the mode stays on, no builder, no Save, the prompt shows; then the bar's Cancel: the mode is off, the builder is drawn, and a later `enter()` is refused; control: mode off, `reports/new` draws the builder with Save and no prompt. - `ReportNewPage` saves on its own (the deleted `ReportNewPage.menuSlot-36364` file's surviving case, ported), and Close goes back to the index. - Removed with the behaviour they pinned: the report-half cases in `DesignModeMenu-36363` and `designModeMenuCreate-36364`, and `ReportNewPage.menuSlot-36364.test.tsx`. <details><summary>Local runs</summary> - Pre-merge head `22dee19f5`: `@object-ui/app-shell` full suite: Test Files 2474 passed, 1 skipped (2475); Tests 23314 passed, 9 skipped. `@object-ui/i18n` suite: 107 files, 2006 passed. `type-check` for both packages exited 0. - After merging origin/main (head `7ea3843ec`, which carries #36821): the app-shell closure was rebuilt and `type-check` for both packages exited 0. `@object-ui/i18n` suite: 108 files, 2011 passed. Scoped app-shell run (`src/layout/` plus the ReportView, ReportNewPage, DashboardView, AppReportIndex and reportBuilder files): 190 files, 1535 passed. This run was narrowed on purpose; CI's `Test UI` runs the full suite. - Ablation 1, committed fix, `scripts/ablation-replace.mjs`: in `enter`, `if (heldOut > 0) {` was changed to `if (heldOut < 0) {` (anchor 1 to 0, blob `473cab2c7389` to `7793aa4658ec`). Result: 7 failed (every refusal pin across five files). Restored blob equals HEAD and `git diff HEAD` is empty. - Ablation 2: in `useDashboardEditOffered`, `return gated && !designing;` was changed to `return gated;`. Result: 1 failed ("while the mode is on, Edit is not offered"). Restored, blob equals HEAD. - Round 2, head `cccd01739`: `ReportNewPage-36692` 6/6. Ablation 3, committed fix: `if (designing) {` changed to `if (false as boolean) {` (blob `f81d258a824f` to `fa265e66e744`): 1 failed, 5 passed, the mode-on pin red; restored blob equals HEAD. Scoped run (`packages/i18n/` plus app-shell `src/layout/`, ReportView, ReportNewPage, DashboardView, AppReportIndex, reportBuilder): 298 files, 3549 passed, 13 skipped. `type-check` for both packages exited 0. </details> ## Acceptance notes - Browser screenshots: showcase app as admin, console served by Vite from this branch's `ui/` against a `--seed-admin` backend on its own port. The files are in the project files under `issue-36692/`: - `1-reports-index-new-report.png`: the reports index with 「New report」. - `1b-builder-one-save-set.png`: the builder it opens, showing only its own Discard/Save. - `2a-design-mode-index-no-new-report.png`: design mode on, so no 「New report」. - `2b-design-mode-reports-picker.png`: the design-mode Reports picker without 「New report…」. The showcase's reports are all in its menu already, so the picker reads "Nothing to add here". - `3-refusal-prompt.png`: the dashboard in edit, and 「Design layout」 refused with the prompt. - `4-design-mode-dashboard-no-edit.png`: design mode on, so the dashboard has no Edit. - A typed `reports/new` URL reloads the page, so the mode is gone. An in-app navigation to `reports/new` keeps the mode, and there the page now draws the prompt instead of the builder (round 2). The index link is hidden while the mode is on. - Open PR #36858 overlaps this branch textually in `DesignModeMenu.tsx` and `designModeMenuCreate.ts` (this PR removes the report half there). Whichever lands second resolves it. - `#36791` will conflict with this branch on the de quote-pair ledger counts (`de-quote-pairing-3876.test.ts`). Whichever lands second re-counts. ## Verification Derived gate families (`dispatch-gates.mjs --commands` at `7ea3843ec`) were run locally; their results are in the report comment on the card. CI carries the full farm. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzhpykmQZe1yMupC2CU)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzhpykmQZe1yMupC2CU --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8f141a2 commit e0050ba

31 files changed

Lines changed: 1140 additions & 664 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(console): report editing is its own entry, and report and dashboard editing exclude the design mode both ways
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The console's design mode no longer hosts the report builder, so the screen shows one Save/Cancel set at a time:
12+
13+
- The design mode's 「Add menu item → Reports」 lists only reports that exist; its 「New report…」 row is gone, with the hand-off that let the builder save into the menu. A new report is made from the reports index, then linked from the design mode.
14+
- The reports index offers 「New report」 in its header, opening the report builder. It is offered to workspace admins, as the builder is, and not while the design mode is on.
15+
- While the design mode is on, a dashboard's and a report's own 「Edit」 are not offered.
16+
- While a dashboard or report editor is open, 「Design layout」 refuses with a prompt to save or cancel those changes first, so the design mode's 「Cancel」 can no longer end the mode under an editor left open.
17+
- The report builder's own address reached with the design mode already on (the browser's Back) shows a prompt to finish designing the layout instead of the builder; the builder opens there once the mode is saved or cancelled.
18+
19+
The design mode's 「New dashboard…」 is unchanged. In `@object-ui/i18n`, `designMode.menu.newReport`, `designMode.menu.newReportLeft` and `report.builder.addsToMenu` are removed from every pack, and `designMode.editorOpen`, `console.reportIndex.newReport`, `report.builder.designModeOnTitle` and `report.builder.designModeOn` are added. Nothing to migrate.

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

Lines changed: 9 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@
4747
* place, and the mode saves at once, every other staged change with it
4848
* (`saveAppMenuWithNewItem`); then the mode is left and the new dashboard
4949
* opens for editing (`dashboardEditArrival`). 「Cancel」 writes nothing.
50-
* In 「Reports」 the first row is 「New report…」: a report needs a data source
51-
* and a measure, so the place stays held and the report builder opens; its
52-
* Save creates the report and saves the mode the same way
53-
* (`designModeReportSlot`), and its Close drops the place, writing nothing.
50+
* 「Reports」 lists only reports that exist (objectstack#36692, the
51+
* maintainer's ruling to keep report editing its own entry, as Twenty does):
52+
* a new report is made from the reports index, then linked here.
5453
*
5554
* Every edit is staged with the mode (`useDesignModeChange`), under one key
5655
* for the app's menu: the mode's 「Save」 writes it (`saveAppMenu`), its
@@ -69,7 +68,7 @@
6968
*/
7069

7170
import * as React from 'react';
72-
import { Link, useLocation, useNavigate } from 'react-router-dom';
71+
import { Link, useNavigate } from 'react-router-dom';
7372
import { toast } from 'sonner';
7473
import {
7574
DndContext,
@@ -180,7 +179,6 @@ import {
180179
} from './designModeMenuSave.js';
181180
import { freeItemName, isNewMenuItemKind, saveAppMenuWithNewItem, type NewMenuItemKind } from './designModeMenuCreate.js';
182181
import { dashboardEditArrival } from './designModeArrival.js';
183-
import { offerNewReportSlot, withdrawNewReportSlot, type NewReportSlot } from './designModeReportSlot.js';
184182

185183
/**
186184
* The group label's icon-mode hiding, as the sidebar's own labels declare it
@@ -503,83 +501,6 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
503501
return true;
504502
};
505503

506-
// objectstack#36364 (report half) — 「New report…」: a report cannot be
507-
// made from a name (the spec wants `dataset` and `values`), so the place
508-
// stays held and the report builder opens at `reports/new`. The builder
509-
// saves through the slot offered here (`designModeReportSlot`): the report
510-
// is created in the menu's package and its entry saved in the held place
511-
// with every other staged change, in one act; nothing is written before.
512-
// The builder's Close drops the place. Resolves `false` when nothing was
513-
// saved (the mode has said why); the builder stays open for another try.
514-
const [buildingReport, setBuildingReport] = React.useState(false);
515-
const saveNewReport = async (name: string, label: string, body: Record<string, unknown>): Promise<boolean> => {
516-
if (!addAt) return false;
517-
// A report entry with no label shows its machine name (only an object,
518-
// view or dashboard entry inherits its target's label), so the entry
519-
// carries the name the reader gave the report.
520-
const entry = { ...entryFor('report', name, newEntryId([...menu, ...(storedMenu ?? [])])), label };
521-
const itemTexts = {
522-
...texts,
523-
itemPendingDraft: t('designMode.menu.newItemPendingDraft', {
524-
defaultValue: 'A draft with this name is already pending. Try again.',
525-
}),
526-
itemLeft: t('designMode.menu.newReportLeft', {
527-
defaultValue: 'The new report "{{name}}" could not be removed again; remove it in Studio.',
528-
name: label,
529-
}),
530-
};
531-
const saved = await saveWith(insertEntry(menu, addAt.parentId, addAt.index, entry), (navigation) =>
532-
saveAppMenuWithNewItem(
533-
{ appName, packageId, served, navigation, labels, item: { kind: 'report', name, label, body } },
534-
itemTexts,
535-
consoleAppMenuDoors(client as never),
536-
),
537-
);
538-
if (!saved) return false;
539-
setAddAt(null);
540-
setBuildingReport(false);
541-
return true;
542-
};
543-
// The builder's address the held place waits on.
544-
const newReportPath = `${basePath}/reports/new`;
545-
const saveNewReportRef = React.useRef(saveNewReport);
546-
React.useLayoutEffect(() => {
547-
saveNewReportRef.current = saveNewReport;
548-
});
549-
React.useEffect(() => {
550-
if (!buildingReport) return;
551-
const slot: NewReportSlot = {
552-
path: newReportPath,
553-
save: (name, label, body) => saveNewReportRef.current(name, label, body),
554-
cancel: () => {
555-
setBuildingReport(false);
556-
setAddAt(null);
557-
},
558-
};
559-
offerNewReportSlot(slot);
560-
// Withdrawn when the place is no longer held, and when the menu unmounts
561-
// (the design mode ended): the builder then saves on its own, off the menu.
562-
return () => withdrawNewReportSlot(slot);
563-
}, [buildingReport, newReportPath]);
564-
// Leaving the builder another way than its Save or Close (a menu link, the
565-
// browser's Back) drops the place too, so no held row waits for a builder
566-
// that is gone. Read once the builder has been reached.
567-
const { pathname } = useLocation();
568-
const [reachedBuilder, setReachedBuilder] = React.useState(false);
569-
const onBuilder = pathname === newReportPath || pathname.endsWith(newReportPath);
570-
if (buildingReport && onBuilder && !reachedBuilder) setReachedBuilder(true);
571-
if (!buildingReport && reachedBuilder) setReachedBuilder(false);
572-
if (buildingReport && reachedBuilder && !onBuilder) {
573-
setBuildingReport(false);
574-
setReachedBuilder(false);
575-
setAddAt(null);
576-
}
577-
const startNewReport = () => {
578-
if (!addAt) return;
579-
setBuildingReport(true);
580-
navigate(newReportPath);
581-
};
582-
583504
const renderLeaf = (entry: MenuEntry, depth: number) => {
584505
const id = String(entry.id);
585506
const place = placeOf(menu, id);
@@ -620,7 +541,7 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
620541
const renderEntries = (entries: Menu, parentId: string | null, depth: number): React.ReactNode[] => {
621542
const rows: React.ReactNode[] = [];
622543
entries.forEach((entry, index) => {
623-
if (addAt && addAt.parentId === parentId && addAt.index === index) rows.push(<Placeholder key="placeholder" depth={depth} buildingReport={buildingReport} />);
544+
if (addAt && addAt.parentId === parentId && addAt.index === index) rows.push(<Placeholder key="placeholder" depth={depth} />);
624545
if (isGroup(entry)) {
625546
const gid = String(entry.id);
626547
rows.push(
@@ -641,7 +562,7 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
641562
rows.push(renderLeaf(entry, depth));
642563
}
643564
});
644-
if (addAt && addAt.parentId === parentId && addAt.index >= entries.length) rows.push(<Placeholder key="placeholder" depth={depth} buildingReport={buildingReport} />);
565+
if (addAt && addAt.parentId === parentId && addAt.index >= entries.length) rows.push(<Placeholder key="placeholder" depth={depth} />);
645566
// Another package's group takes no own entry: no 「Add menu item」, no drop at its end.
646567
if (foreignGroup(parentId)) return rows;
647568
rows.push(
@@ -695,14 +616,13 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso
695616
</SortableContext>
696617
</DndContext>
697618
</SidebarGroupContent>
698-
{addAt && !buildingReport && (
619+
{addAt && (
699620
<MenuItemPicker
700621
packageId={packageId}
701622
inMenu={menuTargets(menu)}
702623
onClose={() => setAddAt(null)}
703624
onPick={(kind, name, link) => pick(entryFor(kind, name, newEntryId([...menu, ...(storedMenu ?? [])]), link))}
704625
onCreate={createItem}
705-
onNewReport={startNewReport}
706626
language={language}
707627
/>
708628
)}
@@ -794,14 +714,12 @@ function MenuLeaf({
794714
);
795715
}
796716

797-
function Placeholder({ depth, buildingReport }: { depth: number; buildingReport?: boolean }) {
717+
function Placeholder({ depth }: { depth: number }) {
798718
const { t } = useObjectTranslation();
799719
return (
800720
<li className="list-none" style={indent(depth)} data-testid="design-menu-placeholder">
801721
<div className="mx-0.5 flex h-8 items-center rounded-md border border-dashed border-sidebar-border px-2 text-sm text-sidebar-foreground/60">
802-
{buildingReport
803-
? t('designMode.menu.newReport', { defaultValue: 'New report…' })
804-
: t('designMode.menu.placeholder', { defaultValue: 'Choose a menu item…' })}
722+
{t('designMode.menu.placeholder', { defaultValue: 'Choose a menu item…' })}
805723
</div>
806724
</li>
807725
);
@@ -998,7 +916,6 @@ function MenuItemPicker({
998916
onClose,
999917
onPick,
1000918
onCreate,
1001-
onNewReport,
1002919
language,
1003920
}: {
1004921
packageId: string;
@@ -1007,8 +924,6 @@ function MenuItemPicker({
1007924
onPick: (kind: MenuTargetKind, name: string, link?: { label: string; url: string }) => void;
1008925
/** Create a new `kind` named `label`; `taken` is every name of that kind the picker lists. */
1009926
onCreate: (kind: NewMenuItemKind, label: string, taken: readonly string[]) => Promise<boolean>;
1010-
/** Build a new report for the held place, in the report builder. */
1011-
onNewReport: () => void;
1012927
language: string;
1013928
}) {
1014929
const { t } = useObjectTranslation();
@@ -1133,19 +1048,6 @@ function MenuItemPicker({
11331048
</button>
11341049
</li>
11351050
)}
1136-
{kind === 'report' && (
1137-
<li>
1138-
<button
1139-
type="button"
1140-
onClick={onNewReport}
1141-
className="flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm font-medium text-primary hover:bg-accent"
1142-
data-testid="design-menu-picker-new-report"
1143-
>
1144-
<Plus className="h-4 w-4 shrink-0" aria-hidden="true" />
1145-
<span className="flex-1 truncate">{t('designMode.menu.newReport', { defaultValue: 'New report…' })}</span>
1146-
</button>
1147-
</li>
1148-
)}
11491051
{loading ? (
11501052
<li className="px-2 py-2 text-sm text-muted-foreground">{t('designMode.menu.loading', { defaultValue: 'Loading…' })}</li>
11511053
) : offered.length === 0 ? (

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export const APP_MENU_SEARCH_FROM = 8;
7474
* (objectstack#36363: its changes are saved as this environment's
7575
* customization), except where the customization door is walled off for this
7676
* caller. Not drawn where no shell holds the mode, nor while the mode is on.
77+
*
78+
* objectstack#36692 — while a dashboard's or a report's own editor is open
79+
* it stays drawn, and choosing it refuses, saying to save or cancel those
80+
* changes first: the mode's `enter` refuses while an editor holds it out
81+
* (`useHoldDesignModeOut`), so the screen never shows two Save/Cancel sets.
7782
*/
7883
function useEnterDesignMode(apps: Parameters<typeof matchAppBySegment>[0], activeAppName: string): (() => void) | null {
7984
const entry = useStudioEntryGate(appStudioDesignPath(matchAppBySegment(apps, activeAppName), true));

0 commit comments

Comments
 (0)