Introduce new capabilities for viewing secondary elements
See original GitHub issueFeature Description
Site Kit’s primary features live in its dashboard view, but there are a few substantial “secondary” elements which fall outside of the main area, particularly the WordPress dashboard “Site Kit Summary” widget, and the admin bar integration on the frontend. These currently both rely on the custom VIEW_DASHBOARD
capability, however in the context of dashboard sharing, this is potentially not sufficient as a user may have the ability to view the shared dashboard, but lack access to Search Console or Analytics. These two locations are unique in that they have a hardcoded layout that relies on these two modules only. If the user does not have access to at least one of them, we should not show it in the first place as the requests would be guaranteed to fail which would make for a rather poor experience.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
Permissions
class should receive two new capabilities:VIEW_WP_DASHBOARD_WIDGET
VIEW_ADMIN_BAR_MENU
- For now, both capabilities will use the same logic for checking them:
* They should be added to the list of base capabilities with similar behavior as
VIEW_DASHBOARD
. * They should however use the same logic asVIEW_AUTHENTICATED_DASHBOARD
, i.e. they should only be available to authenticated users (in addition to the above base capability to core mapping).
Implementation Brief
- Add two new capability constants to
includes/Core/Permissions/Permissions.php
:VIEW_WP_DASHBOARD_WIDGET
andVIEW_ADMIN_BAR_MENU
. - Have the constants setup/mirror the behaviour of the existing
VIEW_DASHBOARD
constant, except for its permissions checks use the logic here: https://github.com/google/site-kit-wp/blob/1a10436f98b25c2f046aaacde1bf5157a43717ff/includes/Core/Permissions/Permissions.php#L368
Test Coverage
- PHPUnit tests that ensure these capabilities are returned when the appropriate permissions exist/don’t exist should be added.
QA Brief
QA
- This issue should not affect any existing functionality as it simply ‘adds’ capabilities without ‘using’ them (for now). Thus, it should suffice to smoke test the plugin:
- with and without the Dashboard Sharing feature flag.
- using an authenticated admin and a non-authenticated admin (they should be able to do/not do things as before, i.e. authenticated admins should still be able to setup and view the dashboard, etc.).
UPDATED QA
- Verify that a non-authenticated admin and a non-admin user, who would be able to view the shared dashboard (their role should be shared with at least one module), CANNOT view the Admin Bar widget / menu button and the Site Kit Summary on the WP Dashboard.
- Verify that authenticated admins who can view the full dashboard are still able to view the Admin Bar and WP Dashboard widgets.
Changelog entry
- Introduce new permissions for viewing Site Kit on the WordPress Dashboard, and in the Admin Bar.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (2 by maintainers)
Approval ❌
@wpdarren @jimmymadon @aaemnnosttv This has already been flagged in the dashboard sharing bug bash, but this is not behaving like it should. There may have been a misunderstanding during the implementation, since also the QA Brief is not accurate. This change should have end user facing implications: Users with shared access (not connected with their Google account) should be able to view the shared dashboard, but not the Site Kit WP dashboard widget, and not the Site Kit admin bar menu. Essentially, these two areas should never be visible to anyone with shared access.
Sending this back to Execution for consideration. In case this is trivial to fix, it would be great to do that here. Otherwise, since it’s only affecting the
dashboardSharing
feature flag, we could also fix it later.@aaemnnosttv Updated the ACs based on our conversation earlier. Let me know if that looks good to you.