Repository navigation
Commit 0b539b6
feat(app-shell): pick who sees a shared view or dashboard from the known capabilities, with the positions it reaches (#37906)
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao3jNGx6LmWH1CGtjYoMw3yP)_
Fixes #34908 — the console and Studio half (step 2 of the ruling's
execution, with step 3's docs recipe). Part 1 was #37839.
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:新建共享视图时多出「谁能看此视图」,只能从环境里已有的能力中选,每项显示由哪些权限集授予,下方直接写出「哪些岗位会看到此视图」;Studio
的视图面板和仪表盘设置里的「所需权限」也换成同一个选择器和岗位预览。共享视图的提示不再说「所有能看到列表的人都能看到」。
- 为什么做:维护者选定的「给已有权限门补入口」第二步——管理员自己按岗位分视图、不找厂商;第一步(表单行)已在 #37839 合入。
-
出错会怎样:选了自己没有的能力,该视图会从自己的视图切换器里消失;单独保存的视图或仪表盘对设置者本人也会被拒绝打开,要先在设置里把能力授予自己再改回。预览只是参考,服务器的权限门才是准绳。不改数据、不改协议。
- 要你做什么:无
## What changes
Ruling 7103739693 (letter B), verbatim: 「B 给已有权限门补入口 —
控制台和设计器加「谁能看此视图」选择,并显示哪些岗位会看到;不改协议,约2个PR。」 The gate is the existing,
server-enforced `requiredPermissions` (all-of); no key, value, gate or
any-of form is added, and the view surface grants nothing.
- **The catalog** —
`ui/packages/app-shell/src/views/capabilityAudience.ts` joins three
registry reads: `capability` (declared), `permission` (each set's
`systemPermissions`) and `position` (each position's `permissionSets`).
The names offered are the declared capabilities plus every name a set
grants, the same "known capability" set `@objectstack/lint`'s capability
references resolve against, so the list is closed. A position holds only
what its named sets grant (ADR-0131 D3/D4). A failed position read keeps
the catalog and says the positions are unknown; a failed capability or
set read fails the load.
- **The preview** — `positionsReached`: a position is listed when its
sets grant EVERY picked capability. It is advisory: it does not read set
activation and cannot name people who hold a set directly.
- **新建视图 (the switcher's create card)** — `CreateViewCard` offers 「Who
sees this view」 (`ViewAudiencePicker.tsx`) in the shared scope only,
read once the reader picks Shared (`ObjectView` hands the loader).
Closed list, each option with its granting sets, the position preview
under it, and no free-text fallback: a failed read offers nothing to
add. It starts from the open view's gate, which `buildInPlaceViewConfig`
used to hand on silently; `useCreateViewInPlace` lets the pick replace
it, and an empty pick writes no key. With no picker (personal scope, or
no loader) the body is built as before.
- **The shared hint** (`CreateViewDialog.tsx`) — now "Shared views are
seen by everyone who can see this list, unless the view is limited to
the holders of a capability", in all eleven console locales.
- **Studio** — a `ref-multi:capability` widget (`widgets.tsx`, the
`ref-multi:permission` registration's sibling) with the preview as the
list's footer. `view.metadata-form.ts` and `dashboard.metadata-form.ts`
declare it on the audience row. `ViewVariantInspector`,
`DashboardDefaultInspector` and `ResourceEditPage` hand down a loader
(`WidgetContext.loadCapabilityAudience`, `useCapabilityAudienceLoader`);
the picker reads it once its row is on screen, so a closed Access
section sends no request, and a catalog the host already holds still
wins. The widget is a closed registry: no typed-name box when the
catalog is unread, empty or failed; each option shows "Granted by …".
The dashboard inspector handed down no `WidgetContext` before; it now
states `conditionScopeForMetadataType('dashboard')` (`none`), and the
dashboard form declares no `condition` row, so nothing else renders
differently.
- **N5 (carried from #37839)** — the view hint's last sentence now says
what holds on every carrier: the person setting the gate no longer sees
the view in the list either. (A view item is refused on every door, but
an entry kept in its object's view set stays open to that set's editors
in the designer.) en source, zh-CN / ja-JP / es-ES leaves, the console
zh-CN overlay; the seven fill locales carry the new English.
- **Docs** — `content/docs/permissions/capabilities.mdx` gains "Showing
a list view to some positions, without code": have a capability, grant
it to the positions' permission sets in Setup, pick it on the view, read
the preview, and the warning that the gate applies to the person setting
it. One checklist line. No page moved; the recipe exists nowhere else in
`content/docs/permissions/`.
## Tests
<details><summary>Commands and results (head 9731b21, the L1 rework
fix, comment 7217699980)</summary>
- `ui`: `pnpm exec vitest run
packages/app-shell/src/views/viewAudience-34908.test.tsx` → 19 passed:
the catalog join, the all-of preview, the failed position read, the card
(hint, shared-only and lazy read, closed list with sets, preview,
starting gate removable, failed read offers nothing, control: personal /
no loader send no gate), the host (pick replaces the inherited gate,
empty pick writes none, control: no picker keeps it), the Studio widget
(preview, `(not found)` flag, empty, control: no catalog no preview).
- `ui`: the above with `inPlaceViewCreate-35553.test.tsx` and
`SchemaForm.widgetLabelling.test.tsx` (two new probe cases for
`ref-multi:capability`) → 3 files, 126 tests passed.
- `ui`: at the fix head, 5 files, 135 tests passed:
`viewAudience-34908`, `SchemaForm.widgetLabelling`,
`DashboardDefaultInspector.layoutColumns-11796`,
`AddWidgetPicker.oneRegistry-26745` (the two that reached
`/meta/capability` at `f67c1e60c5`) and `WidgetContext.catalogUnion`;
two new cases pin the lazy loader (no request until the collapsed
section opens, then exactly one; no loader call when a catalog is
given).
- `ui/packages/app-shell`: `tsc --noEmit` and `tsc -p
tsconfig.test.json` → exit 0.
- `check:i18n`, `check:i18n-stale-fill`, `check:test-source-alias` → OK.
</details>
<details><summary>Derived gates (dispatch-gates --commands)</summary>
- 114 derived, 114 run (`--ran` reconciliation: 0 NOT-MEASURED, 0
UNRUN); all 114 exited 0 at head 9731b21 (six spec gates first
answered exit 3 on a stale dts and exited 0 after a spec rebuild); the
changeset-only last commit re-derives the same 114. CI at `2156f1acc8`:
61 success, 9 skipped, 0 failed.
- During development `check:test-source-alias` asked the new test to
load `@objectstack/lint` and `@objectstack/formula` at module top (the
source reaches both through dynamic imports); done, and the gate is
green.
</details>
## Acceptance notes
- The ruling names the Studio list-view inspector
`studio-design/ObjectListViewInspector.tsx`; that file is gone from
`main`. The picker lands in Studio's view panel,
`metadata-admin/inspectors/ViewVariantInspector.tsx`, through the form
row.
- The acceptance line reads "业务员 will see this view"; the card says
`{{positions}} will see this view` (zh `{{positions}} 会看到此视图`), listing
position labels.
## Verification
In the console, open a list, 视图 → 添加视图 → 共享: 「谁能看此视图」 lists the
environment's capabilities. Pick one granted to the 业务员 position's
permission set: the line under it reads 「业务员 会看到此视图」. Create: a user
without the capability no longer sees the view in the switcher, and
opening its URL answers 403. In Studio, the view's 导航与共享 → 所需权限 shows
the same picker and preview.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibxDBbvf7dEeutsepbm
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 21ad7c5 commit 0b539b6
49 files changed
Lines changed: 1352 additions & 42 deletions
File tree
- .changeset
- content/docs/permissions
- packages
- platform-objects/src/apps/translations
- spec/src/ui
- ui/packages
- app-shell/src/views
- metadata-admin
- inspectors
- i18n/src
- locales
- namespaces/studio
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
200 | 243 | | |
201 | 244 | | |
202 | 245 | | |
| |||
303 | 346 | | |
304 | 347 | | |
305 | 348 | | |
| 349 | + | |
306 | 350 | | |
307 | 351 | | |
308 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1661 | 1661 | | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | | - | |
| 1664 | + | |
1665 | 1665 | | |
1666 | 1666 | | |
1667 | 1667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1661 | 1661 | | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | | - | |
| 1664 | + | |
1665 | 1665 | | |
1666 | 1666 | | |
1667 | 1667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1661 | 1661 | | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | | - | |
| 1664 | + | |
1665 | 1665 | | |
1666 | 1666 | | |
1667 | 1667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1661 | 1661 | | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | | - | |
| 1664 | + | |
1665 | 1665 | | |
1666 | 1666 | | |
1667 | 1667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1661 | 1661 | | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | | - | |
| 1664 | + | |
1665 | 1665 | | |
1666 | 1666 | | |
1667 | 1667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
0 commit comments