Comments (4)
Hello @bjoernbg, thanks for creating this issue. As you know, that "Source" doesn't work for custom field plugins yet. There is an internal ticket for this task, but no ETA yet. Ultimately we'd like to have something like this:
const { type, data, actions } = useFieldPlugin();
console.log(data.options); // <- you should have all the options from Dataset here
While it's not the case yet, there is a workaround if you'd like to try out.
useEffect(() => {
if (type === 'loaded') {
const url = `https://api.storyblok.com/v2/cdn/datasource_entries?token=${data.token}`
fetch(url, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((json) => {
console.log('# data source entries', json)
})
}
}, [type])
This will give you this:
{
"datasource_entries": [
{
"id": 3564960,
"name": "asdf",
"value": "vasdfasd",
"dimension_value": null
},
{
"id": 3564961,
"name": "wef",
"value": "sfhsdfg",
"dimension_value": null
},
{
"id": 7035428,
"name": "HEY",
"value": "VALUE",
"dimension_value": null
}
]
}
What do you think?
from field-plugin.
Thanks, that would be our idea as well, but it's a bit more complicated nonetheless. Also, it seems that we only get a cached version of the datasource through the REST endpoint (X-Cache
header says Hit from cloudfront
). Changes that I made to my datasource in Storyblok are not beeing reflected in the result from the fetch. At least for 5 minutes or so, which is cumbersome and would make it difficult to change something on a live system and test it immediately (you never know when you get the latest version).
So it's not really an option for now.
from field-plugin.
@bjoernbg thanks for the perspective. That is definitely going to be a good push to the team to improve this part. It's indeed a CDN endpoint which doesn't guarantee realtime updates. You can use Management API instead, which gives you the latest data without caching. But you need Personal Access Token for this, which means you're gonna have to embed it in your source code which is not good security-wise, or put it as an option, which still can be seen anyone in your Storyblok organization.
Feel free to explore what I just suggested above if the drawback is bearable to you. In the meantime, I've just re-initiated the internal discussion on this topic. I will let you know the progress.
from field-plugin.
Hey @bjoernbg, our team has worked on enabling the 'datasources' as a field plugin source option. The functionality works as follows: If you select a datasource as the field plugin source, the key-value pairs will be passed as options to the field plugin. This should make the reusability of options between field plugins throughout the space much easier.
Feel free to give it a try and share your feedback with us.
from field-plugin.
Related Issues (20)
- Vue 3: Sandbox Reactivity Issues
- Sandbox not working in the browser Brave due to ad blocker HOT 1
- Multirepo pnpm install fails after creation HOT 8
- Wrong modal iframe heigth HOT 5
- Visual Editor does not detect changes in custom field plugin HOT 6
- Possibility to edit complete data structure in Field Plugin Sandbox HOT 3
- Access FieldPlugin options from within validateContent HOT 1
- Cannot find module '@storyblok/field-plugin/test' or its corresponding type declarations. HOT 3
- Add selected interface app language HOT 2
- Vue3 plugin options from useFieldPlugin hook is `undefined` HOT 2
- Field Plugin height is not correctly updated HOT 1
- [sandbox] Preserve settings in URL query parameters for easy sharing HOT 1
- Extend CLI with --publish flag option configurable
- Extend CLI deploy command with --spaces flag option configurable HOT 4
- Extend CLI to enable deleting field-type plugins HOT 4
- Add easy access to current block data object HOT 3
- Field plugins do not work on domains other than app.storyblok.com
- Vite 5 support ?
- Default options not working HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from field-plugin.