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
Enable settings view and settings edit component registration #1623
Comments
One note: in the IB I changed Much of the ACs are copied as they're more/less IBs, and sound good to me 🙂 I've haven't modified the IB here but I wanted to make a note around the "locked" state we use for modules. Now that we store unsaved state in Redux, and can better load/unload editing screens, I think we should rethink the "locked" UX. If anything, setting other modules state to "locked" is fine, but instead of forcing a user to close their current module before switching, we should confirm they want to exit editing without saving changes and then just let them. Anyway, just a point to make really; doesn't affect the data store implementation. |
@tofumatt That change sounds good, I'll update this in the ACs too. Regarding "locked" display mode, that's a fair point for consideration in the future. Although, I'm not sure I understand the technical concern here - when you're editing, you can't go to another module's settings, so you would never lock a settings panel where you were just editing. IB ✅ |
IB ✅ |
Feature Description
We need to actually allow registration and usage of
SettingsView
andSettingsEdit
components for modules.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
registerModule
action of thecore/modules
store should be modified:settingsComponent
argument should be removed.settingsViewComponent
andsettingsEditComponent
arguments should be introduced, which should be React components for the module's view and edit component respectively. There should not be any default (i.e.undefined
).DefaultModuleSettings
component should be removed.googlesitekit.ModuleSettingsDetails-{$slug}
filter should instead include a dispatch call toregisterModule
, passing itsSettingsView
andSettingsEdit
component as applicable (some modules have both, some modules have just the view, other modules may have neither).SettingsRenderer
should be introduced:slug
(string),isOpen
(bool), andisEditing
(bool) props.SettingsMain
component of every module.modules/${ slug }
as the module's store name for now.settingsViewComponent
andsettingsEditComponent
fromcore/modules
datastore'sgetModule
selector.SettingsModule
component should be modified:withSelect
HOC, to receive the registered module's data via the datastore. For now, it should only pass thehasSettings
prop to the inner component, based on whether there is amoduleData.settingsEditComponent
(i.e.hasSettings = !! moduleData.settingsEditComponent
).googlesitekit.ModuleSettingsDetails-{$slug}
filter should be removed, and instead it should render the above newSettingsRenderer
component.ModuleSettingsDetails
component should be removed.Implementation Brief
assets/js/modules/analytics/components/settings/SettingsMain.js
toassets/js/components/settings/SettingsRenderer.js
SettingsRenderer.js
slug
prop and use a dynamicSTORE_NAME
defined asmodules/${ slug }
(see Enable settings view and settings edit component registration #1623 (comment))STORE_NAME
should be changed tostoreName
now as it is no longer a constantSettingsEdit
andSettingsView
from the module, falling back to a function that returnsnull
so that they will safely render nothing if they don't exist in the storeSettingsModule
(assets/js/components/settings/settings-module.js
) to be wrapped withData.withSelect
and pass through thehasSettings
propgooglesitekit.ModuleSettingsDetails-${ slug }
filterFilteredModuleSettingsDetails
withSettingsRenderer
passing along the same props, as well asslug
hasSettings
prop passed fromSettingsModules
registerModule
calls for all core modules to provide theirSettingsView
andSettingsEdit
components to thesettingsViewComponent
andsettingsEditComponent
respectively (where applicable)invariant
to require that these values are functions (if provided) usingcomponent && ReactIs.isValidElementType( component )
Add
react-is
todependencies
(already required by multiple packages, and dependency ofprop-types
)settingsComponent
key frommoduleDefaults
inassets/js/googlesitekit/modules/datastore/modules.js
(add|remove|removeAll)Filters( 'googlesitekit.ModuleSettingsDetails-
everywhereindex.js
modulesassets/js/googlesitekit/modules/components/DefaultModuleSettings.js
assets/js/components/settings/module-settings-details.js
assets/js/modules/*/components/settings/SettingsMain.js
and referencesTest Coverage
Jest
assets/js/components/settings/SettingsRenderer.test.js
using a basic/dummy test module (not usinganalytics
,tagmanager
, etc)assets/js/googlesitekit/modules/datastore/modules.test.js
to cover the behavior of the changes toregisterModule
assets/js/modules/*/components/settings/SettingsMain.test.js
Storybook
createLegacySettingsWrapper
googlesitekit.ModuleSettingsDetails-${ slug }
filterhasSettings
prop toSettingsModule
as this is now provided by the HOCmodule-*-settings.stories.js
todispatch( core/modules ).registerModule(...)
with the settings components provided on the fresh registry in theaddDecorator
functionsite-kit-wp/stories/module-adsense-settings.stories.js
Lines 96 to 99 in 099cac9
Visual Regression Changes
QA Brief
SettingsRenderer
component.Changelog entry
settingsViewComponent
andsettingsEditComponent
when calling theregisterModule
action on thecore/modules
store.The text was updated successfully, but these errors were encountered: