woocommerce/plugins/woocommerce-admin/client/dashboard
Sam Seay b076a7b521
Fix linter issues and update Syncpack (#38523)
2023-05-31 11:45:10 +12:00
..
components Fix linter issues and update Syncpack (#38523) 2023-05-31 11:45:10 +12:00
dashboard-charts Fix JS lint errors (#33484) 2022-06-21 16:37:34 +08:00
leaderboards Fix the styling of the frame in the Leaderboard section of Analytics. 2022-05-23 17:30:47 +02:00
store-performance Moving currencyContext to currency package and updating references (#36959) 2023-02-28 08:55:49 -08:00
README.md Remove the use of Dashicons and replace with `@wordpress/icons` or `gridicons` (https://github.com/woocommerce/woocommerce-admin/pull/7020) 2021-05-25 12:14:14 -03:00
customizable.js Moving currencyContext to currency package and updating references (#36959) 2023-02-28 08:55:49 -08:00
default-sections.js Fix/37502: Correct spelling errors. (#37887) 2023-05-08 15:55:09 +08:00
index.js Feature Flags: Removed unused flags (https://github.com/woocommerce/woocommerce-admin/pull/7233) 2021-06-30 11:47:38 +12:00
section-controls.js Set up i18n-text-domain rule and fix missing text domain (#33780) 2022-07-08 18:37:30 +08:00
section.js Add @woocommerce/eslint-plugin (https://github.com/woocommerce/woocommerce-admin/pull/4714) 2020-07-28 14:32:58 +12:00
style.scss fix: woocommerce admin cart modal header clips header text (#35780) 2022-12-01 08:03:58 +08:00
utils.ts Migrate Purchase task and dashboard utils to TS (#37725) 2023-05-09 11:28:57 +08:00

README.md

Dashboard

This folder contains the components used in the Dashboard page.

Extending the Dashboard

New Dashboard sections can be added by hooking into the filter woocommerce_dashboard_default_sections. For example:

import { arrowRight } from '@wordpress/icons';
addFilter( 'woocommerce_dashboard_default_sections', ( sections ) => {
	return [
		...sections,
		{
			key: 'example',
			component: ExampleSection,
			title: 'My Example Dashboard Section',
			isVisible: true,
			icon: arrowRight,
			hiddenBlocks: [],
		},
	];
} );

Each section is defined by an object containing the following properties.

  • key (string): The key used internally to identify the section.
  • title (string): The title shown in the Dashboard. It can be modified by users.
  • icon (function|WPComponent|null): Icon to be used to identify the section.
  • component (react component): The component containing the section content.
  • isVisible (boolean): Whether the section is visible by default. Sections can be added/hidden by users.
  • hiddenBlocks (array of strings): The keys of the blocks that must be hidden by default. Used in Sections that contain several blocks that can be shown or hidden. It can be modified by users.

The component will get the following props:

  • hiddenBlocks (array of strings): Hidden blocks according to the default settings or the user preferences if they had made any modification.
  • isFirst (boolean): Whether the component is the first one shown in the Dashboard.
  • isLast (boolean): Whether the component is the last one shown in the Dashboard.
  • onMove (boolean): Event to trigger when moving the section.
  • onRemove (boolean): Event to trigger when removing the section.
  • onTitleBlur (function): Event to trigger when the edit title input box is unfocused.
  • onTitleChange (function): Event to trigger when the edit title input box receives a change event.
  • onToggleHiddenBlock (function): Event to trigger when the user toggles one of the hidden blocks preferences.
  • titleInput (string): Current string to be displayed in the edit title input box. Title is only updated on blur, so this value will be different than title when the user is modifying the input box.
  • path (string): The exact path for this view.
  • query (object): The query string for the current view, can be used to read current preferences for time periods or chart interval/type.
  • title (string): Title of the section according to the default settings or the user preferences if they had made any modification.
  • controls (react component): Controls to move a section up/down or remove it from view to be rendered inside the EllipsisMenu.