Repository navigation
Commit bb76b8c
feat(spec): the view and dashboard forms offer the audience gate (requiredPermissions) (#37839)
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)_
Part of #34908 — the spec half (step 1 of the ruling's execution). The
console and Studio picker is the second PR; the card stays open for it.
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:管理员在设计器里编辑列表视图或仪表盘时,多出一行「所需权限」,填上能力名,就只有持有该能力的人(经权限集或岗位)能看到;中文、日文、西文界面都有说明文字。
-
为什么做:中文客户要「管理员自己按岗位分视图、不找厂商」;平台的权限门早已由服务器强制执行,只是没有填写入口,这是按维护者选定的「给已有权限门补入口」做的第一步。
-
出错会怎样:填错能力名,或填了设置者本人没有的能力,单独保存的视图或仪表盘对所有人都不可见,包括设置者本人,直接打开也被拒绝;要先在设置里把这个能力授予某人,由他打开后改回。写在对象自身「列表视图」里的视图不同:对象的编辑者仍能看到,删掉这一行的值即可恢复。不涉及数据。
- 要你做什么:无
## What changes
Ruling 7103739693 (letter B) on #34908, verbatim: 「B 给已有权限门补入口 —
控制台和设计器加「谁能看此视图」选择,并显示哪些岗位会看到;不改协议,约2个PR。」 This PR is its step 1: a list
view's and a dashboard's `requiredPermissions` (declared and
server-enforced since ruling 6095014058) gets an authoring row. No key,
value, gate or export changes.
- **Premise (b) proved first** —
`packages/rest/src/meta-view-audience-save-round-trip.test.ts`. The
exact envelope the console's add-view door writes (`viewEnvelope`: the
gate under `config`, beside the object binding), drafted (`PUT
?mode=draft`, `If-None-Match: *`) and published, keeps
`requiredPermissions` in the draft read, the stored active row and the
served item; the read gate then serves a holder and refuses a non-holder
`403 PERMISSION_DENIED`. An edit that clears the gate stores no key and
serves the non-holder again. Control: an ungated view is served to
everyone. Real routes, real `saveMetaItem`, better-sqlite3
`sys_metadata`. The save door does not strip or refuse the key, so no
fork.
- **`packages/spec/src/ui/view.form.ts`** — the `navigation_sharing`
section gains a `requiredPermissions` row (`string-tags`, the face
`app.form.ts` and `action.form.ts` use).
- **`packages/spec/src/ui/dashboard.form.ts`** — a new collapsed
`Access` section holding the same row.
- The two hints restate the clauses of
`AUDIENCE_REQUIRED_PERMISSIONS_DESCRIPTION` (all of them required, empty
is no gate, no any-of form, enforced by the server) in an
administrator's words, and add what an administrator needs: a position
passes on what its permission sets grant, and the gate applies to the
person setting it too (a capability they do not hold, or a misspelt one,
refuses the view or dashboard to them on every door, Studio included).
They are worded for the person building the view, not copied verbatim
from the describe, because the dashboard panel's hints are held to
business wording (#36816).
-
**`packages/spec/src/system/metadata-form-zod-reconciliation.test.ts`**
— the two `omit` ledger entries for `view` / `dashboard`
`requiredPermissions` are dropped. Their own reason was "declared, not
enforced yet … whether to offer it then is a ruling for the
enforcement"; the gate has been live since #22639 and the offer is now
ruled.
- **Translations** — `node scripts/check-i18n-bundles.mjs --write`;
zh-CN (「所需权限」 / 「访问权限」), ja-JP and es-ES leaves authored, the other
seven locales left as extractor fills. The console's zh-CN overlay
(`metadata-form-zh-cn.ts` for `view`, `metadata-form-i18n.ts` for
`dashboard`) carries the same zh words. The translated-label positive
control in `object-lifecycle-panel-echo-decisions.test.ts` moves 840 →
843 (two row labels + one section label).
## Tests
<details><summary>Commands and results (head bd91d5c after merging
origin/main)</summary>
- Round 2 (L1-a 7211677883), head 98b17b2: `platform-objects`
`src/apps/translations/` 28 files, 625 tests passed; spec `src/ui/` +
`metadata-form-zod-reconciliation` 195 files, 6750 tests passed; ui
`packages/app-shell/src/views/metadata-admin/` 804 files, 8686 passed, 1
skipped; `check:generated` 14/14; `check:i18n` and
`check:i18n-stale-fill` OK. The round-1 results below are at bd91d5c.
- `pnpm --filter @objectstack/rest exec vitest run
src/meta-view-audience-save-round-trip.test.ts` → Test Files 1 passed,
Tests 3 passed (re-run after the merge).
- `packages/spec`: `vitest run src/ui/
src/kernel/repeater-item-titles.test.ts src/system` → 273 files; 1
failure (the ledger entries this PR drops), green once they were
dropped: `metadata-form-zod-reconciliation.test.ts` 79/79; after the
merge, that file plus `view-form-composite-children` and
`dashboard-form-business-wording-36816`: 3 files, 110 tests passed.
- `packages/platform-objects`: `vitest run src/` → 130 files, 2214 tests
passed (after the ja-JP / es-ES wording and the 843 control); after the
merge `src/apps/translations/` 28 files, 625 tests passed.
- `ui`: `pnpm exec vitest run
packages/app-shell/src/views/metadata-admin/
packages/plugin-designer/src/__tests__/designerForms.sharedSelect-11865.test.tsx`
→ 805 files, 8786 passed, 1 skipped.
- `pnpm --filter @objectstack/rest typecheck` → exit 0 (test layer
included).
- `pnpm --filter @objectstack/spec check:generated` after the merge and
a spec rebuild → all 14 generated artifacts up to date.
</details>
<details><summary>Derived gates (dispatch-gates --commands, 93
families)</summary>
- Round 2, head 98b17b2: 93 derived, 93 run, 0 NOT-MEASURED, 0 UNRUN.
92 exited 0 on the sweep; `pnpm --dir ui exec vitest run scripts/` was
SIGKILLed while the ui suite ran beside it and re-ran alone green (172
files passed, 2 skipped). The round-1 lines below are at bd91d5c.
- 93 derived, 93 run (`--ran` reconciliation: 0 NOT-MEASURED, 0 UNRUN).
- 87 exited 0 on the first pass. 5 exited 3 (prerequisite) and were
re-run green: the four spec `dist` readers (`check:api-surface`,
`check:dual-source-exports`, `check:entry-nameability`,
`check:exported-any`) after a spec rebuild, and
`check-plugin-teardown-shape --self-test` after unshallowing the clone.
`check:authorable-surface`, `check:docs`, `check:i18n` and
`check:i18n-stale-fill` were re-run green after the last translation
edit.
- NOT MEASURED: `check:dual-build-cjs-loads`, reason: it needs every
package's `dist/` (a full `pnpm build`); this diff changes no package's
build shape. CI runs it.
</details>
## Acceptance notes
- The ruling names the Studio list-view inspector as
`ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx`;
that file no longer exists on `main`. Studio's view panel is
`metadata-admin/inspectors/ViewVariantInspector.tsx`, which renders
`viewForm` through `SchemaForm`, so the new row already appears there as
a tag box. The capability picker (limited to the capabilities the
environment knows) with the "which positions will see it" preview
replaces that tag box in the second PR, together with the 新建视图 control,
the shared-hint correction and the `capabilities.mdx` recipe.
- The other seven locales (ar, de, fr, ko, pt-BR, ru, zh-Hant) read the
English source for the three new leaves, as every recent form row has
landed.
## Verification
Open Studio on any list view, expand 导航与共享: the 所需权限 row is there with
its hint. Type a capability name and publish: a user without it no
longer sees the view in the switcher, and opening its URL answers 403.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxDBbvf7dEeutsepbm)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b620c4b commit bb76b8c
26 files changed
Lines changed: 432 additions & 22 deletions
File tree
- .changeset
- packages
- platform-objects/src/apps/translations
- rest/src
- spec/src
- system
- ui
- ui/packages/app-shell/src/views/metadata-admin
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1659 | 1659 | | |
1660 | 1660 | | |
1661 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1662 | 1666 | | |
1663 | 1667 | | |
1664 | 1668 | | |
| |||
1874 | 1878 | | |
1875 | 1879 | | |
1876 | 1880 | | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1877 | 1885 | | |
1878 | 1886 | | |
1879 | 1887 | | |
| |||
2054 | 2062 | | |
2055 | 2063 | | |
2056 | 2064 | | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
2057 | 2069 | | |
2058 | 2070 | | |
2059 | 2071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1659 | 1659 | | |
1660 | 1660 | | |
1661 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1662 | 1666 | | |
1663 | 1667 | | |
1664 | 1668 | | |
| |||
1874 | 1878 | | |
1875 | 1879 | | |
1876 | 1880 | | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1877 | 1885 | | |
1878 | 1886 | | |
1879 | 1887 | | |
| |||
2054 | 2062 | | |
2055 | 2063 | | |
2056 | 2064 | | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
2057 | 2069 | | |
2058 | 2070 | | |
2059 | 2071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
| 131 | + | |
| 132 | + | |
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1659 | 1659 | | |
1660 | 1660 | | |
1661 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1662 | 1666 | | |
1663 | 1667 | | |
1664 | 1668 | | |
| |||
1874 | 1878 | | |
1875 | 1879 | | |
1876 | 1880 | | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1877 | 1885 | | |
1878 | 1886 | | |
1879 | 1887 | | |
| |||
2054 | 2062 | | |
2055 | 2063 | | |
2056 | 2064 | | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
2057 | 2069 | | |
2058 | 2070 | | |
2059 | 2071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1659 | 1659 | | |
1660 | 1660 | | |
1661 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1662 | 1666 | | |
1663 | 1667 | | |
1664 | 1668 | | |
| |||
1874 | 1878 | | |
1875 | 1879 | | |
1876 | 1880 | | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1877 | 1885 | | |
1878 | 1886 | | |
1879 | 1887 | | |
| |||
2054 | 2062 | | |
2055 | 2063 | | |
2056 | 2064 | | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
2057 | 2069 | | |
2058 | 2070 | | |
2059 | 2071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1659 | 1659 | | |
1660 | 1660 | | |
1661 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1662 | 1666 | | |
1663 | 1667 | | |
1664 | 1668 | | |
| |||
1874 | 1878 | | |
1875 | 1879 | | |
1876 | 1880 | | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1877 | 1885 | | |
1878 | 1886 | | |
1879 | 1887 | | |
| |||
2054 | 2062 | | |
2055 | 2063 | | |
2056 | 2064 | | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
2057 | 2069 | | |
2058 | 2070 | | |
2059 | 2071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| |||
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
| 167 | + | |
| 168 | + | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
| |||
0 commit comments