From d2d9dfcffc48386fc2f4e76fd96f172424ef2258 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Jan 2025 15:06:47 +0100 Subject: [PATCH] Reorder client actions sections --- support/doc/plugins/guide.md | 66 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index c9d6dc430..9c858ad20 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md @@ -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. -### 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 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). +#### 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 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.