Skip to content

Commit 0b539b6

Browse files
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/platform-objects': patch
4+
'@object-ui/app-shell': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(app-shell): 「Who sees this view」 — pick a shared view's or a dashboard's audience from the known capabilities, and see which positions will see it
9+
10+
Clause-②: no
11+
Metadata-protocol: none
12+
13+
The audience gate is the existing, server-enforced `requiredPermissions` (all of the capabilities listed are required). The console now sets it from a closed list and shows who it reaches; no key, value or gate changes, and nothing is granted from the view (granting stays in Setup).
14+
15+
- **`@object-ui/app-shell`.** The view switcher's in-place create card offers 「Who sees this view」 for a shared view: the capabilities the environment knows (declared, or granted by a permission set), each with the permission sets granting it, and a read-only preview of the positions whose permission sets grant every capability picked. The preview reads each position's sets from the server (`GET /meta/position?include=grants`, the sets the resolver grants its holders), never from a position's raw definition; a list served without them leaves the positions unknown. While a gate is picked, the card says it applies to its creator too. It starts from the open view's gate, which a new shared view used to inherit silently, and the pick replaces it; an empty pick writes no gate. A failed catalog read offers nothing to type. The shared hint no longer says every shared view is seen by everyone who can see the list. In Studio, the view panel's and the dashboard settings' audience row is the new `ref-multi:capability` picker: a closed list (no typed-name box when the catalog is unread, empty or failed), each option with its granting sets, and the same preview under it. The picker reads the catalog once its row is on screen, so an editor whose audience section stays closed sends no request.
16+
- **`@objectstack/spec`.** The view and dashboard forms' `requiredPermissions` rows declare `widget: 'ref-multi:capability'` (the list is closed: a host with no catalog offers nothing to add). The view hint's last sentence now says only what holds on every carrier: the person setting the gate no longer sees the view in the list either.
17+
- **`@objectstack/platform-objects`.** The `metadataForms` bundles carry the narrowed view hint (zh-CN, ja-JP and es-ES translated; the other locales the English source).
18+
- **`@object-ui/i18n`.** The create card's new strings and the corrected shared hint, in all eleven console locales.
19+
20+
Nothing to migrate.

‎content/docs/permissions/capabilities.mdx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,49 @@ the same way; a user who may edit the object still reads all of its list views,
197197
so a save of what they loaded keeps them.
198198
</Callout>
199199

