Repository navigation
Premium Analytics: register widget-modules entity in the init module #50048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Significance: patch | ||
| Type: changed | ||
| Comment: Internal refactor: register the dashboard entities in the init module instead of on each route load. No user-facing change. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,17 @@ | ||
| export const statsProxyPath = '/jetpack-premium-analytics/v1/proxy'; | ||
|
|
||
| /** | ||
| * Identifier of the Premium Analytics dashboard, formatted as | ||
| * `<plugin>_<page>` to mirror the underscore form produced by the | ||
| * wp-build pipeline. Used as the `{name}` segment of the default-layout | ||
| * REST route. | ||
| * | ||
| * Must match `DASHBOARD_NAME` in `src/dashboard-layout.php`. | ||
| */ | ||
| export const DASHBOARD_NAME = 'jetpack-premium-analytics_dashboard'; | ||
|
|
||
| /** | ||
| * REST namespace that exposes Premium Analytics dashboard endpoints. | ||
| * Must match `DASHBOARD_REST_NAMESPACE` in `src/rest-namespace.php`. | ||
| */ | ||
| export const DASHBOARD_REST_NAMESPACE = 'wpcom/v2'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| */ | ||
| import { getScriptData } from '@automattic/jetpack-script-data'; | ||
| import { loadI18nCatalogs } from '@automattic/jetpack-wp-build-polyfills/src/js/load-i18n-catalogs'; | ||
| import { ensureDashboardEntities } from '@jetpack-premium-analytics/data'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small one: importing from the data barrel makes the whole |
||
| import apiFetch from '@wordpress/api-fetch'; | ||
| import { store as bootStore } from '@wordpress/boot'; | ||
| import { dispatch } from '@wordpress/data'; | ||
|
|
@@ -58,4 +59,7 @@ export async function init(): Promise< void > { | |
| } ); | ||
|
|
||
| await catalogs; | ||
|
|
||
| // After the catalogs: the entity labels are built with `__()` at call time. | ||
| ensureDashboardEntities(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still no test on this path - it's now the only place the entities get registered, and the "after Also just wondering - as far as I can tell nothing in the app reads the entity |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,12 @@ | ||
| /** | ||
| * Identifiers shared by the dashboard hooks and mirrored on the server. | ||
| * Preferences identifiers shared by the dashboard hooks and mirrored on the | ||
| * server. | ||
| * | ||
| * Centralized so the preferences scope, keys, dashboard name, and REST | ||
| * namespace can be renamed in one place — e.g. to fully isolate Premium | ||
| * Analytics' stored preferences from the core dashboard's. The values | ||
| * here must match the constants in `src/dashboard-layout.php`. | ||
| * Centralized so the preferences scope and keys can be renamed in one place — | ||
| * e.g. to fully isolate Premium Analytics' stored preferences from the core | ||
| * dashboard's. | ||
| */ | ||
|
|
||
| /** | ||
| * Identifier of the Premium Analytics dashboard, formatted as | ||
| * `<plugin>_<page>` to mirror the underscore form produced by the | ||
| * wp-build pipeline. Used as the `{name}` segment of the default-layout | ||
| * REST route. | ||
| */ | ||
| export const DASHBOARD_NAME = 'jetpack-premium-analytics_dashboard'; | ||
|
|
||
| /** | ||
| * Preferences scope under which the dashboard layout and grid settings | ||
| * are stored. Mirrors the scope the server-side default injection writes | ||
|
|
@@ -25,8 +17,5 @@ export const DASHBOARD_PREFERENCES_SCOPE = 'jetpack-premium-analytics/dashboard' | |
| /** Preferences key holding the dashboard grid settings. */ | ||
| export const DASHBOARD_GRID_SETTINGS_KEY = 'dashboardGridSettings'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heads up - trunk moved under this after the rebase: #51948 added Also while you're in here, the header above still says these must match |
||
|
|
||
| /** REST namespace that exposes Premium Analytics dashboard endpoints. */ | ||
| export const DASHBOARD_REST_NAMESPACE = 'wpcom/v2'; | ||
|
|
||
| /** Preferences key holding when the reader completed or dismissed the onboarding, as an ISO date. */ | ||
| export const DASHBOARD_ONBOARDING_KEY = 'onboardingCompletedAt'; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DASHBOARD_REST_NAMESPACEbelow kept its PHP pointer but this one lost thesrc/dashboard-layout.phpone it had in the old header, and a rename on either side would just 404 the sections entity quietly.