From 09082fc0612848aababbf406ddb12de6b700eb39 Mon Sep 17 00:00:00 2001 From: Mauro Bartolomeoli Date: Tue, 28 Mar 2017 11:54:19 +0200 Subject: [PATCH 1/2] Documented the dynamic configuration feature for plugins --- docs/developer-guide/plugins-architecture.md | 2 +- docs/developer-guide/plugins-documentation.md | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/developer-guide/plugins-architecture.md b/docs/developer-guide/plugins-architecture.md index 7ade494e9f..39561d3ce4 100644 --- a/docs/developer-guide/plugins-architecture.md +++ b/docs/developer-guide/plugins-architecture.md @@ -99,7 +99,7 @@ My.jsx: // this is a dumb component const MyComponent = require('../components/MyComponent'); -const {connect} = require('react-redux'); +const {connect} = require('../utils/PluginsUtils'); // let's wire it to state and actions const MyPlugin = connect((state) => ({ diff --git a/docs/developer-guide/plugins-documentation.md b/docs/developer-guide/plugins-documentation.md index 29a09b7fe1..243f94415f 100644 --- a/docs/developer-guide/plugins-documentation.md +++ b/docs/developer-guide/plugins-documentation.md @@ -40,4 +40,41 @@ or fully configured: ] } ``` + +## Dynamic configuration +Configuration properties of plugins can use expressions, so that they are dynamically bound to the +application state. + +An expression is anything between curly brackets ({...}) that is a javascript expression, +where the **monitored state** of the application is available as a set of variables. + +To define the monitored state, you have to add a **monitorState** property in **localConfig.json**. + +```js +{ + ... + "monitorState": [{"name": "mapType", "path": "mapType.mapType"}] + ... +} +``` + +Where: + * **name** is the name of the variable that can be used in expressions + * **path** is a javascript object path to the state fragment to be monitored (e.g. map.present.zoom) + +When you have a monitored state, you can use it in configuration properties this way: + +```js +"cfg": { + ... + "myProp": "{mapType === 'openlayers' : 1 : 2}" + ... +} +``` + +Expressions are supported in **cfg** properties and in **hideFrom** and **showIn** sections. + +In addition to monitored state also the **page request parameters** are available as variables to be +used in expressions. + Look at the [plugin reference page](./api/plugins) for a list of available configuration properties. From 2e8d67fda4d17cafc2f71d3be797697320d019b3 Mon Sep 17 00:00:00 2001 From: Mauro Bartolomeoli Date: Tue, 28 Mar 2017 11:59:34 +0200 Subject: [PATCH 2/2] Fixed typo --- docs/developer-guide/plugins-documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer-guide/plugins-documentation.md b/docs/developer-guide/plugins-documentation.md index 243f94415f..b3914ede4d 100644 --- a/docs/developer-guide/plugins-documentation.md +++ b/docs/developer-guide/plugins-documentation.md @@ -67,7 +67,7 @@ When you have a monitored state, you can use it in configuration properties this ```js "cfg": { ... - "myProp": "{mapType === 'openlayers' : 1 : 2}" + "myProp": "{mapType === 'openlayers' ? 1 : 2}" ... } ```