Create New Ads Module Datastore Partial for Plugin Detection Selectors #10170
Labels
javascript
Pull requests that update Javascript code
Module: Ads
Google Ads module related issues
Team S
Issues for Squad 1
Type: Enhancement
Improvement of an existing feature
Feature Description
With the integration of plugin detection logic and surfacing said data in the Ads module inline/base data (see #10169), an extension of the existing Ads module
moduleData.js
datastore partial is required, with the addition of specific selectors that return responses based on the shape of said newly addedplugins
Ads module base/inline data. This update should also include theplugins
object in the initial state.In addition to this, a new datastore partial (say
woocommerce.js
) should also be created to hold specific selectors relative to whether the modal should be shown or not, and to retrieve the WooCommerce redirect URI based on the current scenario (which will use selectors form the extension tomoduleData,.js
). This datastore partial will not maintain any state, and will merely make use of the selectors from the above datastore extension, as well as navigation selectors from the CORE_SITE store, such asgetAdminURL()
.The following selectors (and their accompanying logic patterns) should be added to the existing
moduleData.js
partial:isWooCommerceInstalled()
isWooCommerceActive()
isGoogleForWooCommerceInstalled()
isGoogleForWooCommerceActive()
hasGoogleForWooCommerceAdsAccount()
The following selectors (and their accompanying logic patterns) should be added to the new
woocommerce.js
partial:shouldShowWooCommerceRedirectModal()
getGoogleForWooCommerceRedirectURI()
getAdminURL()
selector from theCORE_SITE
datastore.For more information, see the Datastore Setup sub heading of the design document.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
_googlesitekitModulesData
(added in Add Plugin Detection Logic to Ads Module Backend Infrastructure #10169) and combine the returned values:assets/js/modules/ads/datastore/moduleData.js
datastore file to use kebab case -assets/js/modules/ads/datastore/module-data.js
Implementation Brief
EDIT: Since we will need this data before Ads module is active/connected, we moved the selectors to the core site datastore
Within the existingmoduleData.js
datastore partial atassets/js/modules/ads/datastore/moduleData.js
:assets/js/googlesitekit/datastore/site/info.js
Rename the file tomodule-data.js
and update it's references in other files where used[ ] Update theinitialState
const to include thewoocommerce
andgoogle-listings-and-ads
objects from base data, default toundefined
RECEIVE_MODULE_DATA
in the reducer to extract and pass new objects (woocommerce
andgoogle-listings-and-ads
)getWooCommercePluginStatus
andgetGoogleForWooCommercePluginStatus
selectors, similar to how other selectors are added, invokegetSiteInfoProperty
function and passwoocommerce
andgoogle-listings-and-ads
respectively as argumentsassets/js/modules/ads/datastore/woocommerce.js
assets/js/googlesitekit/datastore/site/plugin-status.js
. Add following selectors:isWooCommerceActive
, which returns the boolean value of theactive
property obtained fromgetWooCommercePluginStatus
selectorisGoogleForWooCommercePresent
which returns boolean value frominstalled
property ofgetGoogleForWooCommercePluginStatus
selector valueisGoogleForWooCommerceActive
, which checks boolean value ofactive
property returned from same selector as aboveisGoogleForWooCommerceAdsAccountLinked
, which checks boolean value ofadsConnected
property from same selector as previously usedshouldShowWooCommerceRedirectModal
isWooCommerceActive
,isGoogleForWooCommerceActive
andisGoogleForWooCommerceAdsAccountLinked
selectors and stores the results against applicable constants.isWooCommerceActive
istrue
but the result ofisGoogleForWooCommerceActive
isfalse
isWooCommerceActive
istrue
and the result ofisGoogleForWooCommerceActive
istrue
, but the result ofisGoogleForWooCommerceAdsAccountLinked
isfalse
false
otherwisegetGoogleForWooCommerceRedirectURI
select(CORE_SITE).getAdminURL()
and references said valueisWooCommerceActive
istrue
but the result ofisGoogleForWooCommerceActive
isfalse
:${ adminURL }/plugin-install.php?s=google-listings-and-ads&tab=search&type=term
isWooCommerceActive
istrue
and the result ofisGoogleForWooCommerceActive
istrue
, but the result ofisGoogleForWooCommerceAdsAccountLinked
isfalse
:${ adminURL }/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard
isWooCommerceActive
istrue
, the result ofisGoogleForWooCommerceActive
is alsotrue
, and the result ofisGoogleForWooCommerceAdsAccountLinked
istrue
:${ adminURL }/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard
Test Coverage
assets/js/modules/ads/datastore/moduleData.test.js
assets/js/googlesitekit/datastore/site/info.test.js
and add tests cases for the newly added selectors, updating the mocked base data assigned to thebaseData
const.assets/js/modules/ads/datastore/woocommerce.test.js
assets/js/googlesitekit/datastore/site/plugin-status.test.js
that tests the new selectors.QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: