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
24 changes: 24 additions & 0 deletions .changeset/34652-action-table-column-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@objectstack/spec': minor
'@objectstack/lint': patch
'@objectstack/platform-objects': patch
'@object-ui/i18n': patch
---

feat(spec, lint, i18n): an action answer table's column headers have a translation bundle key

Clause-②: yes (widening) — `ActionResultDialogTranslationSchema` and the action `preflight` translation node accept a new optional `columns` map, `columns.<field path>.<column path>` (both keys literal, dots included), beside `fields`; every bundle that parsed before parses unchanged and reads the same.
Metadata-protocol: added
Skills-docs: follow-up owed — skills/objectstack-i18n/SKILL.md

A `format: 'table'` field in an action's `resultDialog.fields` or `preflight.fields` declares `columns: [{ path, label }]`, and each column's `label` is translatable, but no bundle key carried it, so a table's headers stayed in the authored language in every locale. The key is `objects.<object>._actions.<action>.resultDialog.columns.<field path>.<column path>` (and `….preflight.columns.…`; `globalActions.<action>.…` for an object-less action):

```ts
resultDialog: {
fields: { rows: '逐行结果' },
columns: { rows: { email: '邮箱', 'error.message': '未添加的原因' } },
}
```

- `os i18n extract` lists one key per labelled column, `os validate` refuses a column key that names no declared table field or column (`translation-target-unknown`), and `resolveActionResultDialog` / `resolveActionPreflight` (so `translateAction` and the served metadata) and the console's `useObjectLabel` overlay the translated header; a column with no key keeps its authored label.
- The platform bundles carry the nine column headers of `sys_user.import_sso_users`'s result table in every shipped locale.
1 change: 1 addition & 0 deletions content/docs/protocol/kernel/i18n-standard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ beneath an action entry are judged the same way under either.
| `{action}.params.{param}.options.{value}` | an option's stored **`value`** in that param's inline `options` — a warning, as on a field. A param that references a `field` and declares no inline `options` takes the field's list when the dialog renders, so its option keys are not judged |
| `{action}.outcomeMessages.{outcome}` | an outcome the action's own `outcomeMessages` declares |
| `{action}.resultDialog.fields.{path}` | the literal `path` of a field the action's `resultDialog.fields[]` declares — dots included, so `client.secret` is one key |
| `{action}.resultDialog.columns.{path}.{column}` / `{action}.preflight.columns.{path}.{column}` | a column header of a table: `{path}` the literal `path` of a `format: 'table'` field in that block's `fields[]`, `{column}` the literal `path` of one of its `columns[]` — dots included at both levels, so `columns.rows["error.message"]` is two keys deep, not three |
| `{action}.resultDialog.title` / `.description` / `.acknowledge` | an action that declares a `resultDialog`, whether or not the dialog sets that text itself — for an action that declares none, nothing reads the dialog's copy |
| `apps.{app}` | an app declared, or one a `navigationContributions` entry anywhere in the artifact contributes into — including an app owned outside the artifact; under an app that is only contributed into, `apps.{app}.label` may be left out (the owning package's label survives the merge) |
| `apps.{app}.navigation.{id}` | a navigation item `id` the app declares (nested `children` and `areas[]` included) or one contributed into it; under an app that is only contributed into, the contributed ids alone |
Expand Down
21 changes: 11 additions & 10 deletions content/docs/references/system/translation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Translations for an action result dialog
| **description** | `string` | optional | Translated result dialog description |
| **acknowledge** | `string` | optional | Translated acknowledge button label |
| **fields** | `Record<string, string>` | optional | Result field labels keyed by the literal field path declared in the action metadata (keys may contain dots) |
| **columns** | `Record<string, Record<string, string>>` | optional | Table column header labels: keyed by the literal path of a `format: 'table'` field, then by the literal path of one of its `columns[]` (keys may contain dots) |


---
Expand Down Expand Up @@ -136,8 +137,8 @@ Translation data for a single field
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |

### Nested Shape: `ObjectTranslationData._sections[string]`

Expand Down Expand Up @@ -241,8 +242,8 @@ Translation data for a single object
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |

### Nested Shape: `PlatformTranslationData.dashboards[string]`

Expand Down Expand Up @@ -421,8 +422,8 @@ Translation data for a single object
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |

### Nested Shape: `ServedTranslationData.dashboards[string]`

Expand Down Expand Up @@ -664,8 +665,8 @@ Translation data for a single object
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |

### Nested Shape: `TranslationData.dashboards[string]`

Expand Down Expand Up @@ -876,8 +877,8 @@ Translation data for a single object
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |

### Nested Shape: `TranslationItem.dashboards[string]`

Expand Down
5 changes: 4 additions & 1 deletion content/docs/ui/translations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default defineStack({
| Bulk-action copy on a list view (button, confirm prompt, dialog fields) | `objects.<name>._views.<view>.bulkActions.<def>.label` / `.confirmText` / `.confirmLabel` / `.params.<param>.label` / `.help` / `.placeholder` — a bulk param's hint is `help`, not `helpText` |
| Action labels, confirm text, success messages, disabled reasons, param dialog submit labels, confirm and param dialog dismiss labels | `objects.<name>._actions.<action>` |
| Action result dialogs (title / description / acknowledge / field labels) | `objects.<name>._actions.<action>.resultDialog` |
| Column headers of a table in an action's result dialog or preflight panel | `objects.<name>._actions.<action>.resultDialog.columns.<field path>.<column path>` / `.preflight.columns.<field path>.<column path>` — a sibling of `fields`, both paths written literally, dots included |
| Form sections | `objects.<name>._sections.<section>` |
| Custom validation-rule messages | `objects.<name>._validations.<rule>.message` |
| App navigation | `apps.<app>.navigation.<id>.label` |
Expand Down Expand Up @@ -159,7 +160,9 @@ is resolved by this one rule.
`resultDialog` shown by actions like `create_user` (temporary password), 2FA
backup codes, and OAuth client-secret rotation carries its own
`_actions.<action>.resultDialog` slot (`title` / `description` / `acknowledge`
and `fields` keyed by the literal result-field path, e.g. `"user.email"`).
and `fields` keyed by the literal result-field path, e.g. `"user.email"`; a
`format: 'table'` field's column headers sit beside `fields` under
`columns.<field path>.<column path>`).
`os i18n extract` emits these keys; the shipped platform dialogs ship
en / zh-CN / ja-JP / es-ES copy. Separately, **platform notification and
storage strings localize to the recipient's locale** — collaboration
Expand Down
69 changes: 69 additions & 0 deletions packages/lint/src/i18n-walk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,72 @@ describe('collectExpectedEntries — preflight field labels', () => {
expect(preflightKeys(['objects', 'sys_package', '_actions', 'install_bare'])).toEqual([]);
});
});

