Plugin system issues

After working on the peertube-plugin-categories

see Categories management plugin - #5 par lutangar

I encoutered the following issues. I’ll probably create Github issues from some of these and even submit PR …but mb I’m missing a few obvious things…

Overall

  • unregister should take the same arguments as register

ex: when the extension is uninstalled how to reset settings or storage?

  • typescript type definition should be exposed

see Expose Typescript type definition · Issue #4201 · Chocobozzz/PeerTube · GitHub

Categories (or constants customization overall)

  • getCategories should be exposed on categoryManager

  • other getter methods should probably be added to retrieve the customizations done mbgetAddedCategories, getDeletedCategories, …

  • categories shouldn’t be modified in memory but stored somewhere in database

many potential unwanted side effects

Missing hooks

  • [client-hook] form submit success/settings changed success
  • add a way to set the form submission as failed server side

ex: throwing in the plugin handleSettingsChages doesn’t do anything
ex: this could allow custom error messages

Translation

might be just me, so please forgive me…

  • it seems plugin translation system doesn’t work

see PeerTube/client/src/app/core/plugins/plugin.service.ts at v3.2.1 · Chocobozzz/PeerTube · GitHub
it seems the helpers property is never populated…

  • I don’t know whcich i18n library is used internally, but there should be a way to add parameters to the translation key.
    Something like the following:
    Hello {name}, how are you today?

To avoid having lengthy keys, I tried to use technical key instead of plain english (ex: settings.greeting) but renounce because of the previous point (bug?).

Settings

  • as there is a registerSetting method there probably should be an unregisterSettting method
  • an html form element added via registerSetting is never found back in the settings

thus it can never be retrieved or updated via the `settingsManager

  • missing delete method on the settingsManager

mb clear settings automatically when the plugin is uninstalled?
OR leave the choice to the plugin developer?

  • there could be an input type file

  • Question: how to implement efficiently a datagrid on the settings page? Should it be part of the plugin API?*

…or mb there is a way to reuse part of the Angular UI?

Storage

  • missing delete method on storageManager

same thought as for the settings: shall it be cleared on uninstall?

Here’s an HedgeDoc version of this list, if it can be of any help:
PeerTube issues - HedgeDoc

I discussed this with @Chocobozzz , and it was not easy to implement. The solution he tell me to use is to store options in a global var. See here: peertube-plugin-livechat/server/main.ts at 499ecffe624c0fa1db0bf095fb0a4b3dbd005424 · JohnXLivingston/peertube-plugin-livechat · GitHub

English is never translated. Peertube don’t allow to use technical key.
It is an issue, as it make it very hard to have long text to translate. That’s why I haven’t translated the settings screen in my livechat plugin for now… I don’t know how I can do.

«html» settings are not fields, but text that will be displayed between settings. You can use this to add custom text, or even custom buttons!

unregister should take the same arguments as register

  • getCategories should be exposed on categoryManager

missing delete method on the settingsManager

missing delete method on storageManager

Please create issues :slight_smile:

I think the plugin can remember what it did in the past, and track added/deleted categories.

categories shouldn’t be modified in memory but stored somewhere in database

The plugin system is designed to update peertube state/behaviour at runtime to keep things simple. It’s the plugin job to remember what it want to do depending on a previous state.

Missing hooks

Please create issues so we add them

Did you manage to make it work?

Please create an issue so we improve the translation system (very limited at the moment)

If you need it, please create an issue

I think you can try to use the html setting type to inject custom HTML in the page.