Update widget registration to optionally declare associated module(s) and update getWidgets
to accept a new modules option
#4807
Labels
P0
High priority
QA: Eng
Requires specialized QA by an engineer
Type: Enhancement
Improvement of an existing feature
Feature Description
With dashboard sharing, it is important that users will only be able to see widgets on the dashboard for modules which have been shared with them. Currently, widget registration does not include awareness of the module (or modules) a widget is associated with.
This issue will update widget registration to allow for such (optional) association as well as extend the
getWidgets
selector to allow for selecting widgets optionally limited by some set of modules.In the future, this will be integrated with
getViewableModules
in #4803 and #4813Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
registerWidget
action on thecore/widgets
store, and its respective function on theWidgets
instance returned bycreateWidgets
should support a new optionalsettings.modules
(string|string[]
) of module slug(s)getWidgets
selector on the same store should be extended to receive an optionaloptions
object as its 3rd argument withoptions.modules
as astring|string[]
of module slug(s)adsense
andanalytics
), it should only be returned if all of its registered modules are in the list of modules provided in the option. (e.g. ifoption.modules
wasanalytics
, the widget would not be returned. Ifoption.modules
was['analytics','search-console','adsense']
, it would be, because bothadsense
andanalytics
were included)getWidgets
should continue to work as todayImplementation Brief
assets/js/googlesitekit/widgets/datastore/widgets.js
file:registerWidget
action:modules
to the incoming settings object (2nd parameter).modules
variable to always be an array. of strings.modules
to the settings object defined in the action payload.getWidgets
selector:options
which is an object with the onlymodules
property supported by now.options.modules
is not empty, then filter returned widgets to return widgets that either have no modules assigned or all associated modules are included in theoptions.modules
list. See more details in AC.assets/js/googlesitekit/widgets/index.js
fileregisterWidget
function to definemodules
as a new property of the settings parameter.Test Coverage
QA Brief
registerWidget
action and thegetWidgets
selector to make sure that the implementation follows requirements defined in AC.Changelog entry
The text was updated successfully, but these errors were encountered: