woocommerce/plugins/woocommerce-admin/client/dashboard
Chi-Hsuan Huang c05605fddf Update linting, testing, `@types/*` dependencies (https://github.com/woocommerce/woocommerce-admin/pull/8475)
* Update husky from 4 to 7

* Update @types/jest from 26 to 27

* Update lint-staged from 10 to 12

* Update babel-jest from 26 to 27

* Update @typescript-eslint/eslint-plugin from 4 to 5

* Update @typescript-eslint/parser from 4 to 5

* Update chalk from 4 to 5

* Update concurrently from 5 to 7

* Update stylelint from 9 to 14 and stylelint-config-wordpress from 13 to 17

* Update @wordpress/prettier-config from 0.4 to 1.1

* Update eslint from 7 to 8, @wordpress/eslint-plugin from 8 to 10, eslint-plugin-testing-library to 5

* Fix lint errors after updating eslint-plugin-testing-library

* Fix style lint

* Rename .stylelintrc.json -> stylelint.config.js & add todo comment

Fix stylelint.config.js

* Remove @wordpress/e2e-test-utils

* Add changelogs for eslint-plugin

* Update storybook/preview.js since addDecorator has been deprecated

Remove parameters

* Import directly from @storybook/addon-docs

* Migrate some stories to use @storybook/addon-controls

Add a comment for @storybook/addon-knobs

* Update changelogs

* Update preview.js to fix lint warning

* Update pnpm-lock.yaml

* Fix eslint layout errors (https://github.com/woocommerce/woocommerce-admin/pull/8484)
2022-03-18 19:45:14 +08:00
..
components Update linting, testing, `@types/*` dependencies (https://github.com/woocommerce/woocommerce-admin/pull/8475) 2022-03-18 19:45:14 +08:00
dashboard-charts Add hook reference generator README and documentation (https://github.com/woocommerce/woocommerce-admin/pull/8004) 2022-02-11 10:38:38 -04:00
leaderboards Remove unpublished wc-admin-settings package and update getSetting usage (https://github.com/woocommerce/woocommerce-admin/pull/8057) 2022-01-06 08:53:30 -04:00
store-performance Fix incorrect date options when the "Default Date Range" is set from Analytics settings (https://github.com/woocommerce/woocommerce-admin/pull/8189) 2022-01-19 10:15:33 +08:00
test Task list - add a shortcut back to store setup (https://github.com/woocommerce/woocommerce-admin/pull/4853) 2020-08-06 10:02:24 +12: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 Add hook reference generator README and documentation (https://github.com/woocommerce/woocommerce-admin/pull/8004) 2022-02-11 10:38:38 -04:00
default-sections.js Update linting, testing, `@types/*` dependencies (https://github.com/woocommerce/woocommerce-admin/pull/8475) 2022-03-18 19:45:14 +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 Sentence case all the things analytics (https://github.com/woocommerce/woocommerce-admin/pull/6501) 2021-08-13 14:54:24 -04: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 Tests for task list components (https://github.com/woocommerce/woocommerce-admin/pull/7757) 2021-10-15 16:56:17 -03:00
utils.js Update linting, testing, `@types/*` dependencies (https://github.com/woocommerce/woocommerce-admin/pull/8475) 2022-03-18 19:45:14 +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.