Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented the dynamic configuration feature for plugins #1651

Merged
merged 2 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/developer-guide/plugins-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
37 changes: 37 additions & 0 deletions docs/developer-guide/plugins-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? 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.