aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/root-helpers/plugins.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-09 13:50:31 +0200
committerChocobozzz <me@florianbigard.com>2021-04-09 13:50:31 +0200
commit3c47fa3bc0e3f2362bb17976057287a7e9aba46b (patch)
tree0f74d23e219e7c917034d9cd394fabc4668f16fa /client/src/root-helpers/plugins.ts
parentc713017f3cd2d617da22c24c579342ec4121cfcd (diff)
downloadPeerTube-3c47fa3bc0e3f2362bb17976057287a7e9aba46b.tar.gz
PeerTube-3c47fa3bc0e3f2362bb17976057287a7e9aba46b.tar.zst
PeerTube-3c47fa3bc0e3f2362bb17976057287a7e9aba46b.zip
Add ability to hide plugin settings
Diffstat (limited to 'client/src/root-helpers/plugins.ts')
-rw-r--r--client/src/root-helpers/plugins.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/client/src/root-helpers/plugins.ts b/client/src/root-helpers/plugins.ts
index 4bc2c8eb2..5344c0468 100644
--- a/client/src/root-helpers/plugins.ts
+++ b/client/src/root-helpers/plugins.ts
@@ -7,7 +7,8 @@ import {
7 ClientScript, 7 ClientScript,
8 PluginType, 8 PluginType,
9 RegisterClientHookOptions, 9 RegisterClientHookOptions,
10 ServerConfigPlugin 10 ServerConfigPlugin,
11 RegisterClientSettingsScript
11} from '../../../shared/models' 12} from '../../../shared/models'
12import { ClientScript as ClientScriptModule } from '../types/client-script.model' 13import { ClientScript as ClientScriptModule } from '../types/client-script.model'
13import { importModule } from './utils' 14import { importModule } from './utils'
@@ -54,8 +55,9 @@ function loadPlugin (options: {
54 pluginInfo: PluginInfo 55 pluginInfo: PluginInfo
55 peertubeHelpersFactory: (pluginInfo: PluginInfo) => RegisterClientHelpers 56 peertubeHelpersFactory: (pluginInfo: PluginInfo) => RegisterClientHelpers
56 formFields?: FormFields 57 formFields?: FormFields
58 onSettingsScripts?: (options: RegisterClientSettingsScript) => void
57}) { 59}) {
58 const { hooks, pluginInfo, peertubeHelpersFactory, formFields } = options 60 const { hooks, pluginInfo, peertubeHelpersFactory, formFields, onSettingsScripts } = options
59 const { plugin, clientScript } = pluginInfo 61 const { plugin, clientScript } = pluginInfo
60 62
61 const registerHook = (options: RegisterClientHookOptions) => { 63 const registerHook = (options: RegisterClientHookOptions) => {
@@ -86,12 +88,20 @@ function loadPlugin (options: {
86 }) 88 })
87 } 89 }
88 90
91 const registerSettingsScript = (options: RegisterClientSettingsScript) => {
92 if (!onSettingsScripts) {
93 throw new Error('Registering settings script is not supported')
94 }
95
96 return onSettingsScripts(options)
97 }
98
89 const peertubeHelpers = peertubeHelpersFactory(pluginInfo) 99 const peertubeHelpers = peertubeHelpersFactory(pluginInfo)
90 100
91 console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) 101 console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name)
92 102
93 return importModule(clientScript.script) 103 return importModule(clientScript.script)
94 .then((script: ClientScriptModule) => script.register({ registerHook, registerVideoField, peertubeHelpers })) 104 .then((script: ClientScriptModule) => script.register({ registerHook, registerVideoField, registerSettingsScript, peertubeHelpers }))
95 .then(() => sortHooksByPriority(hooks)) 105 .then(() => sortHooksByPriority(hooks))
96 .catch(err => console.error('Cannot import or register plugin %s.', pluginInfo.plugin.name, err)) 106 .catch(err => console.error('Cannot import or register plugin %s.', pluginInfo.plugin.name, err))
97} 107}