Reorder client actions sections

This commit is contained in:
Chocobozzz 2025-01-28 15:06:47 +01:00
parent 2920344fe7
commit d2d9dfcffc
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 33 additions and 33 deletions

View File

@ -109,39 +109,6 @@ function register ({ registerHook, peertubeHelpers }) {
See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete hooks list. See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete hooks list.
### Client actions
Plugin can trigger actions in the client by calling `doAction` with a specific action.
This can be used in combination with a hook to add custom admin actions, for instance:
```
function register ({ registerHook, doAction }) {
registerHook({
target: 'filter:admin-video-comments-list.bulk-actions.create.result',
handler: async menuItems => {
return menuItems.concat(
[
{
label: 'Mark as spam',
description: 'Report as spam and delete user.',
handler: async (comments) => {
// Show the loader
doAction('application:increment-loader')
// Run custom function
await deleteCommentsAndMarkAsSpam(comments)
// Reload the list in order for the admin to see the updated list
await doAction('admin-video-comments-list:load-data')
},
isDisplayed: (users) => true,
}
])
}
})
}
```
See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete `doAction` list.
### Static files ### Static files
Plugins can declare static directories that PeerTube will serve (images for example) Plugins can declare static directories that PeerTube will serve (images for example)
@ -955,6 +922,39 @@ function register ({ registerClientRoute }) {
You can then access the page on `/p/my-super/route` (please note the additional `/p/` in the path). You can then access the page on `/p/my-super/route` (please note the additional `/p/` in the path).
#### Run actions
Plugin can trigger actions in the client by calling `doAction` with a specific action.
This can be used in combination with a hook to add custom admin actions, for instance:
```js
function register ({ registerHook, doAction }) {
registerHook({
target: 'filter:admin-video-comments-list.bulk-actions.create.result',
handler: async menuItems => {
return menuItems.concat(
[
{
label: 'Mark as spam',
description: 'Report as spam and delete user.',
handler: async (comments) => {
// Show the loader
doAction('application:increment-loader')
// Run custom function
await deleteCommentsAndMarkAsSpam(comments)
// Reload the list in order for the admin to see the updated list
await doAction('admin-video-comments-list:load-data')
},
isDisplayed: (users) => true,
}
])
}
})
}
```
See the [plugin API reference](https://docs.joinpeertube.org/api/plugins) to see the complete `doAction` list.
### Publishing ### Publishing
PeerTube plugins and themes should be published on [NPM](https://www.npmjs.com/) so that PeerTube indexes take into account your plugin (after ~ 1 day). An official plugin index is available on [packages.joinpeertube.org](https://packages.joinpeertube.org/api/v1/plugins), with no interface to present packages. PeerTube plugins and themes should be published on [NPM](https://www.npmjs.com/) so that PeerTube indexes take into account your plugin (after ~ 1 day). An official plugin index is available on [packages.joinpeertube.org](https://packages.joinpeertube.org/api/v1/plugins), with no interface to present packages.