Skip to content

Commit 01ed76a

Browse files
committed
feat(console): draw the report index only where the app's navigation declares it
The sidebar stops injecting its All reports row; a report nav entry with no reportName is the app's report index, routed to /reports and named by the console. The Studio shows that entry as the report index and keeps it on save. The showcase and todo examples, which ship reports, declare the entry. Claude-Session: https://claude.ai/code/session_01WGufzhEW5k2a4Vd5KSupfu Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bd611ad commit 01ed76a

24 files changed

Lines changed: 255 additions & 84 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/app-shell': minor
3+
---
4+
5+
feat(console): the sidebar draws the report index only where the app's navigation declares it
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added
9+
10+
The console no longer injects an "All reports" row at the foot of every app's sidebar. The app's report index (`/apps/APP/reports`) is an entry its navigation declares, a `report` item with no `reportName`, drawn and highlighted like any other entry; an app whose navigation declares none shows no index entry. With no `label`, the entry shows the console's own name for the index ("All reports"). The ⌘K palette offers the declared entry, and keeps finding every report the member may open from the reports the app ships, entry or not.
11+
12+
In the Studio, a `report` entry with no report chosen reads as the report index (「报表索引」 / "Report index") instead of an unbound entry, and a save keeps it.
13+
14+
**Migration.** An app that relied on the injected row adds one entry to its navigation where the index belongs: `{ id: 'nav_reports', type: 'report' }`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/i18n': patch
3+
---
4+
5+
feat(i18n): the Studio's navigation inspector names the report index face
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added
9+
10+
New `studio` strings, en and zh: `engine.inspector.appNav.reportIndex` (the empty face of a `report` entry's report picker) and `engine.inspector.appNav.reportIndexHint`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/layout': minor
3+
---
4+
5+
feat(layout): a `report` navigation entry with no `reportName` resolves to the app's report index
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added
9+
10+
`resolveHref` answers `BASE/reports` for a `report` entry that names no report (it answered `#`), so the entry links, and is the active row, on the report index route. A label-less one asks the host's `NavTargetLabelResolver` for the new `{ kind: 'reportIndex' }` target, else shows its `id`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): a `report` navigation item without `reportName` opens the app's report index
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added
9+
10+
`ReportNavItemSchema.reportName` is optional. `{ type: 'report', reportName }` opens that report, as before; `{ type: 'report' }` with no `reportName` opens the app's report index (`/apps/APP/reports`), the list of the reports the app ships that the member may open. Before, an item with no `reportName` was refused (`navigation.N.reportName: expected string, received undefined`). Nothing that parsed before parses differently, and the stack's cross-check of a named `reportName` against `reports` is unchanged.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/types': patch
3+
---
4+
5+
docs(types): `NavigationItem.reportName` says that an omitted name opens the app's report index
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added
9+
10+
The description of the mirror's optional `reportName` now states what its absence means on a `report` entry. No shape changes.

‎content/docs/references/ui/app.mdx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const result = ActionNavItemSchema.parse(data);
194194
| **requiresObject** | `string` | optional | Hide/disable this entry unless the named object is registered in the runtime |
195195
| **requiresService** | `string` | optional | Hide/disable this entry unless the named kernel service is registered |
196196
| **type** | `'report'` | ✅ | |
197-
| **reportName** | `string` | ✅ | Target report name |
197+
| **reportName** | `string` | optional | Target report name. Omit it and the entry opens the app's report index (the reports the app ships that the member may open) instead of one report. |
198198

199199
### Nested Shape: `App.navigation[number][type='action']`
200200

@@ -588,7 +588,7 @@ Documentation entry on the app menu (ADR-0046). Targets a `book` and/or a `doc`
588588
| **requiresObject** | `string` | optional | Hide/disable this entry unless the named object is registered in the runtime |
589589
| **requiresService** | `string` | optional | Hide/disable this entry unless the named kernel service is registered |
590590
| **type** | `'report'` | ✅ | |
591-
| **reportName** | `string` | ✅ | Target report name |
591+
| **reportName** | `string` | optional | Target report name. Omit it and the entry opens the app's report index (the reports the app ships that the member may open) instead of one report. |
592592

593593
### Nested Shape: `NavigationArea.navigation[number][type='action']`
594594

@@ -787,7 +787,7 @@ A navigation contribution: a package injecting nav items into an app it does not
787787
| **requiresObject** | `string` | optional | Hide/disable this entry unless the named object is registered in the runtime |
788788
| **requiresService** | `string` | optional | Hide/disable this entry unless the named kernel service is registered |
789789
| **type** | `'report'` | ✅ | |
790-
| **reportName** | `string` | ✅ | Target report name |
790+
| **reportName** | `string` | optional | Target report name. Omit it and the entry opens the app's report index (the reports the app ships that the member may open) instead of one report. |
791791

792792
### Nested Shape: `NavigationContribution.items[number][type='action']`
793793

@@ -1039,7 +1039,7 @@ This schema accepts one of the following structures:
10391039
| **requiresObject** | `string` | optional | Hide/disable this entry unless the named object is registered in the runtime |
10401040
| **requiresService** | `string` | optional | Hide/disable this entry unless the named kernel service is registered |
10411041
| **type** | `'report'` | ✅ | |
1042-
| **reportName** | `string` | ✅ | Target report name |
1042+
| **reportName** | `string` | optional | Target report name. Omit it and the entry opens the app's report index (the reports the app ships that the member may open) instead of one report. |
10431043

10441044
### Nested Shape: `NavigationItem[type='report'].dataSource`
10451045

@@ -1294,7 +1294,7 @@ Documentation entry on the app menu (ADR-0046). Targets a `book` and/or a `doc`
12941294
| **requiresObject** | `string` | optional | Hide/disable this entry unless the named object is registered in the runtime |
12951295
| **requiresService** | `string` | optional | Hide/disable this entry unless the named kernel service is registered |
12961296
| **type** | `'report'` | ✅ | |
1297-
| **reportName** | `string` | ✅ | Target report name |
1297+
| **reportName** | `string` | optional | Target report name. Omit it and the entry opens the app's report index (the reports the app ships that the member may open) instead of one report. |
12981298

12991299
### Nested Shape: `ReportNavItem.dataSource`
13001300

‎examples/app-showcase/src/ui/apps/index.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export const ShowcaseApp = App.create({
103103
{ id: 'nav_report_chart', type: 'report', reportName: 'showcase_hours_by_status_chart', label: 'Hours by Status (Chart)', icon: 'bar-chart-3' },
104104
{ id: 'nav_report_matrix', type: 'report', reportName: 'showcase_status_priority_matrix', label: 'Status × Priority', icon: 'grid-3x3' },
105105
{ id: 'nav_report_joined', type: 'report', reportName: 'showcase_task_overview', label: 'Task Overview', icon: 'layers' },
106+
// A `report` entry with no `reportName` is the app's report index
107+
// (objectstack#27525): the console injects no index row of its own, so
108+
// the app declares it. No `label`: it shows the console's own name for
109+
// that page.
110+
{ id: 'nav_report_index', type: 'report', icon: 'bar-chart-3' },
106111
],
107112
},
108113
{

‎examples/app-todo/src/apps/todo.app.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export const TodoApp = App.create({
3333
icon: 'chart-bar',
3434
children: [
3535
{ id: 'nav_dashboard', type: 'dashboard', dashboardName: 'task_dashboard', label: 'Dashboard', icon: 'layout-dashboard' },
36+
// The app's report index: a `report` entry with no `reportName`. The
37+
// console draws it only because the app declares it.
38+
{ id: 'nav_reports', type: 'report', icon: 'bar-chart-3' },
3639
]
3740
},
3841
]

‎ui/packages/app-shell/src/chrome/CommandPalette.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,13 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
245245
// objectui#13020 — the app's reports beyond its navigation: the ones it
246246
// ships that this member may open, the list the app's report index shows.
247247
// Read only while the palette is open inside an app; a report a navigation
248-
// entry already names is offered through that entry, once.
248+
// entry already names is offered through that entry, once. A `report` entry
249+
// with no `reportName` is the app's report index (objectstack#27525): it is
250+
// offered as itself, names no report, and leaves every report to this list.
249251
const navReportNames = new Set(
250-
navItems.filter((item) => item.type === 'report').map((item) => item.reportName as string),
252+
navItems
253+
.filter((item) => item.type === 'report' && typeof item.reportName === 'string' && item.reportName !== '')
254+
.map((item) => item.reportName as string),
251255
);
252256
const appReports = useAppReportEntries(activeApp, open && !inStudio, gates).entries.filter(
253257
(entry) => !navReportNames.has(entry.name) && matches(entry.label, entry.name),
@@ -553,7 +557,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
553557
.map(item => (
554558
<CommandItem
555559
key={item.id}
556-
value={`report ${navLabel(item)} ${item.reportName}`}
560+
value={`report ${navLabel(item)} ${item.reportName ?? ''}`}
557561
onSelect={() => leaveTo(resolveHref(item, baseUrl, templateContext).href)}
558562
>
559563
<BarChart3 className="mr-2 h-4 w-4" />

‎ui/packages/app-shell/src/hooks/useNavTargetLabel.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
* A target with no label answers `undefined` — the renderer then falls through
4646
* the spec's ladder and, at the bottom, to the target's machine name.
4747
*
48+
* The app's report index (`reportIndex`, a `report` entry with no
49+
* `reportName`, objectstack#27525) is named by no metadata record: it answers
50+
* the console's own wording for that page, `sidebar.allReports`, the text the
51+
* console's injected index row showed before navigation declared it.
52+
*
4853
* ## A designer's pending drafts — the last rung (objectui#11862)
4954
*
5055
* A draft-only object or dashboard is in no published list, so the metadata
@@ -135,7 +140,7 @@ function listViewsOf(def: LabelledRecord | undefined): Record<string, LabelledRe
135140
export function useNavTargetLabel(): NavTargetLabelResolver {
136141
const metadata = useMetadata();
137142
const { objectLabel, viewLabel, dashboardLabel } = useObjectLabel();
138-
const { language } = useObjectTranslation();
143+
const { language, t } = useObjectTranslation();
139144
const drafts = useContext(DraftTargetLabels);
140145

141146
return useMemo<NavTargetLabelResolver>(
@@ -159,10 +164,12 @@ export function useNavTargetLabel(): NavTargetLabelResolver {
159164
metadataText(def?.label, language) ?? draftText(drafts, 'dashboard', target.dashboardName, language);
160165
return nonEmpty(dashboardLabel({ name: target.dashboardName, label: text ?? '' }));
161166
}
167+
case 'reportIndex':
168+
return nonEmpty(t('sidebar.allReports', { defaultValue: 'All reports' }));
162169
default:
163170
return undefined;
164171
}
165172
},
166-
[metadata, objectLabel, viewLabel, dashboardLabel, language, drafts],
173+
[metadata, objectLabel, viewLabel, dashboardLabel, language, t, drafts],
167174
);
168175
}

0 commit comments

Comments
 (0)