Repository navigation
Premium Analytics: drop the widget modules that carry nothing live - #53833
Conversation
jpa/toggle-group takes jpa/<name> icons; drops the chart-line copies
mirrors gutenberg#82485; an element keeps its icon reference
…type-attribute-json # Conflicts: # projects/packages/premium-analytics/docs/dashboard-widgets.md
the module keeps only what JSON cannot carry; CHART_TYPE_ELEMENTS goes
the manifest orders the settings; a module-only one is listed by id
…-attributes-registry Co-authored-by: louwie17 <lourensschep@gmail.com>
mirrors gutenberg#82485; an element keeps its icon reference
…-attributes-registry Co-authored-by: louwie17 <lourensschep@gmail.com>
…-type-attribute-json
…stry' into update/chart-type-attribute-json Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # projects/packages/premium-analytics/docs/dashboard-widgets.md
…tribute-json Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # projects/packages/premium-analytics/docs/dashboard-widgets.md
…icon-references Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # projects/packages/premium-analytics/docs/dashboard-widgets.md
the icon-reference form ships with the field alone; widgets move to widget.json in the follow-up, and the contract takes 1.15.0 after the registry landed at 1.14.0
…e-attribute-json # Conflicts: # projects/packages/ads/widgets/wordads-chart-tabs/widget.ts # projects/packages/premium-analytics/docs/dashboard-widgets.md # projects/packages/premium-analytics/packages/widgets-toolkit/src/helpers/chart-display-attribute-fields.ts # projects/packages/woocommerce-stats/widgets/average-items-per-order/widget.ts # projects/packages/woocommerce-stats/widgets/average-order-value/widget.ts # projects/packages/woocommerce-stats/widgets/bookings-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/gross-sales-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/net-sales-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/orders-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/total-sales-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/visitors-over-time/widget.ts
…type-attribute-json # Conflicts: # projects/packages/premium-analytics/packages/fields/src/field-toggle-group/__tests__/toggle-group-field.test.tsx # projects/packages/premium-analytics/packages/fields/src/field-toggle-group/stories/toggle-group-field.stories.tsx
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
…-widgets # Conflicts: # projects/packages/premium-analytics/widgets/stories/create-story-widget-type.ts # projects/packages/woocommerce-stats/widgets/average-items-per-order/widget.ts # projects/packages/woocommerce-stats/widgets/average-order-value/widget.ts # projects/packages/woocommerce-stats/widgets/bookings-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/gross-sales-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/net-sales-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/orders-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/total-sales-over-time/widget.ts # projects/packages/woocommerce-stats/widgets/visitors-over-time/widget.ts
louwie17
left a comment
There was a problem hiding this comment.
Thanks @retrofox, this tested well and code looks good! I checked all the tabs and the inserter on my local Docker site, plus the line/bar toggle on the Woo chart widgets, and everything rendered the same as before.
I did leave two small inline comments on the docs, neither is a blocker and both can be a quick fix before merging or a follow up. LGTM 🚀
| but it must not re-declare the widget's own attributes. A widget with no own attributes | ||
| The widget's own attribute shape is declared and exported once: in `widget.ts` when the widget | ||
| has one, alongside the `attributes`/`example` schema it describes, and imported by `render.tsx`; | ||
| otherwise in `render.tsx` itself, where stories and tests import it. `render.tsx` may compose a |
There was a problem hiding this comment.
A small nitpick, none of the stories or tests import these types right now, they all only import the default component. Maybe we can drop the "where stories and tests import it" part, or drop the export on the types until something needs them?
Co-authored-by: louwie17 <lourensschep@gmail.com>
Part of WOOA7S-2174 (task D4).
Builds on #53778, now on trunk.
Proposed changes
Fifty-seven widgets ship without a
widget.tsTheir module exported
{}, orattributes: []with an emptyexample, which is what the dashboard builds from the record alone:useWidgetTypeshas a branch for a record withoutwidget_module, wp-build marks the folderhas_widget: false, the generated manifest leaveswidget_modulenull, and the i18n lane skips the metadata bundle while still installing the render catalog.Twenty-nine Premium Analytics widgets and twenty-eight WooCommerce Stats widgets lose their module. The 23 that keep one carry either attribute behavior JSON cannot express (computed elements or values, a helper-built field) or an
example, which the build does not read fromwidget.jsonyet. Their static attributes move towidget.jsonin a follow-up.The attribute type moves into
render.tsxrender.tsximported the widget's own shape from the module and composed the render-only type over it. Without a module, the shape is declared, and exported, inrender.tsx, where stories and tests import it. All-time stats takes its metrics table along; the render catalog is installed before the module imports, so the labels translate as before.Stories pass the manifest alone
createStoryWidgetType()takes the module as an optional second argument; the 28 stories of widgets without one drop the import. The all-time stats suite loses the test that asserted the module's empty attribute list.Docs
.agents/rules/widgets.mdandAGENTS.mdstate the split: an attribute is declared inwidget.jsonwhenever its field is static, andwidget.tscarries only what JSON cannot express, plusexampleuntil it can move too. They describewidget.tsas optional and say where the attribute type lives in each case.Not in this PR: the 18 modules whose
exampleseeds inserted instances (chartType: 'bar',metric: 'opens', …) stay untilexamplecan be declared inwidget.json.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Build with dependencies
GET /wp-json/wpcom/v2/widget-modulesThe 57 records carry
widget_module: nulland keep theirattributes,titleandicon.On the dashboard
Every section renders as before, and the inserter offers the same widgets with the same titles and icons. The WooCommerce chart widgets keep their line/bar toggle, whose attribute lives in
widget.json.Storybook
The
WidgetDashboardWithWidgetstory of a widget without a module (Tags, Referrers, Total views, …) renders the widget inside the dashboard.Tests
pnpm run test --testPathPatterns=tests/groups/widgets-inprojects/packages/premium-analytics, andpnpm run testinprojects/packages/woocommerce-stats.