Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/34818-flow-designer-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(flow designer): add variables, say why Runs is empty, Debug takes the side column, and autosave reads 已保存 in the header

Clause-②: no
Metadata-protocol: none

- **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.
- **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.
- **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.
- **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.
- **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.
139 changes: 113 additions & 26 deletions ui/packages/app-shell/src/views/metadata-admin/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ export { isZhLocale, translateSchemaFieldLabel, translateSchemaFieldHelp } from
interface FlowFieldZh {
label?: string;
help?: string;
/** objectstack#34818 — a PROSE placeholder only; example literals stay English. */
placeholder?: string;
/** The field's `unsetNotice` (objectui#11054). */
unsetNotice?: string;
/** select option value → zh label. */
opts?: Record<string, string>;
/** objectList column key → zh label (+ nested option labels). */
cols?: Record<string, { label?: string; opts?: Record<string, string> }>;
/** objectList column key → zh label (+ help, prose placeholder, nested option labels). */
cols?: Record<string, { label?: string; help?: string; placeholder?: string; opts?: Record<string, string> }>;
}

/**
Expand All @@ -227,6 +229,62 @@ interface FlowFieldZh {
* to its English label, so plugin nodes stay readable. Placeholders (example
* literals like cron strings / URLs) are intentionally left in English.
*/
/**
* The approver row's columns, shared by an approval's `approvers` and its
* `fallbackApprovers` (the same `ApprovalNodeApproverSchema`). objectstack#34818:
* the column help the server serves (the spec's descriptions) read English in
* the zh panel; each is said here in the admin's words.
*/
const APPROVER_COLS_ZH: NonNullable<FlowFieldZh['cols']> = {
type: {
label: '类型',
help:
'这一步如何找到审批人。尽量选组织里的角色(上级、岗位、部门、团队),不要选某个具体的人 —— 人可能离职,换一个环境也可能不存在。' +
'「上级」要等管理员在用户目录里登记了每个人的上级才能找到人;在此之前找不到任何人,请求按本节点「没有解析出审批人时」的设置处理。' +
'「平台管理员」只用于部署自带的打包流程,这里保存的流程不能使用。',
opts: {
user: '用户',
position: '岗位',
org_membership_level: '组织成员(所有者 / 管理员 / 成员)',
team: '团队',
department: '部门',
manager: '上级',
field: '字段',
queue: '队列',
expression: '表达式(CEL)',
platform_admin: '平台管理员',
},
},
value: {
label: '值',
help:
'按所选类型填写具体是谁:用户、成员级别、岗位、团队、部门或队列,或保存审批人的记录字段。「上级」留空。' +
'「表达式」填写返回审批人的 CEL 表达式,可读取 `current.*`、`trigger.*` 和 `vars.*`。',
placeholder: '按“类型”填写:用户、组织成员级别、岗位、团队、部门或字段',
},
resolveAs: {
label: '解析为',
help: '仅用于「表达式」:表达式的结果代表什么。默认每个结果是一个人;选部门、岗位或团队,则其全部成员都是审批人。',
opts: {
user: '用户 ID(默认)',
department: '部门 ID → 部门成员',
position: '岗位名称 → 任职人员',
team: '团队 ID → 团队成员',
},
},
group: {
label: '分组',
help: '分组会签的组名:同名的审批人为一组,这一步需要每一组都通过(如「法务」「财务」)。仅在审批方式为「分组会签」时读取。',
placeholder: '如 法务 / 财务 —— 用于分组会签',
},
organization: {
label: '所属组织',
help:
'到同一集团的另一个组织里找这个审批人,而不是请求所在的组织,例如由集团 CFO 审批某个工厂的采购单。留空则用请求所在的组织。' +
'填 `$root` 表示集团顶层,`$parent` 表示上一级,或填写组织的标识。',
},
};

