Hello everyone,I am hoping to write my first dato plugin! however this one needs to work within the â/media/assets/â area of the UI.Ideally I want to be able to either
Perform bulk operations on all videos
Perform the operation on individual videos
If I can only do the second via the sidebar on a video asset. I can live with that. However I am finding it difficult to figure out how to affect the asset area, except through asset sources the documentation isnt very clear about plugins in this area.
My plugin isnât really an âasset sourceâ. I am hoping to manipulate the subtitle files on a video (essentially I want to download the srt, replace English swear words and re-upload the âcleanedâ version as an alternate subtitle file)
after trying for a bit on my own I have some questions:
is it a bad idea to mix in the content management sdk with a plugin?
is the âUploadSidebarPanelsHookâ where I want to look for individual video manipulation
I could âabuseâ the asset sources to at least get me a new dialogue, but it doesnât feel very clean, it did however let me experiment with const items = await ctx.selectUpload({ multiple: true});
which gives me a way of letting the user select the videos they want to edit subtitles of however:
-This however doesnât let me filter to video assets (as far as I can see)
-the âuploadâ type doesnât seem to have access to the subtitle fileâŚ
main.tsx shows how to render a plugin sidebar panel, per our docs
UploadSideBarPanel.tsx shows a basic lifecycle of downloading the subtitle tracks, editing them, re-uploading them, and adding them as new tracks to the upload
I also sent you an email invite to a demo project where you can see this plugin in action. This video shows what it does:
Detailed answers:
And to answer your questions more specifically:
Unfortunately, we donât have a way for plugins to interact with multiple items in the media library directly You can use a custom page, but youâd have to create the whole media gallery from scratch, which isnât easy. Sorry! It could be a feature request though.
It is an âasset sidebar panelâ that you want. It has nothing to do with asset sources.
Nope, itâs totally fine. Thatâs why we give plugins the ability to request/require ctx.currentUserAccessToken.
Sort of⌠renderUploadSidebarPanelsHook is the real starting place, but that only gets you access to ctx.upload for the basic upload info (like the id). From there youâll have to make CMA or fetch calls:
Hope that helps! Please let me know if thereâs anything I can clarify. Otherwise, hopefully you can use that example as a starting point to really flesh it out
Sorry thereâs not a nice way to do this to multiple files at once Of course you can do it all with a webhook or custom build trigger instead, using similar logic to the above. But the UX/UI of that wonât be as clear, so youâll have to explain to editors how it works.
(i.e. itâs basically just a CMA bulk update script that you write external to the Dato UI altogether, and all the editors would be able to do in the UI is invoke that webhook).
Which file is that? Can I please see the whole file, instead of just those few lines? Notably, are those functions inside a connect() call in main.tsx, like in my example?
And inside renderUploadSidebarPanel(), I thiiiiink you also donât need to return render(), just call render() directly. If you return it, I believe it might just disappear into the void (since youâre passing it instead of running it)?
If itâs easier, feel free to share the whole repo with me (r.tuan@datocms.com).