Skip to content

Commit 421f180

Browse files
feat(flow designer): add variables, say why Runs is empty, Debug takes the side column, and autosave reads 已保存 in the header (#34955)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzgae1jRRi8FRrTxaZL Fixes #34818 (slice 3 of 3: items 5 to 9, plus the approval help text moved from slice 2; slices 1 and 2 landed as #34850 and #34932). Surface per the seat's amendment 6954475081. Clause-②: no Metadata-protocol: none ## 维护者速读 - **变量页可以新增变量了。** 空状态说明变量是做什么的;「添加变量」新建一个不重名的文本变量,每行可改名称、类型、默认值、输入、输出。`$` 开头、空名、重名会被拦下并提示;还被步骤引用的变量不能改名或删除,提示里列出是哪些步骤(这张卡不自动改引用)。只读包仍是原来的列表。 - **运行页签分两种说法。** 从未发布的流程写「发布并启用后,这里显示每次运行的记录。」,并且不去请求运行记录;已发布但引擎不响应时只说引擎不可用。 - **调试面板占用右栏。** Studio 里流程的「属性」本来在右侧面板,进入「调试」后模拟器直接画在右侧面板里,画布独占中间;离开调试,属性面板带着原来的选中回来。没有右侧面板的布局下,属性栏不画,模拟器列加宽到属性栏的宽度。1280 宽实测「运行 / 单步 / 重置」和状态徽标完整可见。 - **自动保存不再弹提示。** 标题栏的「正在保存」落定为「已保存」,读屏读作「流程「X」已保存」,下次编辑前一直在;保存失败照旧显示错误条,另弹一条错误提示。其他 Studio 编辑器的保存提示不变。按席位裁定,徽标在流程自己的标题行里、紧挨流程名。 - **节点面板在 zh-CN 下没有英文了。** 包括条件分支的「分支方式」、审批的「解析为」「没有解析出审批人时」和分组占位,也包括实测才发现的、由服务端下发的审批人各列说明、「排除提交人」「备用审批人」和 SLA 升级各项说明。`quorum`、`per_group` 改为「法定人数」「分组会签」。审批人说明改为「插入时自带通过和驳回两条连线」。 - 元数据结构、引擎行为、发布检查都不变。 ## What changes **Item 5, the node panel in zh-CN (and the approval help text).** - `inspectors/flow-node-config.ts`: - The approval `approvers` help says the node comes with an "approve" and a "reject" connection, instead of asking the author to label them (slice 2 inserts them). - `localizeField` and `localizeColumn` overlay a prose `placeholder`, and `localizeColumn` overlays a column `help`. Example literals (CEL, numbers, field names) stay as written. - `metadata-admin/i18n.ts` (`FLOW_FIELD_ZH`): - decision: `mode` and its two options; the branch columns' help and prose placeholders. - approval: `resolveAs`; `onEmptyApprovers` with all four options (including `fallback`); `excludeSubmitter`; `fallbackApprovers`; the escalation helps; `minApprovals` reads 法定人数 / 分组会签. - `APPROVER_COLS_ZH` is shared by `approvers` and `fallbackApprovers` (both are `ApprovalNodeApproverSchema`). It covers every column's label and help, including `organization`, plus a `platform_admin` option label. - The served help: live, the panel draws the fields the engine publishes, whose help is the spec's `.describe()`. Seven of those strings were English in zh-CN. They are now in the table, and the test reads the fields from the spec's own JSON Schema, as the engine publishes them. **Item 6, Debug takes the right column's place.** - `studio-design/StudioDesignSurface.tsx` (flow pillar): while the section is `debug`, the Configuration aside is not drawn. The selection is kept. - In the surface's right slot, the chrome gets `debugTarget: slot.propsTarget`, and opening Debug calls `showProps()`, so the slot shows the half the simulator is drawn in. - In the classic row (no slot), nothing else is needed. - `previews/FlowPreview.tsx`: `FlowPreviewChrome.debugTarget`. With a target, the simulator is portaled into it and the section keeps the canvas alone (`grid-cols-1`). Without one, the simulator column beside the canvas widens from 240px to the aside's 300px. - `FlowSimulatorPanel.tsx`: the toolbar wraps (`flex-wrap`), the row the claim allows. Live readings at the slot's 419px: - idle: 运行 / 单步 / 重置 and the status fit on one row; - paused with 继续: 运行 / 单步 / 继续 / 重置 and 已暂停 fit on one row; - paused on an approval with `approve` and `reject` connections (slice 2's default): the status pill was clipped past the slot's edge before the wrap, and with the wrap it moves to a second row. **Item 7, Add variable.** - New `previews/FlowVariablesPanel.tsx` replaces the read-only `FlowVariablesList`, in both the chrome `variables` section and the classic side panel. It edits only with `onPatch` (the designer's `canEdit`). - Every write is the whole `variables` array, in the shape `FlowVariableSchema` parses. `objectName` rides along untouched. - Name refusals: blank, `$`-led (the spec's `flowBoundVariableNameSchema('variableName')`), or held by another variable. - Default values parse by type (number, `true`/`false`, a JSON object or list). A default the type cannot hold is held with a note, and so is a type change the current default cannot follow. - Rename and remove are refused while a step reads the variable. `flowVariableReaders` reads a whole-word mention in any string of a step (template holes and bare CEL alike), connection conditions, and the flow's `successMessage` / `errorMessage`. The read is deliberately wide, so a refusal can be stricter than the engine, never looser. - An input that declares `objectName` cannot be unticked (the spec refuses `objectName` on a non-input). **Item 8, autosave says 已保存 in the header.** - `StudioDesignSurface.tsx` (flow pillar): a landed draft save no longer calls `announceDraftSaved`. It sets `flowSavedFor`, and the header actions show `auto-autosaved`: a ✓ and 已保存, with an sr-only sentence naming the flow, in a `role="status"`. The next edit clears it. - It is shown only when nothing was edited in flight (`sent.unmoved()`). - A failed save raises one `toast.error` naming the flow, under one id per flow, beside the existing refusal strip. - `StudioPillarKit.tsx`: comment only. `announceDraftSaved` no longer lists the flow pillar; its other callers are unchanged. - Seat ruling 6954475081 holds this to ruling 6545938831 ② on #28345 (write feedback names the item): the badge sits in the flow header's own title row, beside the title, and its accessible text names the flow. Both are pinned. **Item 9, Runs says why it is empty.** - `previews/FlowRunsPanel.tsx`: a `published` prop. For `false` it says 发布并启用后… and does not fetch. For `true`, a failed fetch names the engine alone. For an unknown value, the old sentence stays. - `StudioDesignSurface.tsx`: `readPublishedFlowNames` lists the served flows per scope (the package and its pair) beside the flow list, and the chrome passes `published` for the open flow. A failed read leaves it unknown. - **Deviation from the claim's wording.** The claim said `published` comes from "what the pillar already reads". It is a new read: one `listResponse('flow', { packageId })` per scope per rail load, with no per-row fan-out. The seat acked it as an extension of amendment 6954475081. **Shared.** New and reworded keys in the lazy `studio` namespace (en and zh). No eager pack changes. Changeset: `@object-ui/app-shell` and `@object-ui/i18n` patch. ## Tests - `inspectors/flow-node-config.zhPanel-34818.test.ts` (7 tests). This is the surface's `inspectorStrings.i18n-34818` row, written against the field tables directly. - Every decision and approval label, help, option, column and prose placeholder has CJK in zh-CN, both from the offline table and from the served fields (`jsonSchemaToFlowFields(z.toJSONSchema(ApprovalNodeConfigSchema / DecisionConfigSchema))`). - No `quorum` / `per_group`. - The approvers help is checked in zh and en. - en-US control: the overlay is the identity. - `previews/FlowVariablesPanel-34818.test.tsx` (10 tests): add (two unique names), the edit of all five properties into one row, a held default, the three name refusals (the spec agrees on `$`), the reference guard on rename and remove with a control that renames and removes, the `objectName` input, the read-only control, the zh rows, and the reader's whole-word rule. Every write is parsed with `FlowVariableSchema`. - `previews/FlowRunsPanel.render.test.tsx`: a new describe (4 tests): unpublished with no fetch, published engine-only, and the unknown and empty controls. - `studio-design/StudioDesignSurface.flowAutosave-34818.test.tsx` (9 tests), on the real `AutomationsPillar` with the real `FlowPreview` / `FlowInspector`: - item 8: the badge is in the header's title row beside the `h1`, its sr-only text names the flow, and no success toast; a second edit clears the badge; a refused save gives one error toast, the strip and no badge; the leaf control (an Interfaces page autosave still toasts by its label); - item 6: classic Debug hides the aside and widens to 300px, and Canvas brings it back with the selection; in the right slot, Debug draws the simulator in the slot, calls `showProps`, and keeps the section canvas-only; control: Canvas keeps the aside; - item 9: an unserved flow reads the unpublished sentence with no run fetch, and a served flow with a silent engine reads the engine sentence. - Updated: - `previews/emptyCollection-8526.test.tsx`: the reworded `noVars` sentence. - `previews/flowFieldChrome.i18n-10862-s4.test.tsx`: an editable flow's variables panel shows Input / Output boxes and name values instead of in / out tags, so the case pins those keys. - Both, plus the new Studio test, take a module-top `import '@objectstack/lint'` (`check:test-source-alias`). Ablations (each restored, tree clean after): | Mutation | Result | | --- | --- | | `flowsEmpty \|\| section === 'debug'` back to `flowsEmpty` | classic Debug test red | | chrome `debugTarget: null` | right-slot Debug test red | | drop `setFlowSavedFor(current.name)` | badge title-row and second-edit tests red | | chrome `published: undefined` | both Studio Runs tests red | | `flowVariableReaders` returns `[]` | reference-guard and reader tests red | | `localizeColumn` without the help overlay | both served-fields zh tests red | ## Acceptance notes - "zh-CN 下节点面板没有英文标签或英文说明": live. Start, decision, approval and end panels were read in zh-CN, and no line with an English phrase was left (the approval had 7 before the served-help fix). - "1280 宽下调试工具栏四个按钮和状态都完整可见": live at 1280 in the right slot (419px). - Paused after 单步 ×3 on the approval: 运行 / 单步 / 继续 / 重置 and 已暂停 are on one row, in zh and en. - With `approve` / `reject` connections, the two decision buttons take 继续's place, and the toolbar wraps the status to a second row instead of clipping it. - The decision buttons show the connection keywords (Approve / Reject) in zh as well; they are left as they were, and named as a follow-up. - "连续改三处配置,标题栏不被提示盖住": live. A variable was added, renamed and given a type and default. 0 toasts were on screen, and the header read ✓ 已保存 beside the switch. - Item 9: an unpublished draft flow reads 发布并启用后…; a published showcase flow with the engine up reads 暂无运行记录 (control). ## Verification Measured on head `56a158240`; `84f3858ad` adds only the toolbar's `flex-wrap`, after which the two `FlowSimulatorPanel` suites (6 tests) pass (base `c6ecd1fab`, main merged in at `f825d67a9`), on a shared box. - Tests: the 218 test files under `metadata-admin` and `studio-design` that touch flows, the edited i18n tables, autosave or toasts on the final head: 218 files, 2977 passed and 1 skipped, exit 0. `packages/i18n`: 102 files, 1894 passed, 13 skipped, exit 0. - Type-check: `pnpm --filter @object-ui/app-shell type-check` (both projects) exit 0 on the final head. A first run failed on `columnMenuLabel` in code main brought (#34926), because the local `@object-ui/components` dist predated it. After `pnpm --filter @object-ui/components build` it exits 0. No file of this PR is involved. - Derived gates: `dispatch-gates --commands` on the merged tree gave 38. All 38 were run, plus `check:i18n` and `check:i18n-stale-fill`. 37 exited 0 at once. `check:test-source-alias` asked for the module-top lint import in three edited tests; after that it exits 0. - Eager bundle: not measured. Every new key is in the lazy `studio` namespace, and no eager pack changed. - Live: showcase backend (`pnpm --filter @objectstack/example-showcase dev -- --fresh`), the console under Vite with `DEV_PROXY_TARGET`, and Playwright at 1280×860 in zh-CN and en. The flow is a draft 「新会议提醒」 in an authored package, never published. The readings are in the comment below. The screenshots and the script are in the seat's project files under `objectstack-seat3/34818-live/slice3/`. - Not run locally, left to CI: the full ui suite, `test:repo` and the dogfood battery (no `!` and no `(narrowing)` arm). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzgae1jRRi8FRrTxaZL <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzgae1jRRi8FRrTxaZL --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 119d5db commit 421f180

17 files changed

Lines changed: 1458 additions & 92 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(flow designer): add variables, say why Runs is empty, Debug takes the side column, and autosave reads 已保存 in the header
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
- **Variables can be added and edited.** The Variables tab says what variables are for and has an **Add variable** button. Each row edits its name, type, default value, input and output. A `$` name, a blank name or a duplicate is held with a note. A variable a step still reads cannot be renamed or removed until those steps change, and the note names them. A read-only package keeps the plain list.
12+
- **Runs says why it is empty.** A flow that has never been published reads 「发布并启用后,这里显示每次运行的记录」 and fetches nothing. A published flow whose automation engine does not answer says so, and only that.
13+
- **Debug takes the side column.** While Debug is open the simulator is drawn where the Configuration was: in Studio's right panel, or, where the page keeps its own side column, at that column's width beside the canvas. Leaving Debug brings the Configuration back with the same selection.
14+
- **Autosave reads 已保存 in the header.** A landed flow autosave no longer raises a "Draft saved" toast. The header's 正在保存 settles into 已保存, which names the flow to screen readers and stays until the next edit. A failed save keeps its message and also raises one error toast. Other Studio editors keep their toast.
15+
- **The node panel reads Chinese throughout.** The decision's branching mode, the approval's resolve-as, group and empty-approvers settings, the help the server sends for each approver column, exclude-submitter, backup approvers and the escalation settings, and the prose placeholders are translated, and quorum and per-group sign-off read 法定人数 and 分组会签. The approvers help says the approve and reject connections come with the node.

‎ui/packages/app-shell/src/views/metadata-admin/i18n.ts‎

Lines changed: 113 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,14 @@ export { isZhLocale, translateSchemaFieldLabel, translateSchemaFieldHelp } from
210210
interface FlowFieldZh {
211211
label?: string;
212212
help?: string;
213+
/** objectstack#34818 — a PROSE placeholder only; example literals stay English. */
214+
placeholder?: string;
213215
/** The field's `unsetNotice` (objectui#11054). */
214216
unsetNotice?: string;
215217
/** select option value → zh label. */
216218
opts?: Record<string, string>;
217-
/** objectList column key → zh label (+ nested option labels). */
218-
cols?: Record<string, { label?: string; opts?: Record<string, string> }>;
219+
/** objectList column key → zh label (+ help, prose placeholder, nested option labels). */
220+
cols?: Record<string, { label?: string; help?: string; placeholder?: string; opts?: Record<string, string> }>;
219221
}
220222

221223
/**
@@ -227,6 +229,62 @@ interface FlowFieldZh {
227229
* to its English label, so plugin nodes stay readable. Placeholders (example
228230
* literals like cron strings / URLs) are intentionally left in English.
229231
*/
232+
/**
233+
* The approver row's columns, shared by an approval's `approvers` and its
234+
* `fallbackApprovers` (the same `ApprovalNodeApproverSchema`). objectstack#34818:
235+
* the column help the server serves (the spec's descriptions) read English in
236+
* the zh panel; each is said here in the admin's words.
237+
*/
238+
const APPROVER_COLS_ZH: NonNullable<FlowFieldZh['cols']> = {
239+
type: {
240+
label: '类型',
241+
help:
242+
'这一步如何找到审批人。尽量选组织里的角色(上级、岗位、部门、团队),不要选某个具体的人 —— 人可能离职,换一个环境也可能不存在。' +
243+
'「上级」要等管理员在用户目录里登记了每个人的上级才能找到人;在此之前找不到任何人,请求按本节点「没有解析出审批人时」的设置处理。' +
244+
'「平台管理员」只用于部署自带的打包流程,这里保存的流程不能使用。',
245+
opts: {
246+
user: '用户',
247+
position: '岗位',
248+
org_membership_level: '组织成员(所有者 / 管理员 / 成员)',
249+
team: '团队',
250+
department: '部门',
251+
manager: '上级',
252+
field: '字段',
253+
queue: '队列',
254+
expression: '表达式(CEL)',
255+
platform_admin: '平台管理员',
256+
},
257+
},
258+
value: {
259+
label: '值',
260+
help:
261+
'按所选类型填写具体是谁:用户、成员级别、岗位、团队、部门或队列,或保存审批人的记录字段。「上级」留空。' +
262+
'「表达式」填写返回审批人的 CEL 表达式,可读取 `current.*`、`trigger.*` 和 `vars.*`。',
263+
placeholder: '按“类型”填写:用户、组织成员级别、岗位、团队、部门或字段',
264+
},
265+
resolveAs: {
266+
label: '解析为',
267+
help: '仅用于「表达式」:表达式的结果代表什么。默认每个结果是一个人;选部门、岗位或团队,则其全部成员都是审批人。',
268+
opts: {
269+
user: '用户 ID(默认)',
270+
department: '部门 ID → 部门成员',
271+
position: '岗位名称 → 任职人员',
272+
team: '团队 ID → 团队成员',
273+
},
274+
},
275+
group: {
276+
label: '分组',
277+
help: '分组会签的组名:同名的审批人为一组,这一步需要每一组都通过(如「法务」「财务」)。仅在审批方式为「分组会签」时读取。',
278+
placeholder: '如 法务 / 财务 —— 用于分组会签',
279+
},
280+
organization: {
281+
label: '所属组织',
282+
help:
283+
'到同一集团的另一个组织里找这个审批人,而不是请求所在的组织,例如由集团 CFO 审批某个工厂的采购单。留空则用请求所在的组织。' +
284+
'填 `$root` 表示集团顶层,`$parent` 表示上一级,或填写组织的标识。',
285+
},
286+
};
287+
230288
const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
231289
start: {
232290
triggerType: {
@@ -293,9 +351,23 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
293351
conditions: {
294352
label: '分支',
295353
help: '每个分支包含标签、CEL 表达式和目标节点。表达式为 “true” 的分支即默认 / else 路径。选择目标会接线该分支的出边(创建或更新),清空则断开该边。',
296-
cols: { label: { label: '标签' }, expression: { label: '表达式' }, target: { label: '目标节点' } },
354+
cols: {
355+
label: {
356+
label: '标签',
357+
help: '分支的标签;成立的分支沿同名标签的出边继续(都不成立时走标为默认、或标签为 default 的出边)。',
358+
placeholder: '如 有商机',
359+
},
360+
expression: { label: '表达式', help: '决定是否走这个分支的 CEL 条件(不加 {{ }})。' },
361+
target: { label: '目标节点', placeholder: '下一个节点' },
362+
},
297363
},
298364
condition: { label: '单一条件', help: '旧的单分支条件(CEL)。建议使用上方“分支”;每条边的条件也可写在出边上。' },
365+
// objectstack#34818 — was English in the zh panel.
366+
mode: {
367+
label: '分支方式',
368+
help: '按出边条件分支时:「只走一条」按连线顺序只走第一条成立的连线(不设置即为此方式);「走所有成立的」走每一条成立的连线。都不成立时走默认连线。不能与上方“分支”同时使用。',
369+
opts: { exclusive: '只走一条', inclusive: '走所有成立的' },
370+
},
299371
},
300372
assignment: {
301373
assignments: { label: '赋值', help: '设置变量:每个键为一个变量,值为表达式或字面量。' },
@@ -391,24 +463,8 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
391463
approval: {
392464
approvers: {
393465
label: '审批人',
394-
help: '谁可以处理此步骤。为节点的出边打上 “approve” 和 “reject” 标签。',
395-
cols: {
396-
type: {
397-
label: '类型',
398-
opts: {
399-
user: '用户',
400-
position: '岗位',
401-
org_membership_level: '组织成员(所有者 / 管理员 / 成员)',
402-
team: '团队',
403-
department: '部门',
404-
manager: '上级',
405-
field: '字段',
406-
queue: '队列',
407-
},
408-
},
409-
value: { label: '值' },
410-
group: { label: '分组' },
411-
},
466+
help: '谁可以处理此步骤。插入审批节点时会自带「通过」和「驳回」两条连线;请保留这两条,缺任一条时「问题」页签会提示。',
467+
cols: APPROVER_COLS_ZH,
412468
},
413469
behavior: {
414470
label: '审批方式',
@@ -420,23 +476,54 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
420476
per_group: '分组会签(每组签核)',
421477
},
422478
},
423-
minApprovals: { label: '最少审批数', help: '所需审批数 —— quorum 为总数,per_group 为每组。服务端会做钳制以防死锁。' },
479+
minApprovals: { label: '最少审批数', help: '所需审批数 —— 「法定人数」方式下为总数,「分组会签」方式下为每组的数量。服务端会做钳制以防死锁。' },
424480
lockRecord: { label: '锁定记录', help: '此节点待处理期间锁定触发记录,禁止编辑。' },
425481
approvalStatusField: {
426482
label: '状态字段',
427483
help: '将请求状态(待审 / 通过 / 拒绝)镜像到的业务对象字段。应为只读。',
428484
},
429485
'escalation.enabled': { label: 'SLA 升级', help: '在超时内未做决策时升级。' },
430-
'escalation.timeoutHours': { label: '超时(小时)' },
486+
'escalation.timeoutHours': {
487+
label: '超时(小时)',
488+
help: '请求最多等多少小时后执行升级。按日历小时计算,夜间、周末和节假日都算在内;平台没有工作时间日历:周五 17:00 发起、设为 4 小时的请求会在当天 21:00 升级。',
489+
},
431490
'escalation.action': {
432491
label: '超时动作',
492+
help: '超过期限后怎么办:改派给其他人、自动通过、自动拒绝,或通知某人(默认)。',
433493
opts: { notify: '通知', reassign: '改派', auto_approve: '自动通过', auto_reject: '自动拒绝' },
434494
},
435-
'escalation.escalateTo': { label: '升级至' },
436-
'escalation.notifySubmitter': { label: '通知提交人' },
495+
'escalation.escalateTo': {
496+
label: '升级至',
497+
help: '超过期限后由谁接手或接到通知:通常是一个岗位,也可以是具体的人。填写岗位名称或 position:<名称>、用户 ID 或邮箱。不接受 team:、department:、org_membership_level: 或 role: 这类地址,因为没有审批人以它们的身份处理。',
498+
placeholder: '岗位名称或用户 ID',
499+
},
500+
'escalation.notifySubmitter': { label: '通知提交人', help: '升级时通知提交请求的人。' },
437501
maxRevisions: {
438502
label: '最多退回次数',
439-
help: '请求自动拒绝前的最多退回修订次数(0 表示禁用退回)。需要一条 “revise” 出边才生效。',
503+
help: '请求自动拒绝前的最多退回修订次数(0 表示禁用退回)。需要一条审批分支为「退回修改」的出边才生效。',
504+
},
505+
// objectstack#34818 — was English in the zh panel.
506+
onEmptyApprovers: {
507+
label: '没有解析出审批人时',
508+
help: '进入节点时解析出的审批人为空怎么办。「自动通过」会让记录直接放行,请确认确实需要再选。',
509+
opts: {
510+
admin_rescue: '等待管理员接手(默认)',
511+
fail: '节点失败(配置有误)',
512+
auto_approve: '自动通过(直接放行!)',
513+
fallback: '交给备用审批人',
514+
},
515+
},
516+
excludeSubmitter: {
517+
label: '排除提交人',
518+
help:
519+
'防止自己审批自己的请求:开启后,不论审批人是怎样找到的,提交人都会从这一步的审批人中去掉。' +
520+
'去掉后如果没人了,请求按「没有解析出审批人时」的设置处理(默认交给组织管理员,或交给你指定的备用审批人),绝不会自动通过,审批记录会写明原因。' +
521+
'因此不能与「自动通过」同时选择。默认关闭。',
522+
},
523+
fallbackApprovers: {
524+
label: '备用审批人',
525+
help: '这一步找不到其他审批人时,由这些人决定。仅在「没有解析出审批人时」选择「交给备用审批人」时读取。',
526+
cols: APPROVER_COLS_ZH,
440527
},
441528
},
442529
wait: {

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-node-config.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,9 @@ const FLOW_NODE_CONFIG: Record<string, FlowConfigField[]> = {
10041004
// nodes wired to its `approve` / `reject` out-edges).
10051005
approval: [
10061006
cfg('approvers', 'Approvers', 'objectList', {
1007-
help: 'Who may act on this step. Wire the node’s out-edges with labels "approve" and "reject".',
1007+
// objectstack#34818 — the designer inserts the node with its `approve`
1008+
// and `reject` out-edges, and Problems names one that goes missing.
1009+
help: 'Who may act on this step. The node comes with an "approve" and a "reject" connection; keep both, or the Problems tab reports the missing one.',
10081010
columns: [
10091011
{
10101012
key: 'type',
@@ -1508,14 +1510,19 @@ function withUnmappedDeclaredKeys(
15081510
return out;
15091511
}
15101512

1511-
/** Overlay a column's zh label / option labels (English is the fallback). */
1513+
/** Overlay a column's zh label / help / option labels (English is the fallback). */
15121514
function localizeColumn(
15131515
col: FlowConfigColumn,
1514-
cz: { label?: string; opts?: Record<string, string> } | undefined,
1516+
cz: { label?: string; help?: string; placeholder?: string; opts?: Record<string, string> } | undefined,
15151517
): FlowConfigColumn {
15161518
if (!cz) return col;
15171519
const out: FlowConfigColumn = { ...col };
15181520
if (cz.label) out.label = cz.label;
1521+
// objectstack#34818 — the served column help (the spec's description).
1522+
if (cz.help) out.help = cz.help;
1523+
// objectstack#34818 — only a column the zh table names a placeholder for:
1524+
// a prose hint, never an example literal.
1525+
if (col.placeholder && cz.placeholder) out.placeholder = cz.placeholder;
15191526
if (col.options && cz.opts) {
15201527
out.options = col.options.map((o) => ({ ...o, label: cz.opts![o.value] ?? o.label }));
15211528
}
@@ -1533,6 +1540,7 @@ function localizeField(rawType: string, canonicalType: string, field: FlowConfig
15331540
if (z.label) out.label = z.label;
15341541
if (z.help) out.help = z.help;
15351542
if (field.unsetNotice && z.unsetNotice) out.unsetNotice = z.unsetNotice;
1543+
if (field.placeholder && z.placeholder) out.placeholder = z.placeholder;
15361544
if (field.options && z.opts) {
15371545
out.options = field.options.map((o) => ({ ...o, label: z.opts![o.value] ?? o.label }));
15381546
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#34818 item 5 — the decision and approval panels read no English
5+
* in zh-CN: every label, help, option and prose placeholder the inspector
6+
* draws for them goes through the zh table, and the approval words
7+
* `quorum` / `per_group` are said in Chinese. Example literals (a CEL
8+
* expression, a number, a field name) stay as written. en-US is the control:
9+
* the table is a no-op there.
10+
*/
11+
12+
import { describe, expect, it } from 'vitest';
13+
import { z } from 'zod';
14+
import { ApprovalNodeConfigSchema, DecisionConfigSchema } from '@objectstack/spec/automation';
15+
import { fieldsForNodeType, localizeFlowFields, type FlowConfigField } from './flow-node-config.js';
16+
import { jsonSchemaToFlowFields } from './json-schema-to-fields.js';
17+
18+
const CJK = /[㐀-鿿]/;
19+
20+
/** Placeholders that are example literals, not prose: left as written on purpose. */
21+
const LITERAL_PLACEHOLDERS = new Set(['expiring_deals.length > 0', 'amount > 10000', '1', '3', '24', 'approval_status']);
22+
23+
/** Every visible string of a field, with where it sits. */
24+
function strings(field: FlowConfigField): Array<[string, string]> {
25+
const out: Array<[string, string]> = [[`${field.id}.label`, field.label]];
26+
if (field.help) out.push([`${field.id}.help`, field.help]);
27+
if (field.placeholder && !LITERAL_PLACEHOLDERS.has(field.placeholder)) out.push([`${field.id}.placeholder`, field.placeholder]);
28+
for (const o of field.options ?? []) out.push([`${field.id}.opt.${o.value}`, o.label]);
29+
for (const c of field.columns ?? []) {
30+
out.push([`${field.id}.col.${c.key}.label`, c.label]);
31+
if (c.help) out.push([`${field.id}.col.${c.key}.help`, c.help]);
32+
if (c.placeholder && !LITERAL_PLACEHOLDERS.has(c.placeholder)) out.push([`${field.id}.col.${c.key}.placeholder`, c.placeholder]);
33+
for (const o of c.options ?? []) out.push([`${field.id}.col.${c.key}.opt.${o.value}`, o.label]);
34+
}
35+
return out;
36+
}
37+
38+
describe('zh-CN decision and approval panels (objectstack#34818 item 5)', () => {
39+
it.each(['decision', 'approval'])('every %s string reads Chinese', (type) => {
40+
const english = strings(fieldsForNodeType(type)[0]!).length; // the table is non-empty
41+
expect(english).toBeGreaterThan(0);
42+
const leftEnglish = localizeFlowFields(type, fieldsForNodeType(type), 'zh-CN')
43+
.flatMap(strings)
44+
.filter(([, text]) => !CJK.test(text));
45+
expect(leftEnglish).toEqual([]);
46+
});
47+
48+
// The fields as the engine publishes them online: the installed contract's
49+
// own JSON Schema, whose descriptions are the help (the live panel drew
50+
// `excludeSubmitter`, `fallbackApprovers` and the approver columns' help in
51+
// English before this pin).
52+
it.each([
53+
['approval', ApprovalNodeConfigSchema],
54+
['decision', DecisionConfigSchema],
55+
] as const)('every served %s string reads Chinese', (type, schema) => {
56+
const served = jsonSchemaToFlowFields(z.toJSONSchema(schema, { io: 'input' }))!;
57+
expect(served.length).toBeGreaterThan(0);
58+
const leftEnglish = localizeFlowFields(type, served, 'zh-CN')
59+
.flatMap(strings)
60+
.filter(([, text]) => !CJK.test(text));
61+
expect(leftEnglish).toEqual([]);
62+
});
63+
64+
it('the approval words are said in Chinese, not as `quorum` / `per_group`', () => {
65+
const all = localizeFlowFields('approval', fieldsForNodeType('approval'), 'zh-CN').flatMap(strings);
66+
expect(all.filter(([, text]) => /quorum|per_group/.test(text))).toEqual([]);
67+
});
68+
69+
it('the approvers help says the node comes with both connections', () => {
70+
const [approvers] = localizeFlowFields('approval', fieldsForNodeType('approval'), 'zh-CN');
71+
expect(approvers!.help).toContain('自带「通过」和「驳回」两条连线');
72+
const [en] = fieldsForNodeType('approval');
73+
expect(en!.help).toContain('comes with an "approve" and a "reject" connection');
74+
expect(en!.help).not.toMatch(/Wire the node/);
75+
});
76+
77+
it('control: en-US draws the English table unchanged', () => {
78+
const en = fieldsForNodeType('approval');
79+
expect(localizeFlowFields('approval', en, 'en-US')).toBe(en);
80+
const mode = fieldsForNodeType('decision').find((f) => f.id === 'mode')!;
81+
expect(mode.label).toBe('Branch mode');
82+
});
83+
});

0 commit comments

Comments
 (0)