8a2750c973
* Initial user preferences custom hook (wc meta). * Organize dependencies. * Specify dependencies in useSelect() call. * Remove specifying preference keys. There's currently no performance benefit to be had. * Add HoC for hydrating current user data. * Add user prefs update method. * Export user prefs hook and HoC in data package. * Handle error condition when updating user preferences. * Use closure to get user ID for prefs update. * Refactor analytics dashboard to use new user hook. * Refactor ReportTable component to use new user hook. * Move prop access to top of function component. * Add todo for potential manual resolution logic. * Refactor DashboardCharts component to use new user preferences hook. * Move code out of functional component where possible. * Fix chart interval query property. * Refactor Leaderboards component to use new user preferences hook. * Move code out of functional component where possible. * Refactor Inbox panel to use user prefs hook. @todo - updating last read isn't working. * Use user prefs hook in StatsOverview component. * Export user preferences store name. * Use new store for unread inbox indicator. * Hydrate current user data higher up in the app. * Update "last read" timestamp in inbox panel. * Fix StatsOverview test. * Remove unused dispatch method from StorePerformance component. * Remove now defunct user methods from wc-api spec. * Add tests for isRequesting. * JSON decode WC meta on updated user object. * Test user prefs retrieval and save. * Remove todo comment. * Use user prefs hook in Jetpack install CTA on homepage. |
||
---|---|---|
.. | ||
components | ||
dashboard-charts | ||
leaderboards | ||
store-performance | ||
README.md | ||
customizable.js | ||
default-sections.js | ||
index.js | ||
section-controls.js | ||
section.js | ||
style.scss | ||
utils.js |
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:
addFilter( 'woocommerce_dashboard_default_sections', sections => {
return [
...sections,
{
key: 'example',
component: ExampleSection,
title: 'My Example Dashboard Section',
isVisible: true,
icon: 'arrow-right-alt',
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
(string|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 thantitle
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.