You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b6dc566
Browse filesBrowse the repository at this point in the historyBrowse files
fix(console): offer view management on manage_metadata, not isAdmin alone (#36782)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8SBcaWJ4VnpRmSNLW9FDCPD)_Fixes#36448
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:没有「管理元数据」权限的组织管理员,在列表页不再看到「管理视图」「视图设置」「新建视图」,数据页也不再有「另存为视图」;有该权限的管理员看到的和以前一样。
-
为什么做:这几个入口保存的都是共享视图定义,服务器只接受有「管理元数据」权限的人;以前只看是不是管理员,没权限的管理员点进去一保存就被拒。紧接上一张「只有元数据管理员能建共享视图」的卡。
- 出错会怎样:最坏是有权限的管理员看不到入口(纯界面开关,服务器规则没动),撤回这个改动即恢复。
- 要你做什么:无。
## What changes
One answer gates every entry on a list page that leads to a `view`
metadata write: `mayManageViews(isAdmin, useCanAuthorMetadata())` — an
administrator whose session holds `manage_metadata`, the capability
`PUT`/`DELETE /meta/view/NAME` asks (`metaWriteCapabilityVerdict`). It
is the predicate #36398 introduced for the Shared choice
(`mayShareViews`), renamed because it now gates more than sharing.
- `ObjectView` computes `canManageViews` once and reads it for: the
`ManageViewsDialog` mount, the `ViewConfigPanel` open state and wrapper,
the `CreateViewDialog` open state, the title switcher's Add view /
Manage views entries (`useObjectViewTitleSwitcher` prop `isAdmin`
becomes `canManageViews`), and the plugin view's `allowCreateView` and
`viewActions` (settings, share, delete) (`useObjectViewPluginSchema`,
same rename).
- `ObjectDataPage`'s Save as view (button, folded menu item and its
`CreateViewDialog`) — a fourth Create View door, writing `/meta/view`
through `createRuntimeMetadata` — reads the same predicate.
- Declared bounded in-place fix (same defect class, same file, same gate
family; named in the thread's first report to the seat): a saved shared
view's Rename in the Options menu and Save to this view
(`canSaveToSharedView`) both write `/meta/view` through `updateView` and
were offered on `isAdmin` alone; they read `canManageViews` too.
- `isAdmin` alone still gates what only reads (the metadata inspector
panel, the package-list reads behind the panel's read-only state).
A reader's own views (`sys_personal_view`) are untouched: the in-place
Add view still offers My view to everyone who may create one.
## Tests
- New `ObjectView.viewManagementGate-36448.test.tsx`: the real
`ObjectView` under the router; an organization administrator without
`manage_metadata` gets no Manage views entry (and no dialog); one with
it opens Manage views and Create View from it (control); a member gets
neither. The plugin schema: without the capability `allowCreateView` is
false and `viewActions` empty; with it, both offered (control).
- `ObjectDataPage.saveAsViewRefusal-11578.test.tsx`: new top-level
describe in the existing harness — Save as view (button, menu item,
dialog) absent without the capability, present with it (control); the
existing cases now set the capability explicitly.
- `objectViewViewSharing.test.tsx` and
`objectViewRecordNavigation.phonePush-29074.test.tsx` follow the rename.
## Acceptance notes
- none
## Verification
Two-minute check: sign in as an organization administrator who lacks
`manage_metadata`, open any object list — the view switcher shows no
Manage views and the data page no Save as view; as a metadata
administrator both are there.
Riskiest hunks to read first: `ObjectView.tsx` (the `canManageViews`
line and the three JSX gates), `objectViewPluginSchema.ts`
(`allowCreateView` / `viewActions`), `ObjectDataPage.tsx`
(`canSaveAsView`).
<details><summary>Readings at head 10d4f44</summary>
- Targeted tests: `pnpm --dir ui exec vitest run` on
`ObjectView.viewManagementGate-36448.test.tsx`,
`ObjectDataPage.saveAsViewRefusal-11578.test.tsx`,
`objectViewViewSharing.test.tsx`,
`objectViewRecordNavigation.phonePush-29074.test.tsx` — Test Files 4
passed (4), Tests 26 passed (26) (lock VERDICT command-exit 0), after
`pnpm --filter '@object-ui/app-shell^...' build` (exit 0).
- Reverse verification (implementation committed first): the five source
files restored to `e0f0e9f7` with the new tests kept — 4 of 10 cases
RED: the three without-capability cases (Manage views offered, Save as
view offered, plugin Create View and view actions offered) as predicted,
plus the plugin-schema control, which goes red because the old hook
takes `isAdmin`, not `canManageViews` (the rename, not the gate).
Restored with `git checkout HEAD`; `git diff HEAD` empty afterwards.
- `pnpm --filter @object-ui/app-shell run type-check` — lock VERDICT
command-exit 0.
- `dispatch-gates.mjs --commands` derived families, all run locally, all
exit 0; `--ran` reconciliation: 38 of 38 accounted for:
- exit 0 · `node scripts/check-closing-keyword-parity.mjs`
- exit 0 · `node scripts/check-closing-keyword-parity.mjs --self-test`
- exit 0 · `node scripts/check-comment-mask-corpus.mjs`
- exit 0 · `node scripts/check-sdui-manifest.mjs`
- exit 0 · `node scripts/check-sdui-manifest.mjs --self-test`
- exit 0 · `pnpm --dir ui exec vitest run scripts/`
- exit 0 · `pnpm --filter @objectstack/spec run
check:duration-unit-keys`
- exit 0 · `pnpm check:adr-anchors`
- exit 0 · `pnpm check:cross-package-test-inputs`
- exit 0 · `pnpm check:dispatcher-error-vocabulary`
- exit 0 · `pnpm check:driver-memory-census`
- exit 0 · `pnpm check:engine-double-contract`
- exit 0 · `pnpm check:gitlink-declared`
- exit 0 · `pnpm check:nul-bytes`
- exit 0 · `pnpm check:published-files`
- exit 0 · `pnpm check:query-options-erasure`
- exit 0 · `pnpm check:refd-timer-probe`
- exit 0 · `pnpm check:registry-log-declared`
- exit 0 · `pnpm check:rest-log-spy-declared`
- exit 0 · `pnpm check:skill-identifier-liveness`
- exit 0 · `pnpm check:test-source-alias`
- exit 0 · `pnpm check:tier-file-adoption`
- exit 0 · `pnpm check:type-check-coverage`
- exit 0 · `pnpm check:type-check-debt`
- exit 0 · `pnpm check:undeclared-dep-imports`
- exit 0 · `pnpm check:watch-hint-literal`
- exit 0 · `pnpm check:where-matcher`
- exit 0 · `node scripts/check-adr-0087-registration.mjs --base
origin/main`
- exit 0 · `node scripts/check-adr-0087-registration.mjs --self-test`
- exit 0 · `node scripts/check-changeset-no-major.mjs --base
origin/main`
- exit 0 · `node scripts/check-empty-changeset.mjs --base origin/main`
- exit 0 · `node scripts/check-empty-changeset.mjs --self-test`
- exit 0 · `node scripts/ci/snapshot-next.mjs --self-test`
- exit 0 · `node scripts/pm/check-governed-queue-guard.mjs --self-test`
- exit 0 · `node scripts/pm/release-rehearsal-clone.mjs --self-test`
- exit 0 · `node scripts/release-pending-publish.mjs --self-test`
- exit 0 · `pnpm check:changeset-gate-self-tests`
- exit 0 · `pnpm check:closed-ceremony-text`
- CI at 10d4f44: 39 success · 13 expected skip · 0 failed
(`pr-state.mjs`: mergeable_state clean).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYXZHUaaZK86HquGRP)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbYXZHUaaZK86HquGRP -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(console): offer view management only to an administrator who may write views
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
Manage views, the view settings panel and Create View on a list page, the plugin view's own Create View and view actions, the data page's Save as view, and a saved shared view's rename and save in place were offered to every workspace administrator. Each of them writes `view` metadata, which the server refuses without the `manage_metadata` capability, so an organization administrator who lacks it was offered them and met a refusal on the first save. They now read the answer the Shared choice of a new view already reads (`mayManageViews`): an administrator whose session holds `manage_metadata`. A metadata administrator sees them as before; a reader's own views are unchanged.
0 commit comments