-
Notifications
You must be signed in to change notification settings - Fork 293
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
Extend Permissions for viewing the dashboard to include the shared dashboard #4599
Comments
@aaemnnosttv Hmm, I'm wondering about that. Is it overall more straightforward to include the "view shared dashboard" within "view dashboard", or would it be better to have them as two standalone capabilities that in the relevant areas we check both for? I guess what I'm getting at is: Is there any |
@felixarntz I'm not sure we have a need for them to be separate, do we? The main reason I thought to add this is due to permission checks which rely on a single capability (e.g. Alternatively, we could conditionally register the relevant screens using a different capability based on the current user? It's a little strange though to do this check at registration time though: if the user can do X then register this item which requires the user can do X 😄 site-kit-wp/includes/Core/Admin/Screens.php Lines 278 to 282 in a27f086
This would apply to the Splash page as well site-kit-wp/includes/Core/Admin/Screens.php Lines 344 to 348 in a27f086
Would you prefer to do some ternary condition here or should we establish a new capability that would work for both while keeping view_dashboard limited to the main dashboard as it is today? |
@aaemnnosttv The ternary approach on registration indeed seems weird, but also WordPress core is doing that itself for some of its admin screens. But yeah, I like the idea of introducing two new capabilities so that we have one to access the "authenticated dashboard", one to access the "shared dashboard" and another one to access "either dashboard". How about we make the existing |
That sounds good to me. It could be useful for logic in the splash page as well. I assume you're okay with those being defined in the same issue here so I'll update the ACs to include that. Edit: Actually we shouldn't need an extra dedicated permission for being able to view the shared dashboard because that is already defined in #4522 – so I think we'd only need to add a new capability for being able to view the authenticated dashboard? As for the splash page however, should we define a new capability for being able to view it other than the current |
Sounds good.
Good question. I guess the cleanest approach there would be to introduce a capability |
Thanks, @kuasha420. Mostly looks good to me. Have one comment for you:
These changes should happen only if the |
QA Update: ✅With the dashboardSharing disabled and enabled:
Added |
QA
|
@wpdarren back to you for another pass 👍 QAB has been updated. |
QA Update: ✅With the dashboardSharing disabled and enabled:
With the dashboardSharing disabled:
|
Feature Description
Building on the new capabilities for dashboard sharing introduced in #4522, the existing capabilities for viewing the Site Kit dashboards should be extended to include users who can view the shared dashboard.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Permissions::VIEW_DASHBOARD
capability for viewing the dashboard should be updated to include users who can view either the main/authenticated dashboard or the shared dashboardPermissions::VIEW_POSTS_INSIGHTS
capability should also use this same logicPermissions::VIEW_AUTHENTICATED_DASHBOARD
capability should be defined to be able to check if a user can visit the authenticated version of the dashboard specifically (essentially the same logic as viewing the dashboard has today)Permissions::VIEW_SPLASH
capability should be defined similar toVIEW_DASHBOARD
above but specifically for the splash page that allows for users who can authenticate OR users who can view the shared dashboardScreen
registration should be updated to use this new permission instead of the currentAUTHENTICATE
which not all users of the shared dashboard can doPermissions::check_all_for_current_user
Implementation Brief
In
Google\Site_Kit\Core\Permissions\Permissions
class:Custom base capabilities
:VIEW_AUTHENTICATED_DASHBOARD
=googlesitekit_view_authenticated_dashboard
VIEW_SPLASH
=googlesitekit_view_splash
$this->base_to_core
array, update the existing capabilities accordingly:dashboardSharing
feature flag is enabled:$this->network_base
array, update the existing base capabilities accordingly and add the newly added Base Capabilities conditionally:get_capabilities
function, conditionally add the new capabilities when thedashboardSharing
is enabled.In
Google\Site_Kit\Core\Admin\Screens
class:dashboardSharing
feature flag is enabled.get_screens
method, update theScreen
entry for thesplash
screen and use the newly addedPermissions::VIEW_SPLASH
as it's capability.Permissions::AUTHENTICATE
condition toPermissions::VIEW_SPLASH
on bothno_access_redirect_module_to_dashboard
andno_access_redirect_dashboard_to_splash
methods.Test Coverage
PermissionsTest
.QA Brief
dashboardSharing
disabled and enabled:Changelog entry
The text was updated successfully, but these errors were encountered: