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ā¦
Because this is a complicated, multi-step thing, I made an example plugin for you to show how it could work:
The important files are:
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).