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
Add actions and selectors for managing module settings panel state #2181
Comments
@tofumatt Mostly LGTM, but two things don't satisfy the ACs:
This should never return
Per the ACs |
Ah, right on. Fixed! 🙂 |
@tofumatt IB pretty much LGTM, however it's still missing a mention of
This is true, but it would be more clear saying that, if |
Ah, right on. I think using a registry selector for modules that aren't yet defined in the panel state should cover that and create an effective default state—let me know what you think about that approach 😄 |
IB ✅ |
Per #2182 (comment) this file |
@felixarntz I've updated the ACs (mostly additive for clarity) and IB here per our last conversation. Let me know if anything is out of place or missing here to prevent further unnecessary changes for @ivankruchkoff . @ivankruchkoff – please take a look and let me know if you have any questions or concerns regarding these changes before resuming. |
@aaemnnosttv @ivankruchkoff ACs look accurate, I think the modified IB can be a bit simplified:
|
SGTM 👍 I've updated the IB to reference this name for the state instead.
From a semantic perspective, I don't think we should implement a toggling behavior for a "set*" action. If we want to offer that capability from the datastore (which is totally reasonable, and something I had added originally as well), then I think it makes more sense to name the action like const isPanelOpen = useSelect( ( select ) => select( 'core/modules' ).isSettingsPanelOpen( slug ) );
const { setSettingsPanelState } = useDispatch( 'core/modules' );
const togglePanel = useCallback( () => {
setSettingsPanelState( slug, isPanelOpen ? 'closed' : 'view' )
}, [ slug, isPanelOpen ] ); This is quite simple to implement so the question is whether or not it makes sense to build that into the datastore or not? |
As discussed last week, we had somewhat a misunderstanding regarding your latest comment @aaemnnosttv - the current IB LGTM! |
@ivankruchkoff – this one is ready to resume if you haven't already 👍 |
@aaemnnosttv - addressed CR feedback and changed the implementation to match the new IB. Reassigned it back to you as you looked at initially. |
Updated per CR feedback. |
The
core/modules
store should support managing the state for the settings panels Site Kit Settings.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
core/modules
store should receive a new selectorgetModuleSettingsPanelState( slug )
that returns for the module identified by the given slug in which state the panel is (e.g. whether it is closed, in "view" or "edit" mode etc.).core/modules
store should receive a new actionsetModuleSettingsPanelState( slug, value )
that sets the panel state for the module identified by the given slug to the given value.setModuleSettingsPanelState
:closed
view
edit
locked
"meta-state" which cannot be settable via the action, but selectable separately.isModuleSettingsPanelOpen( slug )
isModuleSettingsPanelClosed( slug )
isModuleSettingsPanelEdit( slug )
isModuleSettingsPanelLocked( slug )
closed
.Implementation Brief
assets/js/googlesitekit/modules/datastore/settings-panel.js
.state
shape as follows whereModuleSlug
is a string ornull
:getModuleSettingsPanelState( slug )
that returnsview|closed|edit
as a string.isModuleSettingsPanelOpen( slug )
– (slug === currentModule
)isModuleSettingsPanelClosed( slug )
– (slug !== currentModule
)isModuleSettingsPanelEdit( slug )
– (slug === currentModule && isEditing
)isModuleSettingsPanelLocked( slug )
– (slug !== currentModule && isEditing
)setModuleSettingsPanelState( slug, value )
that allows settingvalue
to one of:'view' | 'edit' | 'closed'
.Trying to set any other value should result in an error.
slug
toview
, setcurrentModule
toslug
andisEditing
tofalse
slug
toedit
, setcurrentModule
toslug
andisEditing
totrue
slug
toclosed
, setcurrentModule
tonull
andisEditing
tofalse
Test Coverage
assets/js/googlesitekit/modules/datastore/settings-panel.test.js
actions.setModuleSettingsPanelState
selectors.getModuleSettingsPanelState
selectors.isModuleSettingsPanelOpen( slug )
selectors.isModuleSettingsPanelClosed( slug )
selectors.isModuleSettingsPanelEdit( slug )
selectors.isModuleSettingsPanelLocked( slug )
Visual Regression Changes
QA Brief
Changelog entry
core/modules
actions and selectors for managing module settings panel state.The text was updated successfully, but these errors were encountered: