-
Notifications
You must be signed in to change notification settings - Fork 297
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
Add JS entry-point for WordPress editor #9957
Comments
@ankitrox Thank you for drafting the IB. Please take a look at my comments below:
I don't think installing the packages is required at this point, as we'll not be using them yet. They can be installed as needed as part of the respective issues. As part of this issue, we should only ensure that the entry point is built, enqueued, and is able to execute scripts in the WordPress block editor.
The packages don't need to be added to
I think it is crucial to mention that it should use
The entry point should have nothing at this point except the header comments, to be fair. No plugin should be registered at this point.
This should only be done when the
Instead, it should be tested within the test suite for the PHP class that the script is enqueued when the feature flag is enabled. Please let me know if you have any questions, thank you! |
Thank you for reviewing the IB @nfmohit. I understood that the main concern is to just build the script without any actual implementation in it, so I updated the IB accordingly as per your suggestions. |
IB ✅ |
QA Update ✅
|
Feature Description
As part of RRM Phase 2, the WordPress post editor will allow users to override the snippet configuration at the post level. To facilitate this, a new JavaScript entry point should be added to Site Kit and enqueued to the WordPress editor.
The new JavaScript entry point, say
googlesitekit-reader-revenue-manager-block-editor.js
should be enqueued inModules\Reader_Revenue_Manager::setup_assets
, but with aload_contexts
value of an array containingAsset::CONTEXT_ADMIN_POST_EDITOR
so that the JavaScript file is only enqueued in the WordPress editor.A PoC has already implemented this largely which can be used as a starting point.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
rrmModuleV2
feature flag is enabled.Implementation Brief
Note: Please refer to this POC branch as a starting point to this PR.
In
webpack/common.js
, exportgutenbergExternals
after the following forEach loop is done mutating the object.Create a new file
blockEditor.config.js
in webpack directory. Define a new entry pointgooglesitekit-reader-revenue-manager-block-editor
which points to'./assets/js/googlesitekit-reader-revenue-manager-block-editor.js'
as shown in the PR. It should also use the webpack plugins as shown in POC.gutenbergExternals
as externals of the entry point.In
webpack.config.js
, require and yield theblockEditorConfig
.Create a new file
assets/js/googlesitekit-reader-revenue-manager-block-editor.js
In
includes/Modules/Reader_Revenue_Manager.php
rrmModuleV2
is enabled usingFeature_Flags::enabled( 'rrmModuleV2' )
.setup_assets
method, enquque a new scriptgooglesitekit-reader-revenue-manager-block-editor.js
with the dependencies as shown in POC and alsoload_contexts
set toAsset::CONTEXT_ADMIN_POST_EDITOR
so that the JavaScript file is only enqueued in the WordPress editor.Test Coverage
Test that the script is getting enqueued when the
rrmModuleV2
feature flag is enabled.QA Brief
Go to edit post screen in WordPress admin. Check in browser's network tab that there should be a request for
assets/js/googlesitekit-reader-revenue-manager-block-editor.js
file.Changelog entry
The text was updated successfully, but these errors were encountered: