Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
netlify-cms-widget-async-select
Advanced tools
An async select widget for netlify-cms which can populate entries from a valid endpoint. Allows for sending custom headers, data/value fields and transformations.
Readme
A simple async select widget for netlify-cms which can populate entries from a valid endpoint. Allows for sending custom headers, data/value fields and transformations.
As an npm package:
npm install --save netlify-cms-widget-async-select
import { Control as asyncSelectControl } from 'netlify-cms-widget-async-select'
CMS.registerWidget('async-select', asyncSelectControl)
Via script
tag:
<script src="https://unpkg.com/netlify-cms-widget-async-select@^1.0.0"></script>
<script>
CMS.registerWidget('async-select', window.asyncSelectControl, window.asyncSelectPreview)
</script>
Add to your Netlify CMS configuration:
fields:
- {
name: 'test_widget',
label: 'Test Widget',
widget: 'async-select',
url: 'https://jsonplaceholder.typicode.com/users',
valueField: 'id',
displayField: 'name',
},
Async-select widgets may have the following properties in addition to the defaults used by netlity.
url
- string - required
The URI of the endpoint which to request data to populate the select options.
valueField
- string - required
Field in the data response which will be mapped to the value of the netlify widget once populated.
displayField
- string - optional
default: valueField
Field in the data response which will be mapped to the display text of the netlify widget once populated.
dataKey
- string - optional
default: valueField
Field in the data response which will be used for the source of the data.
For example, given the below data structure, you may set dataKey: 'data'
to populate the select dropdown as expected.
Example:
{
meta: {
page: 1,
total: 10
...
}
data: [{
id: 1,
name: 'user 1',
email: 'foo@bar.com'
},{
...
}]
}
headers
- object - optional
default: {}
Key-value object of HTTP headers to pass to the endpoint.
Example:
{
'Content-Type': 'application/json',
...
}
method
- string - optional
default: GET
HTTP request method to use when making call to endpoint.
body
- optional
default: undefined
Body to send in request to endpoint.
filter
- function - optional
default: undefined
Function which receives parameter entry
(Immutable.js Map) which is run on each item returned from endpoint. Similar to Array.prototype.filter
this will reject anything which does not return truthy.
Example:
filter: (entry) => {
return entry.get('id') % 2;
}
Better documentation coming soon.
For help with this widget, open an issue or ask the Netlify CMS community in Gitter.
FAQs
An async select widget for netlify-cms which can populate entries from a valid endpoint. Allows for sending custom headers, data/value fields and transformations.
We found that netlify-cms-widget-async-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).