-
Notifications
You must be signed in to change notification settings - Fork 315
Description
Feature Description
stores created by createModuleStore
should include new selectors for module-specific admin URLs. These can be built on top of the enhanced version of getAdminURL
from the core/site
store, which was implemented as part of #1500.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
core/user/data/authentication
REST route should also returnneedsReauthentication
, which usesAuthentication::need_reauthenticate()
(will be migrated toOAuth_Client
class via Request write scopes only when needed #1566, just fyi - depending on timeline this may overlap). - The
core/user
store should receive an additional selectorneedsReauthentication()
that exposes the above. createModuleStore
should receive a newoptions
argumentadminPage
. The default should be "googlesitekit-dashboard". Modules with their own screens (Search Console, Analytics, AdSense) need to be amended so that they provide the slugs for their own screens when callingcreateModuleStore
.createModuleStore
should receive a newoptions
argumentrequiresSetup
. The default should be a booleantrue
. Modules that do not require setup (only PageSpeed Insights for now) need to be amended so that they providefalse
for this argument.- Store objects returned by
createModuleStore
should have two additional selectors:getAdminScreenURL( queryArgs )
: Should usegetAdminURL
fromcore/site
passingadminPage
as the selector'spage
parameter, andqueryArgs
can be passed through.getAdminReauthURL()
: Should mirror the exact behavior of the legacygetReAuthURL
utility function, based ongetAdminScreenURL
, whether the modulerequiresSetup
, and whether the user needs to re-authenticate (requested scopes and granted scopes are available viacore/user
score, let's introduce a new selector to simplify this check, see below).
- Refactored module code based on the datastore that currently still relies on one of the old utility functions (e.g.
getReAuthURL
, used at least by refactored AdSense code) should be modified to use the new selectors.
Implementation Brief
-
Update the
core/user/data/authentication
REST endpoint inincludes/Core/Authentication/Authentication.php
to also returnneedsReauthentication
which will get its value from theOAuth_Client::needs_reauthentication()
function. -
Add
needsReauthentication()
selector toassets/js/googlesitekit/datastore/user/authentication.js
which connects to the needsReauthentication value returned from the above endpoint. -
Add these arguments to
options
increateModuleStore()
inassets/js/googlesitekit/modules/create-module-store.js
adminPage
(string) default value ofgooglesitekit-dashboard
requiresSetup
(boolean) default value oftrue
-
For modules with their own screens, add the
adminPage
argument with the appropriate page name (ie:googlesitekit-module-analytics
for the analytics module) whencreateModuleStore()
is called for them.assets/js/modules/search-console/datastore/index.js
assets/js/modules/analytics/datastore/index.js
assets/js/modules/adsense/datastore/index.js
-
For PageSpeed Insights module, pass
false
as theoptions.requiresSetup
argument forcreateModuleStore()
atassets/js/modules/pagespeed-insights/datastore/index.js
-
Create a new file
assets/js/googlesitekit/modules/datastore/info.js
that creates a store with selectors forgetAdminScreenURL()
andgetAdminReauthURL()
which will usegetAdminURL()
from thecore/site
store with the properadminPage
parameter which is passed tocreateModuleStore()
. -
Ensure the above
info
store is combined with the other stores inassets/js/googlesitekit/modules/create-module-store.js
to add to the base module store. -
Write tests in
assets/js/googlesitekit/modules/datastore/info.js
to ensure the selectors properly callgetAdminURL()
with the correct parameters. -
Update tests in
assets/js/googlesitekit/modules/create-module-store.test.js
to ensure the new selectors are included. -
Refactor code in modules to use the new selector instead of utilities like
getReAuthURL
, for example:getReAuthURL( 'adsense', true )
QA Brief
Changelog entry
- Add selectors to get module-specific admin screen URLs to every module datastore.