-
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
Restrict editing module entity settings to users who have access #4825
Comments
@felixarntz @marrrmarrr regarding the cases above, I based them off what we have in Figma but both were adapted to be non-module specific. Also the with-access/takeover case copy was adapted from what we have in the sharing settings. Let me know if this sounds good to you, otherwise I think this is ready for an IB. |
@aaemnnosttv Just a couple of questions:
|
Good point - I suppose not. This can be part of the IB I think 👍
The module owner's username is already available on the |
@jimmymadon no need to do it in every component. Every module has the
site-kit-wp/assets/js/modules/analytics/components/settings/SettingsEdit.js Lines 57 to 59 in 8b62084
site-kit-wp/assets/js/modules/optimize/components/settings/SettingsEdit.js Lines 34 to 36 in 8b62084
site-kit-wp/assets/js/modules/search-console/components/settings/SettingsEdit.js Lines 45 to 47 in 8b62084
By checking module access in those components, we ensure that
Same here, we shouldn't display this message in a particular input field. The notice should be displayed in the |
@eugene-manuilov I originally was going to do it that way - then realised that in the case of Analytics, we don't prevent the loading of all other elements/switches if we are only 'deciding' on how to render the Select fields. But in the end, I did for Analytics, I did put the loading logic in SettingsEdit as I didn't want multiple loading bars showing up within. So yeah, makes sense to move the search-console too! Thanks! |
@aaemnnosttv Just to clarify, in Analytics, should this notice be displayed twice - below the UA fields and the GA4 fields or just below the UA fields? |
@jimmymadon, we forgot to add the AdSense module. |
@eugene-manuilov I have added a note to the IB based on Evan's reply to my comment. AdSense does not have any editable owned settings - so I don't think it is necessary to check for module access here? |
Hey @jimmymadon, this is looking good but please can you write a QA Brief for the issue? |
QA Update:
|
QA Update: ✅After conversation with @jimmymadon we decided to include the observation above as a potential 'known issue' for bug bash so it can be discussed further, as we are unsure of the definition here. I am therefore moving this to approved. Verified:
|
This is what I asked Evan here and for now we have decided to proceed with 2 notices if the current user does not have access to both, the UA and GA4 properties. Thinking about this now, I should've included adding/removing access at the "Property" level instead of the "Account" level as defined in the QAB to test this behaviour. However, the red notice can be discussed further as a 'known issue'. |
Feature Description
With the introduction of dashboard sharing, changing a module's connection (a.k.a. service entity) has substantial implications when shared – changing these settings requires taking on the responsibility of sharing (granting access via your Google account). Accordingly, changing these settings can only be done by admins who have access to the configured entity.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
useSnippet
) and submit those changes even if they don't have access to the entitySelect
with single selected value){connection entity}
refers to a service specific term, such as "Analytics property", "Search Console property" or "AdSense account" and should use separate translation strings rather than a formatted string to populatedashboardSharing
is enabled and the user has changed any of the owned settings (see Expose owned module settings to client #5121), and is not the owner themselves, and the module is currently being shared with one or more roles:display a new
Implementation Brief
Implementing logic for when the user does not have access
In
assets/js/modules/analytics/components/settings/SettingsEdit.js
andassets/js/modules/search-console/components/settings/SettingsEdit.js
::hasModuleAccess( slug )
.<ProgressBar>
component.In
assets/js/modules/search-console/components/common/PropertySelect.js
,assets/js/modules/analytics/components/common/AccountSelect.js
,assets/js/modules/analytics/components/common/PropertySelect.js
,assets/js/modules/analytics/components/common/ProfileSelect.js
andassets/js/modules/analytics-4/components/common/PropertySelect.js
:hasModuleAccess( slug )
selector introduced in Implement new selector for checking module access #4802.disabled
prop of the<Select>
component so that the field is disabled if the value is true.In
assets/js/modules/search-console/components/settings/SettingsForm.js
,hasModuleAccess( slug )
selector.<SettingsNotice>
component.type=TYPE_INFO
andicon=WarningIcon
below the select field as described in the AC/Figma design.getModule( slug )
selector from thecore/modules
store. Note that theowner
object will only be set if the user has sufficient permissions, although all users who can edit settings (admins) should have it, it shouldn't be assumed that the object is there. As a fallback, "Another admin" can be replaced with the username in the message.In
assets/js/modules/analytics/components/settings/SettingsControls.js
andassets/js/modules/analytics/components/settings/GA4SettingsControls.js
:hasModuleAccess( slug )
selector.<SettingsNotice>
component as described above in search-console's<SettingsForm>
component. Render it below the select fields in these components as per the Figma mock in the AC.Implementing logic for when the user does have access
In
assets/js/components/settings/
, create a new component<EntityOwnershipChangeNotice>
as follows:slug
prop which accepts the current module-slug for which the notice is being rendered.hasModuleAccess( slug )
selector introduced in Implement new selector for checking module access #4802, return an empty component if false.haveOwnedSettingsChanged
selector from the current module's store (Expose owned module settings to client #5121) to find out if any of the owned settings have changed. Return an empty component if false.getOwnerID()
selector from the current module's store. Use thegetID
selector from thecore/user
store. Compare the IDs to find out if the current user is the owner of the module. If the current user is the owner, return an empty component.<SettingsNotice>
component withtype=TYPE_WARNING
and text as per the AC. The{submit button text}
should be replaced withConfirm Changes
. The module name can be passed as a prop to this component.In
assets/js/modules/analytics/components/settings/SettingsForm.js
andassets/js/modules/search-console/components/settings/SettingsForm.js
,<EntityOwnershipChangeNotice>
component created above at the end of the form.StoryBook coverage
module-search-console-settings.stories.js
,module-analytics-settings.stories.js
and in the new Storybook v6assets/js/modules/analytics/components/settings/SettingsForm.stories.js
.Test Coverage
QA Brief
This issue affects the Settings dropdown lists of "Owned Settings", fields such as "Account", "Property", "Profile", etc. Some of these components are used by multiple settings pages. So it would be beneficial to test that existing settings pages (mainly "add" and "edit") work normally without errors as before for all modules which use these dropdown fields (Search Console, Analytics, AdSense and Tag Manager).
Create an admin, say "Admin1" to setup SiteKit (this includes setting up a new Search Console property). Also setup Analytics and create a new property or use an existing one that is connected to Admin1's account.
To verify Search Console settings:
To verify Analytics Settings:
With Access: As Admin1, login to the "Analytics Dashboard" (by clicking on "See full details in Analytics" within the Analytics accordion in SiteKit's Settings). Click on the "Admin" settings cog in the left menu. Under the first "Account" column, click on "Account Access Management". In the popup, click on the + sign to add Admin2's Google Account to this account. Now login to SiteKit as Admin2, go to Analytics Settings and try editing them. Verify the ACs for when user has access.
Without Access: In Admin1's "Analytics Dashboard" mentioned above, follow the steps to go to Account Settings. In the "Account Access Management" popup, click on the 3 dots next to Admin2's Google Account and click on remove access. Now login to SiteKit as Admin2, go to Analytics Settings and try editing them again. Verify the ACs for when user does not have access.
AdSense: There are no "owned settings" for AdSense and so no changes have been made specifically to the settings components here. They should just work normally as before.
Verify the new stories in Storybook: Search Console, Analytics old story format, Analytics new story format - no access and with access.
Changelog entry
The text was updated successfully, but these errors were encountered: