-
Notifications
You must be signed in to change notification settings - Fork 315
Closed
Labels
Module: AdSenseGoogle AdSense module related issuesGoogle AdSense module related issuesP0High priorityHigh priorityRolloverIssues which role over to the next sprintIssues which role over to the next sprintType: EnhancementImprovement of an existing featureImprovement of an existing feature
Milestone
Description
The "Performance over the last x days" widget on the AdSense module page should be refactored as a new component that is registered and rendered using the Widget API.
The existing component should be untouched and only be renamed, giving it a Legacy
prefix.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- A new component
ModuleOverviewWidget
should be added inassets/js/modules/adsense/components/module/ModuleOverviewWidget.js
. - It should be implemented as a functional, hook-based, datastore-driven widget component that renders the existing "Performance over the last x days" block on the AdSense module page, in a refactored way.
- In other words, it should replicate what the legacy
AdSenseDashboardWidgetOverview
andAdSenseDashboardWidgetSiteStats
components display. These components were already refactored at a previous point so the new component should be able to reuse most of the code. The main things to change is to create the API requests themselves instead of receiving data via props, as well as to useWidget*
components via props. - Sub-components can be implemented as necessary. If reusable, they should go into
assets/js/modules/adsense/components/common
. Otherwise (if specific to just this widget), they should go into a newassets/js/modules/adsense/components/module/ModuleOverviewWidget
directory; in this case, the main widget component should go into theindex.js
file within that directory.
- In other words, it should replicate what the legacy
- The
AdSenseDashboardWidgetOverview
andAdSenseDashboardWidgetSiteStats
components should be renamed, receiving aLegacy*
prefix. - The new component should be used to register a new widget in
assets/js/modules/adsense/index.js
(for testing, requires to enable thewidgets.moduleScreens
feature flag):- slug:
adsenseModuleOverview
- width:
WIDGET_WIDTHS.FULL
- priority:
1
- wrapWidget:
false
(since it needs to renderWidget
manually to add theHeader
prop - widget area:
AREA_MODULE_ADSENSE_MAIN
- slug:
Implementation Brief
- Create a new file
assets/js/modules/adsense/components/module/ModuleOverviewWidget.js
which will export theModuleOverviewWidget
functional component. ModuleOverviewWidget
should have the following props:Widget
,WidgetReportZero
andWidgetReportError
, similar to what is done inassets/js/modules/search-console/components/dashboard/DashboardPopularKeywordsWidget.js
.ModuleOverviewWidget
should take most of the code from the following files:assets/js/modules/adsense/components/dashboard/AdSensePerformanceWidget.js
with the following changes:- Remove the
handleDataSuccess
andhandleDataError
props usage. - Remove usage of the
AdSenseDashboardWidgetOverview
andAdSenseDashboardWidgetSiteStats
.
- Remove the
assets/js/modules/adsense/components/dashboard/AdSenseDashboardWidgetOverview.js
with the following changes:- Remove the
handleDataSuccess
andhandleDataError
props usage.
- Remove the
assets/js/modules/adsense/components/dashboard/AdSenseDashboardWidgetSiteStats.js
with the following changes:- Remove the
handleDataSuccess
andhandleDataError
props usage.
- Remove the
- If there are any errors in the
getReport
queries, render theWidgetReportError
component, passingadsense
as value for themoduleSlug
prop and theerror
as well. - If there is no data for any
getReport
queries, render theWidgetReportZero
component instead ofReportZero
component, passingadsense
as value for themoduleSlug
prop.
- Create a new file
assets/js/googlesitekit/widgets/components/WidgetHeaderTitle
which will export theWidgetHeaderTitle
functional component.WidgetHeaderTitle
should have only 1 prop,title
which is astring
and render the same markup as the title of the legacy component (For e.gPerformance over the last 28 days
) without any grid markup/class names.
- Create a new file
assets/js/googlesitekit/widgets/components/WidgetHeaderCTA
which will export theWidgetHeaderCTA
functional component.WidgetHeaderCTA
should have the following props:href
: Stringlabel
: Stringexternal
: bool (default:true
)
- and it should use the
Link
component to render the external CTA leading to a module's service frontend. For e.gSee full stats in AdSense
.
ModuleOverviewWidget
should render the same markup fromAdSensePerformanceWidget
andAdSenseDashboardWidgetSiteStats
combined, wrapped within theWidget
component, similar to how it's done inDashboardPopularKeywordsWidget
but with the following change:- Update the usage of the
Widget
component to add theHeader
prop. The value of theHeader
prop is a function which returns the title (for e.gPerformance over the last 28 days
) using the newly addedWidgetHeaderTitle
component and the CTA (See full stats in AdSense
) using theWidgetHeaderCTA
component. The function should only render 2 child elements since flexbox is going to be used to space them out in the header. Refer to the legacy components on how the values for the title and CTA are set.
- Update the usage of the
- Using
assets/sass/widgets/_widgets.scss
,- Edit the
.googlesitekit-widget__header
class name to useflexbox
, with thejustify-content
set tospace-between
. - Remove margins from headings within the
.googlesitekit-widget__header
class name. - Make sure children within the
.googlesitekit-widget__header
class name stack properly on small screens, with a margin of16px
between the child elements.
- Edit the
- Edit
assets/js/modules/adsense/index.js
and register a new widget with the following properties:- Component:
ModuleOverviewWidget
, - slug:
adsenseModuleOverview
- width:
WIDGET_WIDTHS.FULL
- priority:
1
- wrapWidget:
false
- widget area:
AREA_MODULE_ADSENSE_MAIN
- Component:
- Edit
/stories/module-adsense-components.stories.js
to add a new stories for theModuleOverviewWidget
under theAdSense Module/Components/Module Page/
group, showing the following states:- When the data is loading.
- When there is no data.
- When there is an error.
- When data has loaded.
- The
AdSenseDashboardWidgetSiteStats
andAdSenseDashboardWidgetOverview
components should be renamed, receiving aLegacy*
prefix and references should be updated.
Test Coverage
- N/A
Visual Regression Changes
- N/A
QA Brief
- Visit the "AdSense" dashboard where the new widget should be displayed above the legacy one.
- Both widgets should function the same way and display the same data.
Changelog entry
- Migrate AdSense module page overview widget to use Widget API.
Metadata
Metadata
Assignees
Labels
Module: AdSenseGoogle AdSense module related issuesGoogle AdSense module related issuesP0High priorityHigh priorityRolloverIssues which role over to the next sprintIssues which role over to the next sprintType: EnhancementImprovement of an existing featureImprovement of an existing feature