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 getAdminScreenURL and getAdminReauthURL selectors to base module store #1559
Comments
AC's mostly look good to me @felixarntz.
Should this issue include the |
@aaemnnosttv Yeah that's what I was thinking. Will clarify a bit more. |
IB ✅ |
Overall, everything looks good. Found a few minor things:
@ShahAaron can you look at it and fix? |
@ShahAaron @eugene-manuilov Good catch, can you address point 1. specifically? Point 2. was maybe due to a slightly unclear ACs, the dashboard CTA you're referring to is technically not a refactored component, so we don't need to update that yet. No harm in doing that, but I'd rather not make this change now this late in the release cycle. |
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 ofgetAdminURL
from thecore/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
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).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.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).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:site-kit-wp/assets/js/modules/adsense/settings/settings-setup-incomplete.js
Line 51 in d62ff79
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: