Skip to content

Commit 3ae001f

Browse files
committed
fix(spec): the destructive-to-danger conversion renames action:bar variants too, and member guidance says danger
action:bar has no props row, but it draws each `actions` / `systemActions` member through the block renderers, which no longer read `destructive`, so a stored bar written that way fell back to a plain button with nothing to say so. The conversion now renames the bar's own `variant` and its members'. The container member `className` refusal and the member docblock named `destructive` as the red variant; they say `danger`. Claude-Session: https://claude.ai/code/session_01WGufzeYWDZN6LkXji5ziLF Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2f05526 commit 3ae001f

5 files changed

Lines changed: 83 additions & 20 deletions

File tree

‎.changeset/26779-action-block-variant-danger.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The four block renderers forward `danger` to the runner as it is and draw it as
1515

1616
This replaces the variant sentences of the #26665 entry in this release: the action blocks no longer translate `destructive` to `danger` at their forward to the runner, and `danger` is the spelling they accept (`UIActionSchema.variant` included). That entry's confirm-dialog behaviour is unchanged: a destructive block with a `confirmText` asks through the destructive confirm button, now when it is declared `variant: 'danger'`.
1717

18-
Stored rows and older built artifacts: the ADR-0087 D2 conversion `page-action-block-variant-destructive-to-danger` rewrites `variant: 'destructive'` to `'danger'` on the four blocks' `properties.variant` and on each `action:group` / `action:menu` member's `variant`, at every position a page nests a component (regions, slots, nested containers). A stored `page` row is rewritten when it is rehydrated, so it keeps drawing the destructive button and confirming through the destructive confirm button. The conversion is retired from the load path, so a source that still writes `destructive` on a block is refused, not rewritten. The D3 entry `ui-page-action-block-variant-destructive-refused` carries the judgment for `os migrate meta`.
18+
Stored rows and older built artifacts: the ADR-0087 D2 conversion `page-action-block-variant-destructive-to-danger` rewrites `variant: 'destructive'` to `'danger'` on the four blocks' `properties.variant` and on each `action:group` / `action:menu` member's `variant`, at every position a page nests a component (regions, slots, nested containers). It renames an `action:bar`'s own `variant` and the `variant` of each `actions` / `systemActions` member as well. The bar has no props row, so nothing refuses `destructive` on it, but it draws each member through the block renderers, which no longer read that word. A stored `page` row is rewritten when it is rehydrated, so it keeps drawing the destructive button and confirming through the destructive confirm button. The conversion is retired from the load path, so a source that still writes `destructive` on a block is refused, not rewritten. The D3 entry `ui-page-action-block-variant-destructive-refused` carries the judgment for `os migrate meta`.
1919

2020
Clause-②: no (narrowing) — the action block rows refuse `destructive`, a value they used to accept. `danger` takes its place on the same rows.
2121

‎packages/spec/src/conversions/page-action-block-variant-destructive-to-danger.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import type { ConversionNotice } from './types.js';
3131
* - the stored-row seam REWRITES `destructive` to `danger` on every row
3232
* shape, and the result parses against the row that now refuses it;
3333
* - the authoring funnel does NOT replay it;
34+
* - the same seam renames an `action:bar`'s own `variant` and its members',
35+
* though the bar has no row: it draws its members through the blocks;
3436
* - another component's `destructive` (the Button primitive's own word) and
3537
* every other variant are left byte-identical with no notice;
3638
* - idempotence, and copy-on-write identity for a page with nothing to do.
@@ -145,13 +147,41 @@ describe('page-action-block-variant-destructive-to-danger (ADR-0087 D2)', () =>
145147
expect(notices.map((n) => [n.from, n.to, n.path])).toEqual([['destructive', 'danger', `${AT}.actions[1].variant`]]);
146148
});
147149

150+
it('the stored-row seam rewrites an `action:bar`\'s own `variant` and its `actions` / `systemActions` members\'', () => {
151+
const props = {
152+
variant: 'destructive',
153+
actions: [
154+
{ name: 'copy', label: 'Copy', type: 'script', variant: 'ghost' },
155+
{ name: 'purge', label: 'Purge', type: 'script', variant: 'destructive' },
156+
],
157+
systemActions: [{ name: 'sys_delete', label: 'Delete', type: 'script', variant: 'destructive' }],
158+
};
159+
const { out, notices } = replayStored(pageWith({ type: 'action:bar', properties: props }));
160+
const block = blockOf(out);
161+
expect(block.properties).toEqual({
162+
variant: 'danger',
163+
actions: [
164+
{ name: 'copy', label: 'Copy', type: 'script', variant: 'ghost' },
165+
{ name: 'purge', label: 'Purge', type: 'script', variant: 'danger' },
166+
],
167+
systemActions: [{ name: 'sys_delete', label: 'Delete', type: 'script', variant: 'danger' }],
168+
});
169+
expect((block.properties as { actions: unknown[] }).actions[0]).toBe(props.actions[0]);
170+
expect(notices.map((n) => [n.from, n.to, n.path])).toEqual([
171+
['destructive', 'danger', `${AT}.variant`],
172+
['destructive', 'danger', `${AT}.actions[1].variant`],
173+
['destructive', 'danger', `${AT}.systemActions[0].variant`],
174+
]);
175+
});
176+
148177
it.each([
149178
['the canonical `danger`', { type: 'action:button', properties: { label: 'Purge', variant: 'danger' } }],
150179
['another variant', { type: 'action:icon', properties: { icon: 'copy', variant: 'outline' } }],
151180
["an `element:button`'s `destructive` (the Button primitive's own word)", { type: 'element:button', properties: { label: 'Reset', variant: 'destructive' } }],
152181
["a `destructive` member on a block that has no members", { type: 'action:button', properties: { label: 'Go', actions: [{ variant: 'destructive' }] } }],
153182
['a member that is not an object', { type: 'action:menu', properties: { actions: ['destructive'] } }],
154183
['`actions` that is not a list', { type: 'action:group', properties: { actions: { variant: 'destructive' } } }],
184+
["a `systemActions` list on a block that has no such list", { type: 'action:menu', properties: { systemActions: [{ variant: 'destructive' }] } }],
155185
])('control: %s is left as stored, with no notice', (_label, component) => {
156186
const page = pageWith(component);
157187
const { out, notices } = replayStored(page);

‎packages/spec/src/conversions/registry.ts‎

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10863,11 +10863,18 @@ const ACTION_CONTAINER_BLOCK_TYPES = new Set(['action:group', 'action:menu']);
1086310863
* artifact door and `os migrate meta --write`, which is why the block
1086410864
* renderers forward `danger` directly and keep no `destructive` bridge.
1086510865
*
10866-
* Five surfaces, all value renames and nothing else: `properties.variant` on
10866+
* Its surfaces are value renames and nothing else: `properties.variant` on
1086710867
* each of the four block nodes (the containers' own value is their trigger's),
1086810868
* and `variant` on each `action:group` / `action:menu` member of
10869-
* `properties.actions`. Every other value is left alone, and so is every other
10870-
* component type: `destructive` stays the Button primitive's word on
10869+
* `properties.actions`. `action:bar` is visited too, though it has no row
10870+
* here: the bar spreads each member of `properties.actions` and
10871+
* `properties.systemActions` onto an `action:button` (or folds it into its
10872+
* `action:menu`) with `variant: member.variant || properties.variant`, so a
10873+
* stored bar written `destructive` reaches the block renderers, which no
10874+
* longer read that word, and would fall back to a plain button with no
10875+
* refusal anywhere to say so. Its own `variant` and its members' are renamed
10876+
* as the four blocks' are. Every other value is left alone, and so is every
10877+
* other component type: `destructive` stays the Button primitive's word on
1087110878
* `element:button` and the other primitive-backed components, which this
1087210879
* entry never reads. A member that is not an object, or a list that is not an
1087310880
* array, is left as stored. The reach is every position `mapPageComponents`
@@ -10887,7 +10894,9 @@ const pageActionBlockVariantDestructiveToDanger: MetadataConversion = {
1088710894
retiredAfter: '18.2.0',
1088810895
surface: 'page.component.action:button.variant / page.component.action:icon.variant / '
1088910896
+ 'page.component.action:group.variant / page.component.action:menu.variant / '
10890-
+ 'page.component.action:group.actions[].variant / page.component.action:menu.actions[].variant',
10897+
+ 'page.component.action:group.actions[].variant / page.component.action:menu.actions[].variant / '
10898+
+ 'page.component.action:bar.variant / page.component.action:bar.actions[].variant / '
10899+
+ 'page.component.action:bar.systemActions[].variant',
1089110900
summary:
1089210901
"action block variant 'destructive' → 'danger' — the spelling ActionSchema.variant and the action runner "
1089310902
+ 'use; on a block both draw the destructive button and confirm through the destructive confirm button, '
@@ -10896,25 +10905,30 @@ const pageActionBlockVariantDestructiveToDanger: MetadataConversion = {
1089610905
return mapPageComponents(stack, (component, path) => {
1089710906
const type = component.type;
1089810907
if (typeof type !== 'string') return component;
10899-
const isContainer = ACTION_CONTAINER_BLOCK_TYPES.has(type);
10900-
if (!isContainer && !ACTION_RUNNER_BLOCK_TYPES.has(type)) return component;
10908+
const memberLists = ACTION_CONTAINER_BLOCK_TYPES.has(type)
10909+
? ['actions'] as const
10910+
: type === 'action:bar'
10911+
? ['actions', 'systemActions'] as const
10912+
: ACTION_RUNNER_BLOCK_TYPES.has(type) ? [] as const : undefined;
10913+
if (!memberLists) return component;
1090110914
const properties = component.properties;
1090210915
if (!isDict(properties)) return component;
1090310916
let next = properties;
1090410917
if (properties.variant === 'destructive') {
1090510918
emit({ from: 'destructive', to: 'danger', path: `${path}.properties.variant` });
1090610919
next = { ...next, variant: 'danger' };
1090710920
}
10908-
const actions = properties.actions;
10909-
if (isContainer && Array.isArray(actions)) {
10921+
for (const key of memberLists) {
10922+
const members = properties[key];
10923+
if (!Array.isArray(members)) continue;
1091010924
let changed = false;
10911-
const nextActions = actions.map((member, i) => {
10925+
const nextMembers = members.map((member, i) => {
1091210926
if (!isDict(member) || member.variant !== 'destructive') return member;
1091310927
changed = true;
10914-
emit({ from: 'destructive', to: 'danger', path: `${path}.properties.actions[${i}].variant` });
10928+
emit({ from: 'destructive', to: 'danger', path: `${path}.properties.${key}[${i}].variant` });
1091510929
return { ...member, variant: 'danger' };
1091610930
});
10917-
if (changed) next = { ...next, actions: nextActions };
10931+
if (changed) next = { ...next, [key]: nextMembers };
1091810932
}
1091910933
return next === properties ? component : { ...component, properties: next };
1092010934
});
@@ -10960,6 +10974,14 @@ const pageActionBlockVariantDestructiveToDanger: MetadataConversion = {
1096010974
],
1096110975
},
1096210976
},
10977+
// A bar: no row of its own, but its members reach the block renderers.
10978+
{
10979+
type: 'action:bar',
10980+
properties: {
10981+
actions: [{ name: 'purge', label: 'Purge', type: 'script', variant: 'destructive' }],
10982+
systemActions: [{ name: 'sys_delete', label: 'Delete', type: 'script', variant: 'destructive' }],
10983+
},
10984+
},
1096310985
],
1096410986
},
1096510987
],
@@ -11010,6 +11032,13 @@ const pageActionBlockVariantDestructiveToDanger: MetadataConversion = {
1101011032
],
1101111033
},
1101211034
},
11035+
{
11036+
type: 'action:bar',
11037+
properties: {
11038+
actions: [{ name: 'purge', label: 'Purge', type: 'script', variant: 'danger' }],
11039+
systemActions: [{ name: 'sys_delete', label: 'Delete', type: 'script', variant: 'danger' }],
11040+
},
11041+
},
1101311042
],
1101411043
},
1101511044
],
@@ -11025,8 +11054,8 @@ const pageActionBlockVariantDestructiveToDanger: MetadataConversion = {
1102511054
],
1102611055
},
1102711056
// The button, the icon, the group's trigger, the group member, the nested
11028-
// menu member and the slotted header icon.
11029-
expectedNotices: 6,
11057+
// menu member, the bar's two members and the slotted header icon.
11058+
expectedNotices: 8,
1103011059
},
1103111060
};
1103211061