/**
* [#34652] `resultDialog.columns.<path>.<column_path>` and
* `preflight.columns.<path>.<column_path>` — one key per labelled column of a
* `format: 'table'` field, beside the field's own `fields.<path>` key, both
* levels keyed by the literal path (a dotted path stays ONE segment).
*/
describe('collectExpectedEntries — answer table column labels', () => {
const table = {
path: 'rows',
label: 'Result per row',
format: 'table',
columns: [
{ path: 'email', label: 'Email' },
{ path: 'error.message', label: { en: 'Not added because', 'zh-CN': '未添加的原因' } },
{ path: 'row', format: 'json' },
],
};
const stack = {
objects: [
{
name: 'sys_user',
label: 'User',
fields: {},
actions: [
{
name: 'import_users',
label: 'Import',
type: 'api',
params: [{ name: 'csv', type: 'text' }],
resultDialog: { title: 'Done', fields: [{ path: 'summary.added', label: 'Added' }, table] },
preflight: { read: { url: '/api/v1/x' }, fields: [table] },
},
],
},
],
};
const entries = collectExpectedEntries(stack, { warnedGroups: new Set() });
const root = ['objects', 'sys_user', '_actions', 'import_users'];
const blockKeys = (block: string) =>
entries
.filter((e) => root.every((seg, i) => e.path[i] === seg) && e.path[root.length] === block)
.map((e) => e.path.slice(root.length));

it('lists a key per labelled column beside the field key, an unlabelled column none', () => {
expect(blockKeys('resultDialog')).toEqual([
// The optional prose slots are listed whether authored or not.
['resultDialog', 'title'],
['resultDialog', 'description'],
['resultDialog', 'acknowledge'],
['resultDialog', 'fields', 'summary.added'],
['resultDialog', 'fields', 'rows'],
['resultDialog', 'columns', 'rows', 'email'],
['resultDialog', 'columns', 'rows', 'error.message'],
]);
const email = entries.find((e) => e.path.join('\u0000') === [...root, 'resultDialog', 'columns', 'rows', 'email'].join('\u0000'));
expect(email).toMatchObject({ sourceValue: 'Email', inline: 'Email', source: 'action', objectName: 'sys_user' });
const reason = entries.find((e) => e.path.join('\u0000') === [...root, 'resultDialog', 'columns', 'rows', 'error.message'].join('\u0000'));
expect(reason?.inlineLocales).toEqual({ en: 'Not added because', 'zh-CN': '未添加的原因' });
});

it('lists the same column keys under a preflight table field', () => {
expect(blockKeys('preflight')).toEqual([
['preflight', 'fields', 'rows'],
['preflight', 'columns', 'rows', 'email'],
['preflight', 'columns', 'rows', 'error.message'],
]);
});
});
36 changes: 34 additions & 2 deletions packages/lint/src/i18n-walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@
* objects.<name>._actions.<action>.params.<param>.options.<value>
* objects.<name>._actions.<action>.resultDialog.title / .description / .acknowledge
* objects.<name>._actions.<action>.resultDialog.fields.<path>
* objects.<name>._actions.<action>.resultDialog.columns.<path>.<column_path>
* objects.<name>._actions.<action>.preflight.fields.<path>
* objects.<name>._actions.<action>.preflight.columns.<path>.<column_path>
* globalActions.<action>.label / .description / .confirmText / .successMessage
* / .disabledReason / .submitText (beside a non-empty `params`)
* / .cancelText (beside `confirmText` or a non-empty `params`)
* globalActions.<action>.outcomeMessages.<outcome>
* globalActions.<action>.params.<param>.* / .resultDialog.* / .preflight.fields.<path>
* / .preflight.columns.<path>.<column_path>
* (same shape as object actions)
* apps.<app>.label / .description
* apps.<app>.navigation.<id>.label
Expand Down Expand Up @@ -767,8 +770,9 @@ function pushActionParams(
}

