|
| 1 | +--- |
| 2 | +'@objectstack/spec': minor |
| 3 | +'@objectstack/cli': minor |
| 4 | +'@objectstack/platform-objects': minor |
| 5 | +--- |
| 6 | + |
| 7 | +feat(spec): a greyed action says why — `disabledReason` beside `disabled` |
| 8 | + |
| 9 | +Clause-②: yes (widening) |
| 10 | +Metadata-protocol: added |
| 11 | + |
| 12 | +`ActionSchema` gains one optional key, `disabledReason`: the sentence a greyed action shows to say why it is unavailable, beside the `disabled` predicate that greys it. An action that does not declare it parses exactly as before, and the console keeps its default reason, "Not available for this record". |
| 13 | + |
| 14 | +```ts |
| 15 | +defineAction({ |
| 16 | + name: 'submit_for_approval', |
| 17 | + label: 'Submit for approval', |
| 18 | + objectName: 'clm_contract', |
| 19 | + disabled: "record.legal_review_status != 'approved'", |
| 20 | + disabledReason: 'An approved legal review is required before the contract enters approval.', |
| 21 | +}); |
| 22 | +``` |
| 23 | + |
| 24 | +- **An `I18nLabel`.** A plain string or an inline locale map (`{ en, 'zh-CN' }`). A blank string is refused at parse: `''` or whitespace only. Omit the key to keep the default. The locale-map arm is the `InlineLocaleMapSchema` every `I18nLabel` takes, so a map is not checked for blank values. `disabledMessage`, `disabledTooltip`, `disabledHint` and `disabledText` are renamed onto it. |
| 25 | +- **Translated with the copy keys.** The slot is `objects.OBJECT._actions.ACTION.disabledReason` (`globalActions.ACTION.disabledReason` for an action with no `objectName`), beside `confirmText` and `successMessage`. `translateAction` overlays it, and `os i18n extract` (`@objectstack/cli`) scaffolds it for an action that declares one and seeds nothing for one that does not. |
| 26 | +- **Display only.** It does not change what `disabled` evaluates to and is never read as a condition: `os validate` checks `disabled`, not `disabledReason`. It is not access control either. A call that reaches the server anyway is refused by the action's own rules (its body or hook, `requiredPermissions`), never by this text. |
| 27 | +- **Studio.** The action editor's Placement section gains a "Disabled Reason" row under "Disabled", translated in `@objectstack/platform-objects` for zh-CN, ja-JP and es-ES. |
| 28 | + |
| 29 | +Nothing renders the key yet. The console's greyed-action surfaces (the record header, the record section bar, the declared actions bar and the four `action:*` renderers) read it in the follow-up change. Until then the liveness ledger marks it `planned` with `authorWarn`, so `os validate` warns an author who declares it that nothing shows it yet. |
0 commit comments