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 c45dd80
Browse filesBrowse the repository at this point in the historyBrowse files
feat(setup): Setup → Configuration → Public forms lists and switches every public form (#36697)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8KF3BvUnBEoN52Vcnw6JhXg)_
Part of #36444. This PR is the card's **Settings = operations** half
(ruling items 6–10 of
#36444 (comment)).
The **Studio = design** half (items 1–5: the designer under the object,
create/delete, fields, sections, address, live preview) stays open on
the card for a second PR on this branch.
Clause-②: yes (widening) — a new `@objectstack/spec/ui` export
`anonymousFormIntakeWithdrawnIn` (moved verbatim from
`@objectstack/metadata-core`, which re-exports it), a new Setup
navigation id `nav_public_forms`, a new component id
`forms:public-forms`, and new language-pack keys (the `publicFormsSetup`
block and the nav label) in every shipped locale
Metadata-protocol: none
## 维护者速读
- 设置 › 配置
新增「对外表单」:列出本环境所有对外表单(名称、所属对象、地址、开关),可一键关闭/开启、复制地址、在新标签打开。仅系统管理员可见。
- 关闭后表单地址立即打不开(与现在一致,返回「找不到表单」),表单仍留在列表里可随时重新开启。
- 已安装应用的表单,开关存为本环境的定制,不改应用本身,应用升级照常进来;重新开启且没有其它改动时,自动恢复为应用原样。
- 表单的设计(新建、删除、字段、标题)仍在 Studio,下一个 PR 做;「最近一次提交时间」本卡不做。
## What changes
- **New Setup page `forms:public-forms`** (Setup → Configuration →
Public Forms, `nav_public_forms`, `requiredPermissions:
['manage_platform_settings']`; the page asks the same capability). One
row per public form: name, the object a submission creates a record of,
its address, an on/off switch, copy address, open in a new tab. No field
editing, create or delete here (ruling item 7).
- **Which forms are listed**
(`ui/packages/app-shell/src/views/setup/publicForms.ts`): read from the
effective view list (`GET /meta/view`), judged by the server's own rule
`anonymousFormIntakeCandidates` (`@objectstack/spec/ui`), never a second
reading of `sharing`:
- listed = the rule would open the form with its switch on
(`allowAnonymous: true` + a `publicLink`), so a switched-off form stays
listed (item 8);
- on = the rule opens it as served.
- The name shown is the served label, else the form's title, else its
first section's label, else its key.
- **Where a switch is saved** (item 9): the switch is `sharing.enabled`,
saved and published at once.
- Writable package → saved in that package.
- Installed (read-only) app → a declared override in the app's `.custom`
package (ADR-0146 D2/D3), via the same seams the in-page dashboard
editor uses (`resolveDashboardEditTarget`, `ensureDashboardSaveTarget`,
`overrideDraftBody`, `saveAndPublishInPackage`). The app's own package
is never written, so upgrades still flow in.
- Switching back on removes the override (the pair's row) when it held
nothing but the switch, so the app's original form is served again; an
override that also carries design changes keeps them, with the switch
on.
- A pending draft where the switch would save is never published or
removed on its saver's behalf: the switch writes nothing and says so.
- After an app upgrade, an override taken from an earlier version is
still restored when the form is otherwise the app's current one. When it
is not, it is kept with the switch on, and the page says the form stays
on the app's earlier version (`basedOn`), which Studio's "Restore
package original" undoes. The app's earlier document cannot be read, so
a switch-only override at an old version cannot be told from a design
one (review S1).
- **A form its installed app ships switched off** (address kept,
`enabled: false` or `allowAnonymous: false`, or `enabled` omitted, which
the stack schema parses as `false`) is withdrawn by the app's own
document, and the routes never let an override re-open it (pinned in
`packages/rest/src/public-form-withdrawal-effective-read.test.ts`). The
page judges the app's document with the routes' own function,
`anonymousFormIntakeWithdrawnIn`, against the served form switched on
(slot or slug match), plus an omitted `enabled` (review M1, S2). The
page reads each installed app's form's layers (`markShippedOff`, one
package-list read per page load) and lists such a form as "Off (switched
off by its app)" with its switch disabled, even when an override already
switches it on; a switch-on writes nothing and refuses with that
sentence. A form whose app's document cannot be read shows "Unknown",
never On (N5).
- **`anonymousFormIntakeWithdrawnIn` moves into `@objectstack/spec/ui`**
(`anonymous-form-intake.ts`, beside the candidates half), verbatim: it
is a pure judgement of the bodies it is handed.
`@objectstack/metadata-core` re-exports the same binding, so the routes'
import is unchanged, and its identity test now pins this name with the
others (one copy, not a twin). Spec `api-surface` and `export-origins`
regenerated (1 added).
- **Permission:** the page asks `manage_platform_settings` (its Setup
entry's); the switches also ask `manage_metadata`, the capability the
server checks on every write they make. Without it the forms are listed,
the switches are disabled, and a sentence says why. A refused switch is
told in business words (403 → no permission; anything else → the server
refused, try again), and so is a failed list read; the server's own
message goes to the console log only (review N1, N3, N6).
- **Switched-off behaviour (F3 = A):** unchanged, `404 FORM_NOT_FOUND`.
The routes already honour an override that withdraws a base's form
(`anonymousFormIntakeWithdrawnIn`), so no route, spec key, error code or
stored-key change was needed: Metadata-protocol stays `none`. The new
spec export (the moved withdrawal judgement), the new navigation id,
component id and language keys are the widening the Clause-② line
declares.
- Business wording only (item 10): new `publicFormsSetup` block in all
11 console locales; nav label in all 11 platform-object locales (zh-CN
「对外表单」).
- Access restrictions (password, expiry, domains) are exposed on neither
surface, per the ruling.
- **Not built: "last submission time".** A submission is an ordinary
record of the form's object and records no form, so there is nothing to
read (stated in the ruling).
## Tests
- `ui/packages/app-shell/src/views/setup/publicForms.test.ts` (26
cases): the listing rule (on, off-but-listed, internal forms, non-form
views, naming); writable-package save; installed app off → override in
`.custom` with its `overrides` declaration and nothing in the app;
reading the base when the listed pair does not hold the form; on with a
switch-only override → restore (reset at the pair, no save); on with a
design override → kept, switch on, `basedOn` unchanged; pending draft →
nothing written (both the client-side check and the server's `409
METADATA_CONFLICT`); refusals (package not listed, unreadable form, no
version to declare); a base shipped off, both `enabled: false` and
absent `enabled`, refused with nothing written, with and without an
override already on, and listed as not on (`markShippedOff`); an app
that ships `allowAnonymous: false` under an override that opens it,
refused and listed as not on; an unreadable app document → `unknown`,
not on; an override switch-only at `basedOn: 2.0.0` against a changed
3.0.0 base → `{ kind: 'earlier-version', basedOn: '2.0.0' }`, kept; the
same against an unchanged base → restored. Ablations: dropping the
refusal, the listing mark, the earlier-version answer, the routes'
withdrawal rule, or the unknown mark, or reading an absent switch as on,
each turns cases red.
- `PublicFormsSetupPage.test.tsx` (8 cases, rendered): the Setup
capability gate; without `manage_metadata` the switches are disabled
with the sentence; a shipped-off form shows "switched off by its app"
with a disabled switch (both spellings); the pending-draft toast leaves
the row as it was; a 403 and a 500 are told by key, with no server text;
a failed list read shows the business sentence without the server text;
an unreadable app document shows "Unknown", not On. Ablations of the
metadata gate, the shipped-off mark and the business-word refusal each
turn a case red.
- `PublicFormsSetupPage.navContribution.test.tsx` (3 cases): the ref is
registered by the production registration, addresses
`component/forms/public-forms`, and mounts through the component route.
- `packages/metadata-core/src/anonymous-form-intake.test.ts`: the
identity case now includes `anonymousFormIntakeWithdrawnIn`
(metadata-core's export is the spec binding); the package's 1,057 tests
pass, and so does
`packages/rest/src/public-form-withdrawal-effective-read.test.ts`.
- `packages/cli/test/connect-agent-both-halves-wire.pin.test.ts`: Setup
nav count 34 → 35, plus `nav_public_forms` is served to a
`manage_platform_settings` holder. Red without the fix: against a
platform-objects build without the nav entry it fails `expected [...] to
have a length of 35 but got 34`.
- `ui/packages/i18n/src/__tests__/zh-hant-generated.test.ts`: passes
with `src/locales/zh-Hant.ts` regenerated from zh (`pnpm --filter
@object-ui/i18n gen:zh-hant`).
-
`ui/packages/app-shell/src/console/__tests__/openPathObjectReaders-12811.test.ts`:
the new page's `useMetadata().objects` read is classified `off` (Setup,
not an app object-list open).
## Acceptance notes
Live run on `examples/app-crm` (`objectstack dev --seed-admin --fresh`)
+ console dev server, as the seeded admin. `com.example.crm` lists as
not writable, so this exercised the installed-app (customization) path:
| Step | Result |
|---|---|
| Open Setup → Configuration → Public Forms | 1 row, "Contact us", Lead,
`…/f/contact-us`, On |
| Switch off | toast; row Off; `GET /api/v1/forms/contact-us` → `404
FORM_NOT_FOUND`; `/f/contact-us` shows "Page not found" |
| Reload the page | still listed, still Off |
| Switch on | `GET /api/v1/forms/contact-us` → 200; the form renders and
takes input again |
| Layers after switching on | `effective._packageId = com.example.crm`,
no override left in `com.example.crm.custom` (restored to the app
original) |
Screenshots (live run, 2× scale) are in the project's shared files under
`issue-36444/`; they cannot be uploaded to GitHub from the cloud seat:
- `01-public-forms-on.png`: the page with the Setup sidebar entry, form
On.
- `02-public-forms-off.png`: after switching off (toast, Off).
- `03-anon-form-off.png`: the anonymous address while off.
- `04-public-forms-back-on.png`, `05-anon-form-on.png`: switched back
on, the form takes input again.
The Studio designer screenshot comes with the second PR.
Premise finding for the Studio half: the existing Developer → Public
Forms entry (`nav_public_forms` in `studio.app.ts`,
`developer:public-forms`) is served only where a host loads
`@objectstack/studio`; no example and no CLI default loads it, so the
console's own Studio has no public-forms entry today. The second PR
places the designer under the object in the console's Studio, within the
seven-tab Data pillar (objectui#12450).
Overlap: merges cleanly with `main`, #36629 and #36525. #34223 (draft
since 11-19) also bumps the same Setup nav count line in the CLI pin
test; whichever lands second takes the other's count.
## Verification
Head `2a859fb0a4` (review round 2: S2, N5, N6; round 1 at `d91c73bcad`;
`main` merged in earlier as `33a41ea1b0`, no rebase).
- The derived gate union (`dispatch-gates --commands`, now 94 commands
with the spec and metadata-core paths): 94/94 exit 0 on `2a859fb0a4`.
- CI on `2a859fb0a4`: all workflows completed (Spec Liveness Check
included), 59 checks success, 10 skipped (opt-in, queue and schedule
gates), 0 failure.
- `@object-ui/app-shell` type-check (src + tests): exit 0. eslint on the
changed files: 0 errors.
- Locale keys in all 11 console locales; zh-Hant regenerated from zh
(`gen:zh-hant`).
- Earlier heads: `a502b8c57` had two reds, fixed in `d3b3b09d3`
(`check:spec-symbols` refused a local type `Doc`, renamed `FormDoc`; the
`openPathObjectReaders-12811` census, classified). `d3b3b09d3` had one
red, Test UI (10/16), the stale zh-Hant locale, fixed in `5c7d009426`.
`8902d697ee` and `d91c73bcad` were all green.
- Locally `peopleAssignments.navContribution.test.tsx` ("Position
holders" heading) fails on `main` as well; CI runs it green. Not touched
here.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbWoxCrkYwcqxxENvmn)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbWoxCrkYwcqxxENvmn -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(setup): Setup → Configuration → Public forms lists every public form of the environment and switches it on or off
10
+
11
+
Clause-②: yes (widening) — a new Setup navigation id `nav_public_forms`, a new component id `forms:public-forms`, new language-pack keys (the `publicFormsSetup` block and the nav label) in every shipped locale, and `anonymousFormIntakeWithdrawnIn` newly exported from `@objectstack/spec/ui` (moved from `@objectstack/metadata-core`, which re-exports the same binding)
12
+
Metadata-protocol: none
13
+
14
+
A system administrator (`manage_platform_settings`, the capability the Setup entry asks) now has one page for the operations side of public forms. It lists every public form of the environment: its name, the object a submission creates a record of, its address, and whether it is on. Per row: switch it on or off, copy its address, or open it in a new tab. A form is designed (created, deleted, its fields and title changed) in Studio, not here.
15
+
16
+
-**Which forms are listed.** A form view whose `sharing` opens it to anonymous intake once switched on (`allowAnonymous: true` and a `publicLink`), read by the same rule the anonymous form routes use (`anonymousFormIntakeCandidates`). A switched-off form stays listed and can be switched back on. A form with no public address or no anonymous access is an internal form and is not listed. The list is the effective one (`GET /meta/view`), so an installed app's form switched off in this environment lists as off.
17
+
-**Where a switch is saved.** The switch is the form's `sharing.enabled`, saved and published at once. A form of a writable package is saved in that package. A form of an installed (read-only) app is saved as this environment's customization, an override in the app's `.custom` package (ADR-0146), never an edit of the app's own package, so the app upgrades as before. Switching such a form back on removes the override when it held nothing but the switch, so the app's own form is served again; an override that also carries design changes keeps them, with the switch on.
18
+
-**A form its installed app ships switched off** (its address kept, `enabled` or `allowAnonymous` set to `false`, or `enabled` omitted, which the stack schema reads as `false`) stays closed whatever the environment saves: the anonymous routes treat the app's own document as a withdrawal that no override re-opens. The page judges this with the routes' own function, `anonymousFormIntakeWithdrawnIn`, now declared in `@objectstack/spec/ui` beside the rest of the intake rule; `@objectstack/metadata-core` re-exports the same binding, so the server's import is unchanged. The page lists such a form as "Off (switched off by its app)" with its switch disabled, also when an override already switches it on, and a switch-on writes nothing and says the app ships it switched off. A form whose app's document cannot be read is shown as status unknown, never as on.
19
+
-**After an app upgrade**, switching back on an override taken from an earlier version restores the app's own form when the form is otherwise unchanged. When it is not, the override is kept with the switch on and the page says the form stays on the app's earlier version, which Studio's "Restore package original" undoes.
20
+
- A switch over a draft already pending where it would save writes nothing and says so: that draft is its saver's and is never published on their behalf.
21
+
- A switch writes the form's metadata, which the server lets only a `manage_metadata` holder do. Without it the page still lists the forms but disables the switches and says why. A refused switch, and a list read that fails, are told in business words, never the server's raw message.
22
+
- A switched-off form keeps answering as it does today: `404 FORM_NOT_FOUND` at its address. No route, error code or stored key is added.
23
+
24
+
New Setup navigation entry `nav_public_forms` in `group_configuration` (label "Public Forms", in every shipped locale) opening the component `forms:public-forms`; the Setup navigation now carries 35 entries. New locale block `publicFormsSetup` in every console locale. Not shown: when a form last took a submission, since a submission is an ordinary record of the form's object and records no form.
0 commit comments