-
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
Hide widget tiles when Key Metrics aren't setup #7061
Comments
ACs here are good, assigning it back to you @jimmymadon 👍🏻 |
I think the refactor here is definitely worth doing, I'm going to remove "potential" refactor from the IB. IB ✅ |
The changes here sound similar to a change we made in another issue so we may need to revisit the approach here. See #7126 (comment) One key detail here is that we should avoid rendering the individual tiles themselves when we know it shouldn't be rendered based on outside factors like settings. |
IB ❌
@jimmymadon the problem with the proposed approach is that all widgets will have pulled their reports before we actually start to determine whether or not we need to render anything in the |
What we should do is update HOC to accept a new argument |
@eugene-manuilov Thanks for the suggestion here - @aaemnnosttv and I did discuss this option as well. In the end, we decided to go for a simpler solution as mentioned in the now updated IB. I have also updated the ACs here. c.c. @aaemnnosttv @tofumatt |
Thanks, @jimmymadon. IB looks good now. |
@techanvil Assigning this back to you with a follow up PR based on the bug we discussed. I have also updated the QA brief. |
QA Update: ✅Verified:
|
Feature Description
In #6261, we refactored the selectors so that
getKeyMetrics
within thecore/widgets
core/user
store determines which key metric widget tiles should be displayed on the dashboard. This selector returns an empty array when the Key Metrics widget itself is not set up. Based on this functionality, we should hide the widget tile placeholders which are currently being rendered even when the user has not answered the questionnaire nor picked their own metrics (i.e the Key Metrics widget is not setup).Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
getKeyMetrics
selector fromcore/widgets
should be rendered. (This selector already returns the appropriate metrics set based on either the user input questionnaire answers or the user picking their own metrics.)Implementation Brief
Within
assets/js/googlesitekit/datastore/user/key-metrics.js
:isKeyMetricActive
which takes a key metricwidgetSlug
as a parameter. This selector should use thegetKeyMetrics
from the same file (core/user
datastore) to check if thiswidgetSlug
is present.In all
assets/js/modules/<module-name>/index.js
files:registerWidget
, pass the above selector as a function to theisActive
parameter.In
DashboardMainApp.js
:isKeyMetricsWidgetHidden
selector and iff it returns true, do not not render the<WidgetContextRenderer>
for the Key Metrics Widget context.Delete the
assets/js/components/KeyMetrics/utils.js
file and remove thewhenKeyMetricsWidgetVisible
HOC and its usage in existing widget tiles.Withinassets/js/components/KeyMetrics
, create a new functional component calledMetricTile
:This component will act as a wrapper for theMetricTileNumeric
(already implemented), theMetricTileText
(as part of Create the "Top traffic source" key metric widget tile #6245) andMetricTileTable
(as part of Create the "Top performing keywords" key metric widget tile #6251) components.It should take thewidgetSlug
as a prop and use theisKeyMetricActive
selector above. If the metric is active, it should render thechildren
prop and if it is not active, it should render the<WidgetNull>
component which should also be passed as a prop to the<MetricTile>
component.Within all Key Metric widget components:Instead of rendering the with the <MetricTile-xxxx->
component directly, wrap it with<MetricTile>
created above. Pass the<WidgetNull>
component as a prop to it. For components which have not been implemented as yet and have "TODO" in them, simply wrap the<MetricTile>
component.Move thekeyMetricsWidgetHidden
check from all individual components into the new<MetricTile>
component. This way the logic to render<WidgetNull>
, both, when Key Metrics aren't setup and when the Key Metrics widget is "hidden" (based on the settings toggle), will reside in a single component.Test Coverage
<MetricTile>
component and assert<WidgetNull>
is rendered as per the IB above.QA Brief
userInput
feature flag disabled, smoke test the Site Kit dashboard and verify there are no console errors.userInput
feature flag for the following instructions.googlesitekit_user_input_settings
option fromwp_options
and repeat this step to check the appropriate tiles are displayed based on the answer to question 1 of the questionnaire.Changelog entry
The text was updated successfully, but these errors were encountered: