Skip to content

Commit 1a32595

Browse files
committed
fix(showcase): the greyed Archive action says why it is unavailable
showcase_archive_task declares a disabledReason (en, plus the zh-CN copy key), so its greyed button reads "Mark the task done first." instead of the console's generic "Not available for this record". Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvWX6aMbbnnsKtDC5k
1 parent 180845d commit 1a32595

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

‎examples/app-showcase/src/system/translations/index.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ export const ShowcaseTranslationBundle = {
543543
showcase_quick_view: { label: '快速查看' },
544544
showcase_log_time: { label: '记录工时' },
545545
showcase_new_task: { label: '新建任务' },
546-
showcase_archive_task: { label: '归档', successMessage: "{{ record.title | default:'任务' }}已归档(演示——未修改任何数据)。" },
546+
showcase_archive_task: {
547+
label: '归档',
548+
successMessage: "{{ record.title | default:'任务' }}已归档(演示——未修改任何数据)。",
549+
disabledReason: '请先将任务标记为完成。',
550+
},
547551
},
548552
// Section headings of the six form-view projections in
549553
// `ui/views/task.view.ts` (edit / tabbed / wizard / split / quick).

‎examples/app-showcase/src/ui/actions/index.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ export const ArchiveTaskAction = defineAction({
496496
// Disabled while the task is not done — visible either way. #8990: `has()`
497497
// for the sparse face; `!=` against a literal cannot fault, so no `!= null`.
498498
disabled: 'has(record.done) && record.done != true',
499+
// What the greyed button says while `disabled` holds: why it is
500+
// unavailable and what unlocks it. Without it the console falls back to
501+
// "Not available for this record", which names neither. Display only; it
502+
// never gates the dispatch.
503+
disabledReason: 'Mark the task done first.',
499504
locations: ['record_header', 'record_section'],
500505
refreshAfter: false,
501506
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The greyed Archive button on a task says why it is unavailable
5+
* (objectstack#27520 row 9).
6+
*
7+
* `showcase_archive_task` is the `disabled`-predicate specimen: it stays on
8+
* screen and is greyed until the task is done. The console draws the action's
9+
* `disabledReason` (`ActionSchema.disabledReason`, #26619) as the button's
10+
* hover title and accessible description, and falls back to "Not available for
11+
* this record" only when the action declares none, which told the user neither
12+
* why nor what to do. So the specimen declares the sentence, in English on the
13+
* action and in zh-CN at `objects.showcase_task._actions.<name>.disabledReason`,
14+
* the copy keys' translation route.
15+
*/
16+
17+
import { describe, expect, it } from 'vitest';
18+
import { ActionSchema } from '@objectstack/spec/ui';
19+
import { ArchiveTaskAction } from '../src/ui/actions/index.js';
20+
import { ShowcaseTranslationBundle } from '../src/system/translations/index.js';
21+
22+
const GENERIC = 'Not available for this record';
23+
24+
describe('showcase_archive_task says why it is greyed (objectstack#27520 row 9)', () => {
25+
it('declares a disabledReason beside its disabled predicate, and the spec keeps it', () => {
26+
const parsed = ActionSchema.parse(ArchiveTaskAction);
27+
// Control: the action is still the `disabled` specimen.
28+
expect(parsed.disabled).toBeTruthy();
29+
expect(typeof parsed.disabledReason).toBe('string');
30+
const reason = String(parsed.disabledReason);
31+
expect(reason.trim()).not.toBe('');
32+
expect(reason).not.toBe(GENERIC);
33+
});
34+
35+
it('carries the zh-CN reason on the copy keys\' translation route', () => {
36+
const zhActions = (ShowcaseTranslationBundle['zh-CN'] as {
37+
objects: Record<string, { _actions?: Record<string, { disabledReason?: unknown }> }>;
38+
}).objects.showcase_task._actions ?? {};
39+
const zh = zhActions.showcase_archive_task?.disabledReason;
40+
expect(typeof zh).toBe('string');
41+
expect(String(zh).trim()).not.toBe('');
42+
expect(zh).not.toBe(ArchiveTaskAction.disabledReason);
43+
});
44+
});

0 commit comments

Comments
 (0)