diff --git a/.changeset/34908-view-dashboard-audience-form-row.md b/.changeset/34908-view-dashboard-audience-form-row.md new file mode 100644 index 00000000000..289417abc08 --- /dev/null +++ b/.changeset/34908-view-dashboard-audience-form-row.md @@ -0,0 +1,18 @@ +--- +'@objectstack/spec': patch +'@objectstack/platform-objects': patch +'@object-ui/app-shell': patch +--- + +feat(spec): the view and dashboard authoring forms offer the audience gate, `requiredPermissions` + +Clause-②: no +Metadata-protocol: none + +A list view's and a dashboard's `requiredPermissions` (the capabilities a caller must all hold to be served the item) has been enforced by the server's `/meta` read gate since it landed, but no authoring form offered it, so only a source file could set it. Both forms now carry the row; no key, value or gate changes. + +- **`@objectstack/spec`.** `viewForm`'s "Navigation & sharing" section gains a `requiredPermissions` row (tags), and `dashboardForm` a new "Access" section holding the same row. The hint states the gate's rules in an administrator's words: every capability listed is required, an empty list is no gate, one capability granted to several permission sets is how to serve several groups, 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, locks them out of the item as well). +- **`@objectstack/platform-objects`.** The `metadataForms` bundles carry the new rows; zh-CN (「所需权限」), ja-JP (「必要な権限」) and es-ES ("Permisos requeridos") carry translated labels and hints; the other seven locales fall back to the English source until translated. +- **`@object-ui/app-shell`.** The console's zh-CN overlay for the two forms carries the same rows, so Studio's view inspector and the dashboard settings panel show them in Chinese. + +Nothing to migrate. diff --git a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts index 3824a0fb823..77aa571ceb3 100644 --- a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const arMetadataForms: NonNullable = { label: "مقفل بواسطة", helpText: "المستخدم الذي قفل تهيئة طريقة العرض" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "الكائن" } @@ -1874,6 +1878,10 @@ export const arMetadataForms: NonNullable = { label: "عوامل التصفية", description: "عوامل التصفية الافتراضية والعامة المطبَّقة على عناصر الواجهة." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "متقدم", description: "ضبط إمكانية الوصول والأداء." @@ -2054,6 +2062,10 @@ export const arMetadataForms: NonNullable = { }, "globalFilters.targetWidgets": { label: "عناصر الواجهة المستهدفة" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts index 994dfe6f133..1aa6247cb11 100644 --- a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts @@ -42,6 +42,10 @@ export const arGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.defaultRange.label": "c1f190468a0e2b35", "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.email_template.fields.fromOverride.helpText": "c5e29fa12ee1525b", "metadataForms.email_template.fields.variables.helpText": "27197774c2cda633", "metadataForms.field.fields.inlineEdit.helpText": "1ce60e4c6d5fc0e1", @@ -63,6 +67,8 @@ export const arGeneratedSourceHashes: Readonly> = { "metadataForms.report.fields.exportOptions.formats.label": "193cd91818d64ef7", "metadataForms.report.fields.exportOptions.includeHeaders.helpText": "44cbc80015ff051d", "metadataForms.report.fields.exportOptions.includeHeaders.label": "f114a4778c9727ae", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", diff --git a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts index 4224e854ce1..1918baa469d 100644 --- a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const deMetadataForms: NonNullable = { label: "Gesperrt von", helpText: "Benutzer, der die Ansichtskonfiguration gesperrt hat" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "Objekt" } @@ -1874,6 +1878,10 @@ export const deMetadataForms: NonNullable = { label: "Filter", description: "Standard- und globale Filter, die auf alle Widgets angewendet werden." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "Erweitert", description: "Barrierefreiheit und Leistungsoptimierung." @@ -2054,6 +2062,10 @@ export const deMetadataForms: NonNullable = { }, "globalFilters.targetWidgets": { label: "Ziel-Widgets" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts index f83bb1bd045..16eebeb04a9 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts @@ -56,8 +56,12 @@ export const deGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", "metadataForms.dashboard.fields.name.label": "5274417ff1ccaf01", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", "metadataForms.dashboard.fields.widgets.label": "bd4bf82396edd638", "metadataForms.dashboard.label": "b03d84f15ecdbb1e", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.dashboard.sections.layout.label": "7f508ea1bb2c3a6b", "metadataForms.dashboard.sections.widgets.label": "bd4bf82396edd638", "metadataForms.dataset.fields.filter.label": "802895ec427fc6af", @@ -124,6 +128,8 @@ export const deGeneratedSourceHashes: Readonly> = { "metadataForms.view.fields.kanban.label": "dd95c452aa71459e", "metadataForms.view.fields.name.label": "5274417ff1ccaf01", "metadataForms.view.fields.navigation.label": "51cd9fc784a9643f", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "metadataForms.view.fields.userActions.filter.label": "802895ec427fc6af", "metadataForms.view.fields.userFilters.element.label": "e480e4fe57239c98", "metadataForms.view.sections.gantt.label": "57ffc6ef520edfc5", diff --git a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts index d39f7291126..25f673b19c7 100644 --- a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const enMetadataForms: NonNullable = { label: "Locked By", helpText: "User who locked the view configuration" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "Object" } @@ -1874,6 +1878,10 @@ export const enMetadataForms: NonNullable = { label: "Filters", description: "Default and global filters applied across widgets." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "Advanced", description: "Accessibility and performance tuning." @@ -2054,6 +2062,10 @@ export const enMetadataForms: NonNullable = { }, "globalFilters.targetWidgets": { label: "Target Widgets" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts index 26a0e309d50..ca94e15f7bd 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const esESMetadataForms: NonNullable = label: "Bloqueado por", helpText: "Usuario que bloqueó la configuración de la vista" }, + requiredPermissions: { + label: "Permisos requeridos", + 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." + }, object: { label: "Objeto" } @@ -1874,6 +1878,10 @@ export const esESMetadataForms: NonNullable = label: "Filtros", description: "Filtros predeterminados y globales aplicados a todos los widgets." }, + access: { + label: "Acceso", + description: "Quién puede ver este panel." + }, advanced: { label: "Avanzado", description: "Ajustes de accesibilidad y rendimiento." @@ -2054,6 +2062,10 @@ export const esESMetadataForms: NonNullable = }, "globalFilters.targetWidgets": { label: "Widgets de destino" + }, + requiredPermissions: { + label: "Permisos requeridos", + helpText: "Quién ve este panel: 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 ven este panel. Para mostrarlo 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 el panel en la lista y se les deniega si lo 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 este panel." } } }, diff --git a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts index cbf07da91fd..afa5dd31ca6 100644 --- a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const frMetadataForms: NonNullable = { label: "Verrouillé par", helpText: "Utilisateur qui a verrouillé la configuration de la vue" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "Objet" } @@ -1874,6 +1878,10 @@ export const frMetadataForms: NonNullable = { label: "Filtres", description: "Filtres par défaut et globaux appliqués à l’ensemble des widgets." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "Avancé", description: "Réglages d’accessibilité et de performances." @@ -2054,6 +2062,10 @@ export const frMetadataForms: NonNullable = { }, "globalFilters.targetWidgets": { label: "Widgets cibles" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts index 9042e6b4b19..ebd32ddebcd 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts @@ -64,7 +64,11 @@ export const frGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", "metadataForms.dashboard.fields.description.label": "779a4342c8eb6707", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", "metadataForms.dashboard.fields.widgets.label": "bd4bf82396edd638", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.dashboard.sections.widgets.label": "bd4bf82396edd638", "metadataForms.dataset.fields.description.label": "779a4342c8eb6707", "metadataForms.dataset.fields.dimensions.label": "d75e6dd9d87e93b4", @@ -160,6 +164,8 @@ export const frGeneratedSourceHashes: Readonly> = { "metadataForms.view.fields.navigation.label": "51cd9fc784a9643f", "metadataForms.view.fields.navigation.mode.label": "74dde5013435abdc", "metadataForms.view.fields.pagination.label": "309131fbaca258df", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "metadataForms.view.fields.selection.type.label": "901bb552898b2cab", "metadataForms.view.fields.type.label": "901bb552898b2cab", "metadataForms.view.sections.gantt.label": "57ffc6ef520edfc5", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts index 99928c9151c..921d9a48fef 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const jaJPMetadataForms: NonNullable = label: "ロックしたユーザー", helpText: "ビューの設定をロックしたユーザー" }, + requiredPermissions: { + label: "必要な権限", + helpText: "このビューを見られる人:閲覧者が保持する必要のあるケイパビリティで、列挙したものはすべて必要です。ケイパビリティは権限セットが付与し、ポジションはその権限セットが付与するものを引き継ぎます。空にすると、リストを見られる全員がこのビューを見られます。複数のグループに見せるには、ケイパビリティを 1 つ選び、各グループの権限セットに付与してください。サーバーが強制します:それ以外の人にはリストにこのビューが表示されず、直接開いても拒否されます。これはあなた自身にも適用されます:保持していないケイパビリティや綴りを誤ったケイパビリティを指定すると、あなたもこのビューを開けなくなります。" + }, object: { label: "オブジェクト" } @@ -1874,6 +1878,10 @@ export const jaJPMetadataForms: NonNullable = label: "フィルター", description: "ウィジェット全体に適用する既定およびグローバルフィルター。" }, + access: { + label: "アクセス", + description: "このダッシュボードを見られる人。" + }, advanced: { label: "詳細", description: "アクセシビリティとパフォーマンス調整。" @@ -2054,6 +2062,10 @@ export const jaJPMetadataForms: NonNullable = }, "globalFilters.targetWidgets": { label: "対象ウィジェット" + }, + requiredPermissions: { + label: "必要な権限", + helpText: "このダッシュボードを見られる人:閲覧者が保持する必要のあるケイパビリティで、列挙したものはすべて必要です。ケイパビリティは権限セットが付与し、ポジションはその権限セットが付与するものを引き継ぎます。空にすると、全員がこのダッシュボードを見られます。複数のグループに見せるには、ケイパビリティを 1 つ選び、各グループの権限セットに付与してください。サーバーが強制します:それ以外の人にはリストにこのダッシュボードが表示されず、直接開いても拒否されます。これはあなた自身にも適用されます:保持していないケイパビリティや綴りを誤ったケイパビリティを指定すると、あなたもこのダッシュボードを開けなくなります。" } } }, diff --git a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts index 83feba69934..671ad38fc06 100644 --- a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const koMetadataForms: NonNullable = { label: "잠근 작업자", helpText: "뷰 구성을 잠근 사용자" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "객체" } @@ -1874,6 +1878,10 @@ export const koMetadataForms: NonNullable = { label: "필터", description: "위젯 전체에 적용되는 기본 필터와 전역 필터." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "고급", description: "접근성과 성능 조정." @@ -2054,6 +2062,10 @@ export const koMetadataForms: NonNullable = { }, "globalFilters.targetWidgets": { label: "대상 위젯" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts index c9103bde07a..b440ec908a1 100644 --- a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts @@ -42,6 +42,10 @@ export const koGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.defaultRange.label": "c1f190468a0e2b35", "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.email_template.fields.fromOverride.helpText": "c5e29fa12ee1525b", "metadataForms.email_template.fields.variables.helpText": "27197774c2cda633", "metadataForms.field.fields.inlineEdit.helpText": "1ce60e4c6d5fc0e1", @@ -63,6 +67,8 @@ export const koGeneratedSourceHashes: Readonly> = { "metadataForms.report.fields.exportOptions.formats.label": "193cd91818d64ef7", "metadataForms.report.fields.exportOptions.includeHeaders.helpText": "44cbc80015ff051d", "metadataForms.report.fields.exportOptions.includeHeaders.label": "f114a4778c9727ae", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", diff --git a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts index 54303e78f69..f91dd61fa4a 100644 --- a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts @@ -1344,8 +1344,11 @@ describe('#19403 round 10 — the verdicts, on the live bundles', () => { // 840 since #37141: the skill form's `context` row (ADR-0160 D8) — one // row label, authored in all three locales. // 841 since #37086: the `form` type's own label (ADR-0159 card ②), - // authored in all three locales. - expect(translated.length, `${locale} positive control`).toBe(841); + // authored in all three locales. 844 since #34908: the view and + // dashboard forms offer the audience gate (`requiredPermissions`) — two + // row labels and the dashboard's `access` section label, authored in + // all three locales. + expect(translated.length, `${locale} positive control`).toBe(844); } // ⭐ DARK — the blindness, executable. On a synthetic two-locale catalog the // all-three predicate returns 0 while the per-locale one returns 1, so the diff --git a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts index 6c7df972004..a9c2c2e0944 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const ptBRMetadataForms: NonNullable = label: "Bloqueado por", helpText: "Usuário que bloqueou a configuração da visualização" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "Objeto" } @@ -1874,6 +1878,10 @@ export const ptBRMetadataForms: NonNullable = label: "Filtros", description: "Filtros padrão e globais aplicados a todos os widgets." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "Avançado", description: "Ajustes de acessibilidade e desempenho." @@ -2054,6 +2062,10 @@ export const ptBRMetadataForms: NonNullable = }, "globalFilters.targetWidgets": { label: "Widgets de destino" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts index d1924652a22..9a8c8163394 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts @@ -45,7 +45,11 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.defaultRange.label": "c1f190468a0e2b35", "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", "metadataForms.dashboard.fields.widgets.label": "bd4bf82396edd638", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.dashboard.sections.layout.label": "7f508ea1bb2c3a6b", "metadataForms.dashboard.sections.widgets.label": "bd4bf82396edd638", "metadataForms.email_template.fields.fromOverride.helpText": "c5e29fa12ee1525b", @@ -80,6 +84,8 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "metadataForms.report.fields.exportOptions.includeHeaders.label": "f114a4778c9727ae", "metadataForms.view.fields.gantt.label": "57ffc6ef520edfc5", "metadataForms.view.fields.kanban.label": "dd95c452aa71459e", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "metadataForms.view.sections.gantt.label": "57ffc6ef520edfc5", "metadataForms.view.sections.kanban.label": "dd95c452aa71459e", "objects.sys_device_code.fields.status.label": "64a420165247654b", diff --git a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts index 8fbd9e0954b..bd40396d57d 100644 --- a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const ruMetadataForms: NonNullable = { label: "Кем заблокировано", helpText: "Пользователь, заблокировавший настройку представления" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "Объект" } @@ -1874,6 +1878,10 @@ export const ruMetadataForms: NonNullable = { label: "Фильтры", description: "Фильтры по умолчанию и глобальные фильтры, применяемые ко всем виджетам." }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "Дополнительно", description: "Доступность и настройка производительности." @@ -2054,6 +2062,10 @@ export const ruMetadataForms: NonNullable = { }, "globalFilters.targetWidgets": { label: "Целевые виджеты" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts index 3d6a5f02c22..1a970de4508 100644 --- a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts @@ -42,6 +42,10 @@ export const ruGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.defaultRange.label": "c1f190468a0e2b35", "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.email_template.fields.fromOverride.helpText": "c5e29fa12ee1525b", "metadataForms.email_template.fields.variables.helpText": "27197774c2cda633", "metadataForms.field.fields.inlineEdit.helpText": "1ce60e4c6d5fc0e1", @@ -63,6 +67,8 @@ export const ruGeneratedSourceHashes: Readonly> = { "metadataForms.report.fields.exportOptions.formats.label": "193cd91818d64ef7", "metadataForms.report.fields.exportOptions.includeHeaders.helpText": "44cbc80015ff051d", "metadataForms.report.fields.exportOptions.includeHeaders.label": "f114a4778c9727ae", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts index 86690b36f87..c711030e0ba 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const zhCNMetadataForms: NonNullable = label: "锁定者", helpText: "锁定该视图配置的用户" }, + requiredPermissions: { + label: "所需权限", + helpText: "谁能看此视图:查看者必须持有的能力,列出的每一项都要具备。能力由权限集授予,岗位通过其权限集获得这些能力。留空则所有能看到该列表的人都能看到此视图。要给多类人看,请选一个能力并授予每类人的权限集。由服务器强制执行:其他人在列表中看不到此视图,直接打开也会被拒绝。这也适用于你自己:列出你未持有或拼错的能力后,你也将无法再打开此视图。" + }, object: { label: "对象" } @@ -1874,6 +1878,10 @@ export const zhCNMetadataForms: NonNullable = label: "筛选", description: "应用到所有组件的默认筛选与全局筛选" }, + access: { + label: "访问权限", + description: "谁可以查看此仪表盘。" + }, advanced: { label: "高级设置", description: "性能与无障碍" @@ -2054,6 +2062,10 @@ export const zhCNMetadataForms: NonNullable = }, "globalFilters.targetWidgets": { label: "目标组件" + }, + requiredPermissions: { + label: "所需权限", + helpText: "谁能看此仪表盘:查看者必须持有的能力,列出的每一项都要具备。能力由权限集授予,岗位通过其权限集获得这些能力。留空则所有人都能看到此仪表盘。要给多类人看,请选一个能力并授予每类人的权限集。由服务器强制执行:其他人在列表中看不到此仪表盘,直接打开也会被拒绝。这也适用于你自己:列出你未持有或拼错的能力后,你也将无法再打开此仪表盘。" } } }, diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts index e37e615af26..34af280d9f6 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts @@ -1659,6 +1659,10 @@ export const zhHantMetadataForms: NonNullable label: "鎖定者", helpText: "鎖定該檢視設定的使用者" }, + requiredPermissions: { + label: "Required Permissions", + 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." + }, object: { label: "物件" } @@ -1874,6 +1878,10 @@ export const zhHantMetadataForms: NonNullable label: "篩選", description: "套用到所有元件的預設篩選與全域篩選" }, + access: { + label: "Access", + description: "Who can see this dashboard." + }, advanced: { label: "進階設定", description: "效能與無障礙" @@ -2054,6 +2062,10 @@ export const zhHantMetadataForms: NonNullable }, "globalFilters.targetWidgets": { label: "目標元件" + }, + requiredPermissions: { + label: "Required Permissions", + helpText: "Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either." } } }, diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts index 7f3c633dfe6..dc54a98d4f4 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts @@ -42,6 +42,10 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "metadataForms.dashboard.fields.dateRange.defaultRange.label": "c1f190468a0e2b35", "metadataForms.dashboard.fields.dateRange.field.helpText": "bbd8025863a4481a", "metadataForms.dashboard.fields.dateRange.field.label": "7cd8aace5973d40c", + "metadataForms.dashboard.fields.requiredPermissions.helpText": "00e5446e61cf5759", + "metadataForms.dashboard.fields.requiredPermissions.label": "a47b2168b71f5e68", + "metadataForms.dashboard.sections.access.description": "fea0fbc00761c87f", + "metadataForms.dashboard.sections.access.label": "5a06534d8d136ba3", "metadataForms.field.fields.inlineEdit.helpText": "1ce60e4c6d5fc0e1", "metadataForms.field.fields.inlineEdit.label": "f29ea014320f588e", "metadataForms.report.fields.dateRange.allowCustomRange.helpText": "eb95a6b1536e22fd", @@ -57,6 +61,8 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "metadataForms.report.fields.exportOptions.formats.label": "193cd91818d64ef7", "metadataForms.report.fields.exportOptions.includeHeaders.helpText": "44cbc80015ff051d", "metadataForms.report.fields.exportOptions.includeHeaders.label": "f114a4778c9727ae", + "metadataForms.view.fields.requiredPermissions.helpText": "c4599be2ffa06c02", + "metadataForms.view.fields.requiredPermissions.label": "a47b2168b71f5e68", "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", diff --git a/packages/rest/src/meta-view-audience-save-round-trip.test.ts b/packages/rest/src/meta-view-audience-save-round-trip.test.ts new file mode 100644 index 00000000000..4a0a5389c29 --- /dev/null +++ b/packages/rest/src/meta-view-audience-save-round-trip.test.ts @@ -0,0 +1,196 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * [#34908] The console's save door keeps a list view's audience gate + * (`requiredPermissions`, ruling 6095014058, letter A) — the premise the + * administrator-facing "who sees this view" control stands on (ruling + * 7103739693, letter B: author the existing gate, add no second one). + * + * The bodies are the ones the console writes, byte for byte in shape: a new + * shared view goes out as the `viewEnvelope` the add-view door builds (the + * gate under `config`, beside the object binding), saved as a draft over "no + * draft" (`PUT ?mode=draft`, `If-None-Match: *`) and published + * (`POST /publish`); an edit of an existing view goes out as the same envelope. + * Pinned through the real routes, the real `saveMetaItem` and a real + * better-sqlite3 `sys_metadata`: + * + * - the draft read, the stored active row and the served item each carry the + * gate as written; + * - the published view is then served to a holder of the capability and + * refused by name to a caller who holds none (`403 PERMISSION_DENIED`) — + * the gate the save kept is the gate the read applies; + * - an edit that clears the gate (the control's "everyone") stores no key, + * and the non-holder is served again; + * - CONTROL: a view saved with no gate is served to everyone. + * + * ⚠️ `@objectstack/metadata-protocol` resolves through `exports` to its + * `dist/`: rebuild it before reading a result here after touching it. + */ + +import { describe, it, expect, afterEach } from 'vitest'; +import { ObjectQL } from '@objectstack/objectql'; +import { SqlDriver } from '@objectstack/driver-sql'; +import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; +import { SysMetadata, SysMetadataHistoryObject, SysMetadataAuditObject } from '@objectstack/platform-objects/metadata'; +import { RestServer } from './rest-server.js'; + +const TEST_PACKAGE_ID = 'objectstack-test'; +const META = '/api/v1/meta'; +const LEGAL_CAP = 'task_legal.view'; +const VIEW_NAME = 'task.legal_queue'; + +const TASK = { + name: 'task', + label: 'Task', + fields: { + id: { name: 'id', type: 'text' as const, primaryKey: true, label: 'ID' }, + name: { name: 'name', type: 'text' as const, label: 'Name' }, + }, +}; + +/** The callers: the writer holds the route's `manage_metadata` and the capability. */ +const CALLERS = { + author: { userId: 'u_author', systemPermissions: ['manage_metadata', LEGAL_CAP] }, + holder: { userId: 'u_legal', systemPermissions: [LEGAL_CAP] }, + 'non-holder': { userId: 'u_member', systemPermissions: [] as string[] }, +} as const; +type CallerName = keyof typeof CALLERS; + +/** What the console's add-view door writes (`viewEnvelope(object, spec, { name, label })`). */ +const consoleEnvelope = (gate: string[] | undefined) => ({ + name: VIEW_NAME, + object: 'task', + viewKind: 'list', + label: 'Legal queue', + config: { + type: 'grid', + columns: ['name'], + ...(gate ? { requiredPermissions: gate } : {}), + data: { provider: 'object', object: 'task' }, + }, +}); + +const liveEngines: ObjectQL[] = []; +afterEach(async () => { + while (liveEngines.length) { + try { await liveEngines.pop()?.destroy(); } catch { /* noop */ } + } +}); + +function createMockServer() { + const noop = () => {}; + return { get: noop, post: noop, put: noop, delete: noop, patch: noop, use: noop, listen: async () => {}, close: async () => {} }; +} + +function makeRes() { + const res: any = { statusCode: 200, body: undefined, headers: {} as Record }; + res.status = (code: number) => { res.statusCode = code; return res; }; + res.json = (body: any) => { res.body = body; return res; }; + res.send = () => res; + res.end = () => res; + res.header = (k: string, v: string) => { res.headers[k] = v; return res; }; + res.setHeader = () => {}; + res.write = () => true; + return res; +} + +async function boot() { + const engine = new ObjectQL(); + liveEngines.push(engine); + engine.registerDriver(new SqlDriver({ + client: 'better-sqlite3', + connection: { filename: ':memory:' }, + useNullAsDefault: true, + }), true); + await engine.init(); + engine.registry.registerObject(TASK as any, TEST_PACKAGE_ID); + engine.registry.registerObject(SysMetadata as any, TEST_PACKAGE_ID); + engine.registry.registerObject(SysMetadataHistoryObject as any, TEST_PACKAGE_ID); + engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID); + await engine.syncSchemas(); + + const protocol = new ObjectStackProtocolImplementation(engine as any); + const rest: any = new RestServer( + createMockServer() as any, + protocol as any, + { api: { requireAuth: false }, metadata: { enableCache: false } } as any, + ); + let caller: CallerName = 'author'; + rest.resolveExecCtx = async () => ({ ...CALLERS[caller], systemPermissions: [...CALLERS[caller].systemPermissions] }); + rest.registerRoutes(); + + const route = (method: string, path: string) => { + const found = rest.getRoutes().find((r: any) => r.method === method && r.path === path); + if (!found) throw new Error(`${method} ${path} is not registered`); + return found; + }; + const call = async (who: CallerName, method: string, routePath: string, req: Record) => { + caller = who; + const res = makeRes(); + await route(method, routePath).handler({ method, headers: {}, query: {}, params: {}, ...req }, res); + return res; + }; + const item = { type: 'view', name: VIEW_NAME }; + const path = `${META}/view/${VIEW_NAME}`; + + return { + /** `PUT /meta/view/task.legal_queue` — active unless `mode: 'draft'`. */ + save: (body: unknown, query: Record = {}, headers: Record = {}) => + call('author', 'PUT', `${META}/:type/:name`, { path, params: item, query, headers, body }), + /** `GET /meta/view/task.legal_queue?state=draft` — the strict draft read. */ + readDraft: () => call('author', 'GET', `${META}/:type/:name`, { path, params: item, query: { state: 'draft' } }), + /** `POST /meta/view/task.legal_queue/publish`. */ + publish: () => call('author', 'POST', `${META}/:type/:name/publish`, { path: `${path}/publish`, params: item, body: {} }), + /** `GET /meta/view/task.legal_queue` — the by-name read, as the caller named. */ + read: (who: CallerName) => call(who, 'GET', `${META}/:type/:name`, { path, params: item }), + /** The stored active row's body — the store, not the door's word for it. */ + storedActive: async () => { + const rows = (await engine.find('sys_metadata', { where: { type: 'view', name: VIEW_NAME, state: 'active' } })) ?? []; + return rows.map((r: any) => (typeof r.metadata === 'string' ? JSON.parse(r.metadata) : r.metadata)); + }, + }; +} + +const ok = (res: any) => { + expect(res.statusCode, JSON.stringify(res.body)).toBe(200); + return res.body; +}; +/** The ADR-0112 minimum: the status and the machine code. */ +const envelope = (res: any) => ({ status: res.statusCode, code: res.body?.code ?? res.body?.error?.code }); +/** A list view's gate wherever the served body carries it: under `config`, or on the flattened arm. */ +const gateOf = (body: any): unknown => body?.config?.requiredPermissions ?? body?.requiredPermissions; +const servedItem = (body: any): any => body?.item ?? body?.data ?? body; + +describe('[#34908] the console save door keeps a list view\'s requiredPermissions', () => { + it('a new shared view, drafted and published: the draft, the stored row and the served item carry the gate; the read applies it', async () => { + const h = await boot(); + ok(await h.save(consoleEnvelope([LEGAL_CAP]), { mode: 'draft' }, { 'if-none-match': '*' })); + expect(gateOf(servedItem(ok(await h.readDraft())))).toEqual([LEGAL_CAP]); + + ok(await h.publish()); + const [stored, ...more] = await h.storedActive(); + expect(more).toEqual([]); + expect(gateOf(stored)).toEqual([LEGAL_CAP]); + + expect(gateOf(servedItem(ok(await h.read('holder'))))).toEqual([LEGAL_CAP]); + expect(envelope(await h.read('non-holder'))).toEqual({ status: 403, code: 'PERMISSION_DENIED' }); + }, 60_000); + + it('an edit that clears the gate stores no key, and the non-holder is served again', async () => { + const h = await boot(); + ok(await h.save(consoleEnvelope([LEGAL_CAP]))); + expect(envelope(await h.read('non-holder'))).toEqual({ status: 403, code: 'PERMISSION_DENIED' }); + + ok(await h.save(consoleEnvelope(undefined))); + const [stored] = await h.storedActive(); + expect(gateOf(stored)).toBeUndefined(); + expect(gateOf(servedItem(ok(await h.read('non-holder'))))).toBeUndefined(); + }, 60_000); + + it('control: a view saved with no gate is served to everyone', async () => { + const h = await boot(); + ok(await h.save(consoleEnvelope(undefined))); + ok(await h.read('non-holder')); + ok(await h.read('holder')); + }, 60_000); +}); diff --git a/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts b/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts index 13ad40a11e6..daf67e7e108 100644 --- a/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts +++ b/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts @@ -546,26 +546,6 @@ const LEDGER: ReadonlyArray = [ why: '`[LEGACY ALIAS → sections]` accepted for back-compat and folded onto `sections` at parse (`sections` wins when both are present), deliberately not offered to new authors', }, - // #22611 — the audience gate on a list view and a dashboard lands spec-first: - // `planned` + `authorWarn` in the liveness ledger, read by no server until the - // `/meta` read gate applies it (#22639). The app and action forms offer their - // `requiredPermissions` because those gates are enforced; offering these two - // first would be the UI half of declared-not-enforced. - { - kind: 'omit', - type: 'dashboard', - path: ROOT_PATH, - key: 'requiredPermissions', - why: "declared, not enforced yet — liveness verdict `planned` with `authorWarn`: the dashboard's audience gate (a list of capabilities, all required) parses and is stored, but no server reads it until the `/meta` read gate serves a gated dashboard only to a holder. A form control offered today would let an author set a gate that hides nothing; whether to offer it then is a ruling for the enforcement, not for this gate", - }, - { - kind: 'omit', - type: 'view', - path: ROOT_PATH, - key: 'requiredPermissions', - why: "declared, not enforced yet — liveness verdict `planned` with `authorWarn`: a list view's audience gate (a list of capabilities, all required) parses and is stored, but no server reads it until the `/meta` read gate serves a gated view only to a holder. A form control offered today would let an author set a gate that hides nothing; whether to offer it then is a ruling for the enforcement, not for this gate", - }, - // Renderer-owned vocabulary — a key is admitted here only when all three // hold: its `describe()` says the spec declares no vocabulary for its value; // every server-side meaning it has is superseded by another key this form diff --git a/packages/spec/src/ui/dashboard.metadata-form.ts b/packages/spec/src/ui/dashboard.metadata-form.ts index 4675e5fc80f..91cb5891458 100644 --- a/packages/spec/src/ui/dashboard.metadata-form.ts +++ b/packages/spec/src/ui/dashboard.metadata-form.ts @@ -145,6 +145,27 @@ export const dashboardForm = defineMetadataForm({ }, ], }, + { + // The audience gate (#34908, ruling 7103739693 letter B): the existing, + // server-enforced `requiredPermissions`, given an authoring row — the + // list view's row in `view.metadata-form.ts`, worded for a dashboard. + label: 'Access', + description: 'Who can see this dashboard.', + collapsible: true, + collapsed: true, + fields: [ + { + field: 'requiredPermissions', + widget: 'string-tags', + helpText: 'Who sees this dashboard: 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 sees this dashboard. 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 dashboard 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 dashboard either.', + }, + ], + }, { label: 'Advanced', description: 'Accessibility and performance tuning.', diff --git a/packages/spec/src/ui/view.metadata-form.ts b/packages/spec/src/ui/view.metadata-form.ts index da9dabb5953..b6a4450d816 100644 --- a/packages/spec/src/ui/view.metadata-form.ts +++ b/packages/spec/src/ui/view.metadata-form.ts @@ -315,6 +315,21 @@ export const viewForm = defineMetadataForm({ { field: 'lockedBy', helpText: 'User who locked the view configuration' }, ], }, + // The audience gate (#34908, ruling 7103739693 letter B): the existing, + // server-enforced `requiredPermissions`, given an authoring row — no + // second audience key. The hint restates the clauses of + // `AUDIENCE_REQUIRED_PERMISSIONS_DESCRIPTION` (all of them, no any-of + // form, enforced by the server) for the administrator who sets it. + { + field: 'requiredPermissions', + widget: 'string-tags', + 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.', + }, ], }, ], diff --git a/ui/packages/app-shell/src/views/metadata-admin/metadata-form-i18n.ts b/ui/packages/app-shell/src/views/metadata-admin/metadata-form-i18n.ts index be3504ba2b5..e4d83b634c6 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/metadata-form-i18n.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/metadata-form-i18n.ts @@ -111,6 +111,7 @@ const METADATA_FORM_BUNDLE: TranslationBundle = { layout: { label: '布局', description: '栅格尺寸与刷新频率。' }, widgets: { label: '组件', description: '放在栅格上的卡片与图表。' }, filters: { label: '筛选', description: '应用到全部组件的默认筛选与全局筛选。' }, + access: { label: '访问权限', description: '谁可以查看此仪表盘。' }, advanced: { label: '高级', description: '无障碍与性能调优。' }, }, fields: { @@ -144,6 +145,7 @@ const METADATA_FORM_BUNDLE: TranslationBundle = { }, 'dateRange.allowCustomRange': { label: '允许自定义范围', helpText: '允许查看者自己选择开始和结束日期。' }, globalFilters: { label: '全局筛选', helpText: '查看者可用来一次筛选全部组件,或只筛选你指定组件的筛选条件。' }, + requiredPermissions: { label: '所需权限', helpText: '谁能看此仪表盘:查看者必须持有的能力,列出的每一项都要具备。能力由权限集授予,岗位通过其权限集获得这些能力。留空则所有人都能看到此仪表盘。要给多类人看,请选一个能力并授予每类人的权限集。由服务器强制执行:其他人在列表中看不到此仪表盘,直接打开也会被拒绝。这也适用于你自己:列出你未持有或拼错的能力后,你也将无法再打开此仪表盘。' }, }, }, }, diff --git a/ui/packages/app-shell/src/views/metadata-admin/metadata-form-zh-cn.ts b/ui/packages/app-shell/src/views/metadata-admin/metadata-form-zh-cn.ts index 60fcbc8a8d2..6ccafe214f1 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/metadata-form-zh-cn.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/metadata-form-zh-cn.ts @@ -501,6 +501,7 @@ export const ZH_CN_SPEC_FORMS: NonNullable = { 'navigation.width': { label: '宽度', helpText: '[已弃用 → size] 抽屉的像素 / 百分比宽度(如 "600px")。编写时无法预知客户端视口,因此选不出合适的像素宽度——请使用 `size` 档位。' }, sharing: { label: '共享', helpText: '视图共享配置:谁锁定了视图配置' }, 'sharing.lockedBy': { label: '锁定者', helpText: '锁定该视图配置的用户' }, + requiredPermissions: { label: '所需权限', helpText: '谁能看此视图:查看者必须持有的能力,列出的每一项都要具备。能力由权限集授予,岗位通过其权限集获得这些能力。留空则所有能看到该列表的人都能看到此视图。要给多类人看,请选一个能力并授予每类人的权限集。由服务器强制执行:其他人在列表中看不到此视图,直接打开也会被拒绝。这也适用于你自己:列出你未持有或拼错的能力后,你也将无法再打开此视图。' }, }, }, app: {