-
Notifications
You must be signed in to change notification settings - Fork 284
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
Implement new actions for sharing settings #4794
Comments
@asvinb @aaemnnosttv The
|
@asvinb we don't need a factory for the sharing settings datastore. It should be a simple datastore in the Could you please update your instructions to explain how to create a simple datastore with the requested actions? Also, please, mention the approach of how to work with changed settings and what should happen when we save them. |
IB ✅ |
@kuasha420 @hussain-t This issue should not depend on #4481. The two are interconnected but should be able to be implemented separately. I'm going to remove the dependency for now but let me know if you feel it is important to keep for some reason. |
@aaemnnosttv, there are a couple of reasons I consider #4481 is blocking this ticket though I have done the base work with unit tests and created a draft PR.
|
@aaemnnosttv, we need to move the |
@hussain-t I would prefer to keep these in their respective issues as defined and use a temporary workaround here instead. E.g. we can manually "select" the state for the action above instead, and refactor it to use the selector in that issue as a simple one line change. // TODO: Refactor to use `getSharingSettings` selector.
const { sharingSettings } = registry.stores[ CORE_MODULES ].store.getState() That should unblock this issue and then we can address the above TODO in #4795. If that works for you, then let's move forward with that approach and we can simply update the IB for 4795 with a reminder to address this TODO (I don't think any changes to ACs are necessary here). |
Thanks, @aaemnnosttv; however, currently, when we call this action, it throws an To keep these in their respective issues as defined, I think we can stub the shape of the Otherwise, we will have to call the const settings = {
'search-console': {
sharedRoles: [ 'editor', 'subscriber' ],
management: 'all_admins',
},
analytics: {
sharedRoles: [ 'editor' ],
management: 'owner',
},
'pagespeed-insights': {
sharedRoles: [ 'editor' ],
management: 'all_admins',
},
};
yield actions.receiveGetSharingSettings( settings );
const { sharingSettings } = registry.stores[ CORE_MODULES ].store.getState(); IMO, the first would be better, WDYT? |
Thanks, @aaemnnosttv, as per our discussion I have updated the tests to dispatch the |
QA Update: ✅Verified: The QAB is highlighted as
Labelled this
|
|
Thanks, @aaemnnosttv. I have addressed your comments in a follow-up PR and assigned this ticket for review. |
Feature Description
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
The
core/modules
store should be extended with the following actions:setSharingManagement(moduleSlug: string, management: enum)
Sets the value for a module's sharing management where
management
can be one ofall_admins
orowner
setSharedRoles(moduleSlug: string, roles: string[])
Sets the list of roles (
role.id
[]) the module is shared withsaveSharingSettings()
Saves all sharing settings via
POST:core/modules/data/sharing-settings
usingcreateFetchStore
newOwnerIDs
included in the response should update the modules in statecreateSettingsStore
which stores state for saved settings separately from the current working/draft values that selectors and actions touchreceiveGetSharingSettings
should also be created which should update bothImplementation Brief
assets/js/googlesitekit/modules/datastore/sharing-settings.js
which will contain our actions and reducers.baseInitialState
should contain thesharingSettings
andsavedSharingSettings
property, both initialized to an empty object.fetchSaveSharingSettingsStore
using thecreateFetchStore
function with the following details:baseName
should be set tosaveSharingSettings
controlCallback
should:state.savedSharingSettings
.core/modules/data/sharing-settings
usingAPI.set
, and passing thestate.savedSharingSettings
as the body.argsToParams
andvalidateParams
should be set as well. Refer to how it's done in other data partials.reducerCallback
,state.sharingSettings
should be updated to the response from the API, i.e bothstate.sharingSettings
andstate.saveSharingSettings
should be equal.newOwnerIDs
from the API response is not empty. Refer to Create REST controller for dashboard sharing #4481 for the structure. In this case, loop through the array and update each module owner ID using thesetOwnerID
action.actions
within thebaseAction
object:setSharingManagement
SET_SHARING_MANAGEMENT
having the same value should be added at the beginning of the file.moduleSlug
andmanagement
as mandatory parameters.management
property of the givenmoduleSlug
within the statesavedSharingSettings
property.setSharedRoles
SET_SHARED_ROLES
having the same value should be added at the beginning of the file.moduleSlug
androles
as mandatory parameters.baseReducers
object where thesharedRoles
property of the givenmoduleSlug
is set within the statesavedSharingSettings
property.saveSharingSettings
createValidatedAction
function which checks whetherstate.savedSharingSettings
is not empty.fetchSaveSharingSettingsStore.actions.fetchSaveSharingSettings
function, passing thestate.savedSharingSettings
.receiveGetSharingSettings
settings
and it should setstate.sharingSettings
andstate.savedSharingSettings
with the provided parameter.invariant
to check for the parameters similar to how it’s done in other data store partials.assets/js/googlesitekit/modules/datastore/index.js
to include the new data store partial.Test Coverage
QA Brief
QA
QA:Eng
dashboardSharing
feature flag is enabled.receiveGetSharingSettings
action like so:Note that the
receiveGetSharingSettings
action has to be dispatched beforesaveSharingSettings
since it sets thesharingSettings
in the state. Otherwise, it will throw an error.In the console, test invoking the added actions as defined in the ACs
Test
saveSharingSettings
makes an API call to thesharing-settings
endpoint successfullyChangelog entry
The text was updated successfully, but these errors were encountered: