Skip to content

DataViews: declare Status field elements + sort on status key#26

Merged
pierorocca merged 1 commit into
mainfrom
feat/dataviews-status-elements
Apr 19, 2026
Merged

DataViews: declare Status field elements + sort on status key#26
pierorocca merged 1 commit into
mainfrom
feat/dataviews-status-elements

Conversation

@pierorocca
Copy link
Copy Markdown
Collaborator

Summary

Small hygiene pass on the Recent AI Orders table's Status column. Zero visual change, two concrete improvements:

  1. Declare the status field's elements — the closed enum of valid WC statuses (processing, completed, on-hold, pending, cancelled, refunded, failed). DataViews treats element-typed fields as first-class: future filter UI auto-populates a dropdown from this list, and the enum is documented at the field definition site rather than hidden in the StatusPill color map.
  2. Sort on the status key, not the label. Stable across locales — an English store and a French store produce the same sort sequence on the Status column click. Display label unchanged.

Translation strategy

Labels use the woocommerce text domain so they inherit WC core's own translations. A merchant on a translated store sees the same "En cours" / "処理中" that appears on the native Orders list — no duplicate translation work. PHPCS WordPress.WP.I18n.TextDomainMismatch suppressed per-line because this is deliberate cross-plugin label sharing (standard pattern for plugins integrating with WC's data model).

Test plan

  • 42 Jest tests pass
  • 379 PHPUnit / 1075 assertions pass
  • ESLint clean (with targeted phpcs:ignore for the text-domain mismatches, if that had a JS equivalent it'd be here)
  • Build + postbuild clean, .pot regenerated
  • Manual: clicking "Status" column header on the Overview tab sorts by the key (you'll see the same order an English, French, or Japanese merchant would see)

Ships as

Merged to main, not tagged. Queues behind the next release signal — now 6 PRs past v1.6.7.

🤖 Generated with Claude Code

Small hygiene pass on the Recent AI Orders table's Status column.
Zero visual change, two concrete improvements:

1. Declare the status field's `elements` — the closed enum of valid
   WC order statuses (processing, completed, on-hold, pending,
   cancelled, refunded, failed). DataViews treats element-typed
   fields as first-class: future filter UI would auto-populate a
   dropdown from this list instead of requiring a manual filter
   component, and the declaration documents the valid value set
   at the field definition site rather than in the StatusPill
   component's color map.

2. Sort on the status key (`item.status`) rather than the localized
   label. Makes the sort stable across locales — an English store
   and a French store produce the same sort sequence on the Status
   column click, because the underlying key doesn't change with
   translation. The display label stays the same.

Labels use the `woocommerce` text domain so they inherit WC core's
own translations. A merchant running a translated store sees the
same "En cours" / "処理中" / etc. that appears on the native Orders
list — no duplicate translation work. PHPCS
`WordPress.WP.I18n.TextDomainMismatch` is suppressed per-line
because this is deliberate cross-plugin label sharing, standard
pattern for plugins integrating with WC's data model.

Part of the DataViews migration series; see AGENTS.md "Styling"
for the adoption recipe this builds on.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pierorocca pierorocca merged commit f6e4cfa into main Apr 19, 2026
7 checks passed
@pierorocca pierorocca deleted the feat/dataviews-status-elements branch April 19, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant