woocommerce/plugins/woocommerce-admin/client/analytics/settings
Darren Ethier d728d38219 Refactor: Alternative approach to implementing extendable settings from the server (https://github.com/woocommerce/woocommerce-admin/pull/2917)
* integrate with new asset data registration (php side)

- includes back-compatibility.

* update js configuration and implement settings alias

- this aliases `@woocommerce/wc-admin-settings` to the settings api exposed via blocks (either the blocks plugin or core) and all the settings provided via the server.
- Adds fallback for back-compat if `wc.wcSettings` is not available in the environment (fallsback to `wcSettings`).

* initial pass to update all wcSettings direct usage to the new api

- this is just an initial pass, more can be done in separate pulls.

* missed one spot for adding new filter implementation

* fix incorrect jest config

* Avoid unnecessary assignment and directly return.

* Remove unnecessary defaults

* Fix inline comment text case.

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Remove unnecessary inline comment.

* use @todo instead of TODO

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* fix incorrect reference in webpack config.

* add missing import and slightly delay dependency injection for scripts

* update get-setting and set-setting callbacks

* disable lint rule for console.error on dev doc builds
2019-09-23 17:47:08 -04:00
..
historical-data Revert "Revert "Update to new Snackbar component and notice store"" (https://github.com/woocommerce/woocommerce-admin/pull/2643) 2019-07-23 11:26:46 +08:00
README.md Update text domain. (https://github.com/woocommerce/woocommerce-admin/pull/1795) 2019-03-13 11:14:02 -06:00
config.js Refactor: Alternative approach to implementing extendable settings from the server (https://github.com/woocommerce/woocommerce-admin/pull/2917) 2019-09-23 17:47:08 -04:00
default-date.js Settings: Add default date 2019-06-12 11:40:21 +12:00
index.js Refactor: Alternative approach to implementing extendable settings from the server (https://github.com/woocommerce/woocommerce-admin/pull/2917) 2019-09-23 17:47:08 -04:00
index.scss CSSLint: Remove whitespace at the end of line (https://github.com/woocommerce/woocommerce-admin/pull/1845) 2019-03-20 00:34:22 +01:00
setting.js Revert "Revert "Update to new Snackbar component and notice store"" (https://github.com/woocommerce/woocommerce-admin/pull/2643) 2019-07-23 11:26:46 +08:00
setting.scss Settings: Add default date 2019-06-12 11:40:21 +12:00

README.md

Settings

The settings used to modify the way data is retreived or displayed in WooCommerce reports.

Extending Settings

Settings can be added, removed, or modified outside oc wc-admin by hooking into woocommerce_admin_analytics_settings. For example:

addFilter( 'woocommerce_admin_analytics_settings', 'wc-example/my-setting', settings => {
	return [
		...settings,
		{
            name: 'custom_setting',
            label: __( 'Custom setting:', 'woocommerce-admin' ),
            inputType: 'text',
            helpText: __( 'Help text to describe what the setting does.' ),
            initialValue: 'Initial value used',
            defaultValue: 'Default value',
		},
	];
} );

Each settings has the following properties:

  • name (string): The slug of the setting to be updated.
  • label (string): The label used to describe and displayed next to the setting.
  • inputType (enum: text|checkbox|checkboxGroup): The type of input to use.
  • helpText (string): Text displayed beneath the setting.
  • options (array): Array of options used for inputs with selectable options.
  • initialValue (string|array): Initial value used when rendering the setting.
  • defaultValue (string|array): Value used when resetting to default settings.