/**
* Emit `resultDialog.{title,description,acknowledge}` and
* `resultDialog.fields.<path>` entries under an action's translation root.
* Emit `resultDialog.{title,description,acknowledge}`,
* `resultDialog.fields.<path>` and `resultDialog.columns.<path>.<column_path>`
* entries under an action's translation root.
* Mirrors `ActionResultDialogTranslationSchema` in @objectstack/spec and the
* client-side `actionResultDialog` resolver. Field entries are keyed by the
* LITERAL result-field path (`"user.email"`) — the dot stays inside a single
Expand Down Expand Up @@ -814,10 +818,37 @@ function pushActionResultDialog(
if (!field || typeof field !== 'object') continue;
if (typeof field.path !== 'string' || field.path.length === 0) continue;
pushEntry(out, [...base, 'fields', field.path], field.label, kind, { objectName });
pushAnswerTableColumns(out, base, field, kind, objectName);
}
}
}

/**
* [#34652] Emit `columns.<path>.<column_path>` entries beside `fields` under an
* answer block's root (`…resultDialog` or `…preflight`) — one per labelled
* column of a `format: 'table'` field. Both levels are keyed by the LITERAL
* path (`"error.message"` is one segment), the address
* `ActionResultDialogTranslationSchema.columns` declares and
* `resolveActionResultDialog` / `resolveActionPreflight` read. A column with
* no `label` draws its `path` as the header and gets no key, as a field row
* with no `label` gets none; the format is not re-judged here — a `columns`
* list beside any other format is refused at parse.
*/
function pushAnswerTableColumns(
out: ExpectedEntry[],
blockRoot: string[],
field: any,
kind: ExpectedEntry['source'],
objectName?: string,
): void {
if (!Array.isArray(field.columns)) return;
for (const column of field.columns) {
if (!column || typeof column !== 'object') continue;
if (typeof column.path !== 'string' || column.path.length === 0) continue;
pushEntry(out, [...blockRoot, 'columns', field.path, column.path], column.label, kind, { objectName });
}
}

/**
* Emit `preflight.fields.<path>` entries under an action's translation root —
* one per field the action's `preflight.fields[]` declares, keyed by the
Expand All @@ -840,6 +871,7 @@ function pushActionPreflight(
if (!field || typeof field !== 'object') continue;
if (typeof field.path !== 'string' || field.path.length === 0) continue;
pushEntry(out, [...actionRoot, 'preflight', 'fields', field.path], field.label, kind, { objectName });
pushAnswerTableColumns(out, [...actionRoot, 'preflight'], field, kind, objectName);
}
}

Expand Down
Loading
Loading