‎packages/spec/src/migrations/entries/semantic/18.ui-page-action-block-variant-destructive-refused.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const entry: SemanticMigration = {
77
// No backticks in `surface` — build-upgrade-guide.ts renders it inside a
88
// code span already, and a nested backtick would close it.
99
surface: "variant: 'destructive' on an action block: an action:button, action:icon, action:group or action:menu "
10-
+ 'node, or an action:group / action:menu member',
10+
+ 'node, an action:group / action:menu member, or an action:bar node or member',
1111
replacement: "`variant: 'danger'`, the spelling `ActionSchema.variant` and the action runner use. The rename is "
1212
+ 'lossless on a block: it draws the same destructive button, and a `confirmText` question asks through the '
1313
+ 'destructive confirm button as before.',
@@ -22,11 +22,15 @@ export const entry: SemanticMigration = {
2222
+ 'component-props gate at the metadata save door; `os validate` reports the old value as a '
2323
+ '`component-props-invalid` finding. The D2 conversion `page-action-block-variant-destructive-to-danger` '
2424
+ 'performs the rename, retired from the load path, so an author meets the refusal while stored rows, built '
25-
+ 'artifacts and `os migrate meta --write` are rewritten.',
25+
+ 'artifacts and `os migrate meta --write` are rewritten. An `action:bar` has no props row, so nothing refuses '
26+
+ "`destructive` on it; the conversion still renames the bar's own `variant` and its `actions` / "
27+
+ "`systemActions` members' `variant`, because the bar draws each member through the block renderers, "
28+
+ 'which no longer read `destructive`.',
2629
acceptanceCriteria:
2730
"No `action:button` / `action:icon` / `action:group` / `action:menu` `properties.variant` and no "
2831
+ "`action:group` / `action:menu` member `variant` reads `'destructive'`; `os validate` reports no "
29-
+ '`component-props-invalid` finding at `properties.variant` or `properties.actions.N.variant`, and each such '
30-
+ 'block still draws the destructive button and confirms through the destructive confirm button.',
32+
+ '`component-props-invalid` finding at `properties.variant` or `properties.actions.N.variant`; no '
33+
+ "`action:bar` `properties.variant` or `actions` / `systemActions` member `variant` reads `'destructive'`; and "
34+
+ 'each such block still draws the destructive button and confirms through the destructive confirm button.',
3135
conversionIds: ['page-action-block-variant-destructive-to-danger'],
3236
};

‎packages/spec/src/ui/component.zod.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,7 +4112,7 @@ export type ActionIconPropsParsed = z.infer<typeof ActionIconPropsSchema>;
41124112
* dropdown item (`DropdownActionItem`) — and in the menu's item
41134113
* (`ActionMenuItem`): `visible` (the shared fail-closed gate), `disabled`,
41144114
* `icon`, `label` falling back to `name`, `variant` (group inline, `primary`
4115-
* drawn as `default`; the dropdown and menu items, where `destructive` draws
4115+
* drawn as `default`; the dropdown and menu items, where `danger` draws
41164116
* the item red) and `tags` (a `separator-before` tag draws a divider above
41174117
* the item);
41184118
* - **`size`**, on an `action:group` member only: its inline button reads it,
@@ -4241,7 +4241,7 @@ const actionContainerMemberGuidance = (container: 'action:group' | 'action:menu'
42414241
+ 'toast as `successMessage`.',
42424242
className:
42434243
'A member is drawn by its container, not as a page component, and carries no `className`. Style it with its '
4244-
+ '`variant` (`destructive` draws it red), or style the whole container with the node\'s own `className`.',
4244+
+ '`variant` (`danger` draws it red), or style the whole container with the node\'s own `className`.',
42454245
properties:
42464246
'A member carries no `properties` bag: its static parameter values (`properties.params`) are not part of the '
42474247
+ 'inline action vocabulary. For a `type: \'api\'` member\'s request body write `bodyExtra`; to run an action '

0 commit comments

Comments
 (0)