200+
## Showing a list view to some positions, without code
201+
202+
An administrator can decide who sees a shared list view or a dashboard in the
203+
console, with no source file. The gate is the same `requiredPermissions` as
204+
above, and the console only sets it; it grants nothing. Granting stays in
205+
Setup.
206+
207+
1. **Have a capability for the audience.** Use one your app declares, or
208+
declare one in the environment
209+
([below](#declaring-a-capability-in-the-environment)). One capability per
210+
audience, for example `crm_deal.view_sales` for "the sales team's deal
211+
view".
212+
2. **Grant it in Setup.** Add the name to the `systemPermissions` of a
213+
permission set, and give that set to the positions that should see the
214+
view. A position carries no capability of its own: it passes on what its
215+
permission sets grant. To show the view to two groups, grant the one
216+
capability to both groups' sets.
217+
3. **Pick it on the view.** In the view switcher, **Add view → Shared** offers
218+
**Who sees this view**. For an existing view, Studio's view panel has
219+
**Required permissions** under **Navigation & sharing**, and a dashboard's
220+
settings have it under **Access**. Both list only the capabilities the
221+
environment knows, that is the ones declared and the ones a permission set
222+
grants, with the sets granting each. You cannot type a name that matches
223+
nothing there.
224+
225+
Under the pick, the console previews the positions that will see the view: the
226+
positions whose permission sets grant **every** capability picked. It reads
227+
which sets each position grants from the server, the sets the resolver grants
228+
its holders, so a position that has been switched off reaches no one. The preview is
229+
still advice, and the server stays the authority: it cannot name people who
230+
hold a set directly rather than through a position, nor people who hold the
231+
picked capabilities between several positions. A person holds everything each
232+
of their positions grants, so two positions that each grant part of the pick
233+
let their joint holders through.
234+
235+
<Callout type="warn">
236+
**The gate applies to you too.** Pick a capability you do not hold, and the view
237+
leaves your own view switcher as well. A view or a dashboard saved on its own
238+
is then refused to you on every door, Studio included, until someone grants
239+
you the capability. Grant it to your own permission set first if you still need
240+
to open the view.
241+
</Callout>
242+
200243
## One holder per name
201244

202245
Each capability name has exactly one holder in the registry. When a package
@@ -303,6 +346,7 @@ copy and the two would share one gate. Prefix your capability names.
303346
- [ ] The declaration is reachable from the stack (`capabilities: [...]`) or a `*.capability.ts` file
304347
- [ ] No other installed package declares the same name — the registry refuses a second holder at boot
305348
- [ ] Something actually **requires** the name (`requiredPermissions`), and something **grants** it (`systemPermissions`)
349+
- [ ] A list view or dashboard gated from the console: its capability is granted to the positions' permission sets, and to your own if you still need to open it
306350

307351
## See also
308352

‎packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ export const arMetadataForms: NonNullable<TranslationData['metadataForms']> = {
16611661
},
16621662
requiredPermissions: {
16631663
label: "Required Permissions",
1664-
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you can no longer open this view either."
1664+
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you no longer see this view in the list either."
16651665
},
16661666
object: {
16671667
label: "الكائن"

‎packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const arGeneratedSourceHashes: Readonly<Record<string, string>> = {
6767
"metadataForms.report.fields.exportOptions.formats.label": "193cd91818d64ef7",
6868
"metadataForms.report.fields.exportOptions.includeHeaders.helpText": "44cbc80015ff051d",
6969
"metadataForms.report.fields.exportOptions.includeHeaders.label": "f114a4778c9727ae",
70-
"metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02",
70+
"metadataForms.view.fields.requiredPermissions.helpText": "824ea3479e2e607a",
7171
"metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68",
7272
"objects.sys_email.fields.message_id.label": "14cd089a4062f4b1",
7373
"objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc",

‎packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ export const deMetadataForms: NonNullable<TranslationData['metadataForms']> = {
16611661
},
16621662
requiredPermissions: {
16631663
label: "Required Permissions",
1664-
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you can no longer open this view either."
1664+
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you no longer see this view in the list either."
16651665
},
16661666
object: {
16671667
label: "Objekt"

‎packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const deGeneratedSourceHashes: Readonly<Record<string, string>> = {
128128
"metadataForms.view.fields.kanban.label": "dd95c452aa71459e",
129129
"metadataForms.view.fields.name.label": "5274417ff1ccaf01",
130130
"metadataForms.view.fields.navigation.label": "51cd9fc784a9643f",
131-
"metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02",
131+
"metadataForms.view.fields.requiredPermissions.helpText": "824ea3479e2e607a",
132132
"metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68",
133133
"metadataForms.view.fields.userActions.filter.label": "802895ec427fc6af",
134134
"metadataForms.view.fields.userFilters.element.label": "e480e4fe57239c98",

‎packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
16611661
},
16621662
requiredPermissions: {
16631663
label: "Required Permissions",
1664-
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you can no longer open this view either."
1664+
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you no longer see this view in the list either."
16651665
},
16661666
object: {
16671667
label: "Object"

‎packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ export const esESMetadataForms: NonNullable<TranslationData['metadataForms']> =
16611661
},
16621662
requiredPermissions: {
16631663
label: "Permisos requeridos",
1664-
helpText: "Quién ve esta vista: las capacidades que una persona debe tener, todas las indicadas. Los conjuntos de permisos otorgan capacidades, y un puesto transmite las que otorgan sus conjuntos de permisos. Si se deja vacío, todos los que pueden ver la lista ven esta vista. Para mostrarla a varios grupos, elija una capacidad y otórguela al conjunto de permisos de cada grupo. El servidor lo aplica: los demás no encuentran la vista en la lista y se les deniega si la abren directamente. Esto también se aplica a usted: si indica una capacidad que no tiene, o la escribe mal, usted tampoco podrá volver a abrir esta vista."
1664+
helpText: "Quién ve esta vista: las capacidades que una persona debe tener, todas las indicadas. Los conjuntos de permisos otorgan capacidades, y un puesto transmite las que otorgan sus conjuntos de permisos. Si se deja vacío, todos los que pueden ver la lista ven esta vista. Para mostrarla a varios grupos, elija una capacidad y otórguela al conjunto de permisos de cada grupo. El servidor lo aplica: los demás no encuentran la vista en la lista y se les deniega si la abren directamente. Esto también se aplica a usted: si indica una capacidad que no tiene, o la escribe mal, usted tampoco verá esta vista en la lista."
16651665
},
16661666
object: {
16671667
label: "Objeto"

‎packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ export const frMetadataForms: NonNullable<TranslationData['metadataForms']> = {
16611661
},
16621662
requiredPermissions: {
16631663
label: "Required Permissions",
1664-
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you can no longer open this view either."
1664+
helpText: "Who sees this view: the capabilities a person must hold, every one listed. Permission sets grant capabilities, and a position passes on the ones its permission sets grant. Leave it empty and everyone who can see the list sees this view. To show it to several groups, pick one capability and grant it to each group's permission set. The server enforces it: anyone else does not find the view in the list and is refused if they open it directly. The gate applies to you too: list a capability you do not hold, or misspell one, and you no longer see this view in the list either."
16651665
},
16661666
object: {
16671667
label: "Objet"

‎packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const frGeneratedSourceHashes: Readonly<Record<string, string>> = {
164164
"metadataForms.view.fields.navigation.label": "51cd9fc784a9643f",
165165
"metadataForms.view.fields.navigation.mode.label": "74dde5013435abdc",
166166
"metadataForms.view.fields.pagination.label": "309131fbaca258df",
167-
"metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02",
167+
"metadataForms.view.fields.requiredPermissions.helpText": "824ea3479e2e607a",
168168
"metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68",
169169
"metadataForms.view.fields.selection.type.label": "901bb552898b2cab",
170170
"metadataForms.view.fields.type.label": "901bb552898b2cab",

0 commit comments

Comments
 (0)