diff --git a/.changeset/showcase-action-disabled-specimen.md b/.changeset/showcase-action-disabled-specimen.md new file mode 100644 index 0000000000..cc25565452 --- /dev/null +++ b/.changeset/showcase-action-disabled-specimen.md @@ -0,0 +1,4 @@ +--- +--- + +feat(showcase): add the action `disabled`-predicate specimen (`showcase_archive_task`) — greyed until `record.done`, contrasting `visible` (hide) with `disabled` (grey). Examples-only; releases nothing. diff --git a/examples/app-showcase/src/ui/actions/index.ts b/examples/app-showcase/src/ui/actions/index.ts index f449873fcd..50a6bf4a2e 100644 --- a/examples/app-showcase/src/ui/actions/index.ts +++ b/examples/app-showcase/src/ui/actions/index.ts @@ -235,6 +235,37 @@ export const ActionParamGalleryAction = defineAction({ refreshAfter: false, }); +/** + * script — the `disabled` predicate specimen. Where `visible` HIDES an action + * (see MarkDoneAction), `disabled` keeps it ON SCREEN but greyed until its + * precondition holds: Archive stays visible on every task and only becomes + * clickable once the task is done. Same authoring rules as `visible` + * (`record.`-prefixed, single comparison; disabled when the CEL is TRUE). + * Exercises the renderer-side wiring (objectui: DeclaredActionsBar + + * action:button/group/icon/menu) that #1885's follow-through completed. + */ +export const ArchiveTaskAction = defineAction({ + name: 'showcase_archive_task', + label: 'Archive', + icon: 'archive', + objectName: task, + type: 'script', + body: { + language: 'js', + // No destructive side effect — the specimen's value is the disabled + // behavior itself; echo which record would be archived. + source: + "var id = ctx.recordId || (ctx.record && ctx.record.id) || input.recordId;" + + "return { ok: true, archived: id };", + capabilities: [], + }, + successMessage: 'Task archived (demo — no data changed).', + // Disabled while the task is not done — visible either way. + disabled: 'record.done != true', + locations: ['record_header', 'record_section'], + refreshAfter: false, +}); + export const allActions = [ MarkDoneAction, OpenDocsAction, @@ -245,4 +276,5 @@ export const allActions = [ NewTaskAction, SubmitForSignoffAction, ActionParamGalleryAction, + ArchiveTaskAction, ]; diff --git a/examples/app-showcase/src/ui/pages/task-detail.page.ts b/examples/app-showcase/src/ui/pages/task-detail.page.ts index 4022eae090..81e3e0ae74 100644 --- a/examples/app-showcase/src/ui/pages/task-detail.page.ts +++ b/examples/app-showcase/src/ui/pages/task-detail.page.ts @@ -61,7 +61,10 @@ export const TaskDetailPage = definePage({ properties: { location: 'record_section', align: 'start', - actionNames: ['showcase_mark_done', 'showcase_log_time'], + // showcase_archive_task is the `disabled`-predicate specimen: + // visible on every task, greyed until `record.done` (contrast with + // showcase_mark_done's `visible`, which HIDES once done). + actionNames: ['showcase_mark_done', 'showcase_log_time', 'showcase_archive_task'], }, }, {