const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
start: {
triggerType: {
Expand Down Expand Up @@ -293,9 +351,23 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
conditions: {
label: '分支',
help: '每个分支包含标签、CEL 表达式和目标节点。表达式为 “true” 的分支即默认 / else 路径。选择目标会接线该分支的出边(创建或更新),清空则断开该边。',
cols: { label: { label: '标签' }, expression: { label: '表达式' }, target: { label: '目标节点' } },
cols: {
label: {
label: '标签',
help: '分支的标签;成立的分支沿同名标签的出边继续(都不成立时走标为默认、或标签为 default 的出边)。',
placeholder: '如 有商机',
},
expression: { label: '表达式', help: '决定是否走这个分支的 CEL 条件(不加 {{ }})。' },
target: { label: '目标节点', placeholder: '下一个节点' },
},
},
condition: { label: '单一条件', help: '旧的单分支条件(CEL)。建议使用上方“分支”;每条边的条件也可写在出边上。' },
// objectstack#34818 — was English in the zh panel.
mode: {
label: '分支方式',
help: '按出边条件分支时:「只走一条」按连线顺序只走第一条成立的连线(不设置即为此方式);「走所有成立的」走每一条成立的连线。都不成立时走默认连线。不能与上方“分支”同时使用。',
opts: { exclusive: '只走一条', inclusive: '走所有成立的' },
},
},
assignment: {
assignments: { label: '赋值', help: '设置变量:每个键为一个变量,值为表达式或字面量。' },
Expand Down Expand Up @@ -391,24 +463,8 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
approval: {
approvers: {
label: '审批人',
help: '谁可以处理此步骤。为节点的出边打上 “approve” 和 “reject” 标签。',
cols: {
type: {
label: '类型',
opts: {
user: '用户',
position: '岗位',
org_membership_level: '组织成员(所有者 / 管理员 / 成员)',
team: '团队',
department: '部门',
manager: '上级',
field: '字段',
queue: '队列',
},
},
value: { label: '值' },
group: { label: '分组' },
},
help: '谁可以处理此步骤。插入审批节点时会自带「通过」和「驳回」两条连线;请保留这两条,缺任一条时「问题」页签会提示。',
cols: APPROVER_COLS_ZH,
},
behavior: {
label: '审批方式',
Expand All @@ -420,23 +476,54 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
per_group: '分组会签(每组签核)',
},
},
minApprovals: { label: '最少审批数', help: '所需审批数 —— quorum 为总数,per_group 为每组。服务端会做钳制以防死锁。' },
minApprovals: { label: '最少审批数', help: '所需审批数 —— 「法定人数」方式下为总数,「分组会签」方式下为每组的数量。服务端会做钳制以防死锁。' },
lockRecord: { label: '锁定记录', help: '此节点待处理期间锁定触发记录,禁止编辑。' },
approvalStatusField: {
label: '状态字段',
help: '将请求状态(待审 / 通过 / 拒绝)镜像到的业务对象字段。应为只读。',
},
'escalation.enabled': { label: 'SLA 升级', help: '在超时内未做决策时升级。' },
'escalation.timeoutHours': { label: '超时(小时)' },
'escalation.timeoutHours': {
label: '超时(小时)',
help: '请求最多等多少小时后执行升级。按日历小时计算,夜间、周末和节假日都算在内;平台没有工作时间日历:周五 17:00 发起、设为 4 小时的请求会在当天 21:00 升级。',
},
'escalation.action': {
label: '超时动作',
help: '超过期限后怎么办:改派给其他人、自动通过、自动拒绝,或通知某人(默认)。',
opts: { notify: '通知', reassign: '改派', auto_approve: '自动通过', auto_reject: '自动拒绝' },
},
'escalation.escalateTo': { label: '升级至' },
'escalation.notifySubmitter': { label: '通知提交人' },
'escalation.escalateTo': {
label: '升级至',
help: '超过期限后由谁接手或接到通知:通常是一个岗位,也可以是具体的人。填写岗位名称或 position:<名称>、用户 ID 或邮箱。不接受 team:、department:、org_membership_level: 或 role: 这类地址,因为没有审批人以它们的身份处理。',
placeholder: '岗位名称或用户 ID',
},
'escalation.notifySubmitter': { label: '通知提交人', help: '升级时通知提交请求的人。' },
maxRevisions: {
label: '最多退回次数',
help: '请求自动拒绝前的最多退回修订次数(0 表示禁用退回)。需要一条 “revise” 出边才生效。',
help: '请求自动拒绝前的最多退回修订次数(0 表示禁用退回)。需要一条审批分支为「退回修改」的出边才生效。',
},
// objectstack#34818 — was English in the zh panel.
onEmptyApprovers: {
label: '没有解析出审批人时',
help: '进入节点时解析出的审批人为空怎么办。「自动通过」会让记录直接放行,请确认确实需要再选。',
opts: {
admin_rescue: '等待管理员接手(默认)',
fail: '节点失败(配置有误)',
auto_approve: '自动通过(直接放行!)',
fallback: '交给备用审批人',
},
},
excludeSubmitter: {
label: '排除提交人',
help:
'防止自己审批自己的请求:开启后,不论审批人是怎样找到的,提交人都会从这一步的审批人中去掉。' +
'去掉后如果没人了,请求按「没有解析出审批人时」的设置处理(默认交给组织管理员,或交给你指定的备用审批人),绝不会自动通过,审批记录会写明原因。' +
'因此不能与「自动通过」同时选择。默认关闭。',
},
fallbackApprovers: {
label: '备用审批人',
help: '这一步找不到其他审批人时,由这些人决定。仅在「没有解析出审批人时」选择「交给备用审批人」时读取。',
cols: APPROVER_COLS_ZH,
},
},
wait: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,9 @@ const FLOW_NODE_CONFIG: Record<string, FlowConfigField[]> = {
// nodes wired to its `approve` / `reject` out-edges).
approval: [
cfg('approvers', 'Approvers', 'objectList', {
help: 'Who may act on this step. Wire the node’s out-edges with labels "approve" and "reject".',
// objectstack#34818 — the designer inserts the node with its `approve`
// and `reject` out-edges, and Problems names one that goes missing.
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.',
columns: [
{
key: 'type',
Expand Down Expand Up @@ -1508,14 +1510,19 @@ function withUnmappedDeclaredKeys(
return out;
}

/** Overlay a column's zh label / option labels (English is the fallback). */
/** Overlay a column's zh label / help / option labels (English is the fallback). */
function localizeColumn(
col: FlowConfigColumn,
cz: { label?: string; opts?: Record<string, string> } | undefined,
cz: { label?: string; help?: string; placeholder?: string; opts?: Record<string, string> } | undefined,
): FlowConfigColumn {
if (!cz) return col;
const out: FlowConfigColumn = { ...col };
if (cz.label) out.label = cz.label;
// objectstack#34818 — the served column help (the spec's description).
if (cz.help) out.help = cz.help;
// objectstack#34818 — only a column the zh table names a placeholder for:
// a prose hint, never an example literal.
if (col.placeholder && cz.placeholder) out.placeholder = cz.placeholder;
if (col.options && cz.opts) {
out.options = col.options.map((o) => ({ ...o, label: cz.opts![o.value] ?? o.label }));
}
Expand All @@ -1533,6 +1540,7 @@ function localizeField(rawType: string, canonicalType: string, field: FlowConfig
if (z.label) out.label = z.label;
if (z.help) out.help = z.help;
if (field.unsetNotice && z.unsetNotice) out.unsetNotice = z.unsetNotice;
if (field.placeholder && z.placeholder) out.placeholder = z.placeholder;
if (field.options && z.opts) {
out.options = field.options.map((o) => ({ ...o, label: z.opts![o.value] ?? o.label }));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#34818 item 5 — the decision and approval panels read no English
* in zh-CN: every label, help, option and prose placeholder the inspector
* draws for them goes through the zh table, and the approval words
* `quorum` / `per_group` are said in Chinese. Example literals (a CEL
* expression, a number, a field name) stay as written. en-US is the control:
* the table is a no-op there.
*/

import { describe, expect, it } from 'vitest';
import { z } from 'zod';
import { ApprovalNodeConfigSchema, DecisionConfigSchema } from '@objectstack/spec/automation';
import { fieldsForNodeType, localizeFlowFields, type FlowConfigField } from './flow-node-config.js';
import { jsonSchemaToFlowFields } from './json-schema-to-fields.js';

const CJK = /[㐀-鿿]/;

/** Placeholders that are example literals, not prose: left as written on purpose. */
const LITERAL_PLACEHOLDERS = new Set(['expiring_deals.length > 0', 'amount > 10000', '1', '3', '24', 'approval_status']);

/** Every visible string of a field, with where it sits. */
function strings(field: FlowConfigField): Array<[string, string]> {
const out: Array<[string, string]> = [[`${field.id}.label`, field.label]];
if (field.help) out.push([`${field.id}.help`, field.help]);
if (field.placeholder && !LITERAL_PLACEHOLDERS.has(field.placeholder)) out.push([`${field.id}.placeholder`, field.placeholder]);
for (const o of field.options ?? []) out.push([`${field.id}.opt.${o.value}`, o.label]);
for (const c of field.columns ?? []) {
out.push([`${field.id}.col.${c.key}.label`, c.label]);
if (c.help) out.push([`${field.id}.col.${c.key}.help`, c.help]);
if (c.placeholder && !LITERAL_PLACEHOLDERS.has(c.placeholder)) out.push([`${field.id}.col.${c.key}.placeholder`, c.placeholder]);
for (const o of c.options ?? []) out.push([`${field.id}.col.${c.key}.opt.${o.value}`, o.label]);
}
return out;
}

describe('zh-CN decision and approval panels (objectstack#34818 item 5)', () => {
it.each(['decision', 'approval'])('every %s string reads Chinese', (type) => {
const english = strings(fieldsForNodeType(type)[0]!).length; // the table is non-empty
expect(english).toBeGreaterThan(0);
const leftEnglish = localizeFlowFields(type, fieldsForNodeType(type), 'zh-CN')
.flatMap(strings)
.filter(([, text]) => !CJK.test(text));
expect(leftEnglish).toEqual([]);
});

// The fields as the engine publishes them online: the installed contract's
// own JSON Schema, whose descriptions are the help (the live panel drew
// `excludeSubmitter`, `fallbackApprovers` and the approver columns' help in
// English before this pin).
it.each([
['approval', ApprovalNodeConfigSchema],
['decision', DecisionConfigSchema],
] as const)('every served %s string reads Chinese', (type, schema) => {
const served = jsonSchemaToFlowFields(z.toJSONSchema(schema, { io: 'input' }))!;
expect(served.length).toBeGreaterThan(0);
const leftEnglish = localizeFlowFields(type, served, 'zh-CN')
.flatMap(strings)
.filter(([, text]) => !CJK.test(text));
expect(leftEnglish).toEqual([]);
});

it('the approval words are said in Chinese, not as `quorum` / `per_group`', () => {
const all = localizeFlowFields('approval', fieldsForNodeType('approval'), 'zh-CN').flatMap(strings);
expect(all.filter(([, text]) => /quorum|per_group/.test(text))).toEqual([]);
});

it('the approvers help says the node comes with both connections', () => {
const [approvers] = localizeFlowFields('approval', fieldsForNodeType('approval'), 'zh-CN');
expect(approvers!.help).toContain('自带「通过」和「驳回」两条连线');
const [en] = fieldsForNodeType('approval');
expect(en!.help).toContain('comes with an "approve" and a "reject" connection');
expect(en!.help).not.toMatch(/Wire the node/);
});

it('control: en-US draws the English table unchanged', () => {
const en = fieldsForNodeType('approval');
expect(localizeFlowFields('approval', en, 'en-US')).toBe(en);
const mode = fieldsForNodeType('decision').find((f) => f.id === 'mode')!;
expect(mode.label).toBe('Branch mode');
});
});
Loading
Loading