aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts18
-rw-r--r--client/src/app/core/plugins/plugin.service.ts7
2 files changed, 18 insertions, 7 deletions
diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
index 2c5dbea95..ca9ad9922 100644
--- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
@@ -19,6 +19,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
19 pluginTypeLabel: string 19 pluginTypeLabel: string
20 20
21 private sub: Subscription 21 private sub: Subscription
22 private npmName: string
22 23
23 constructor ( 24 constructor (
24 protected formValidatorService: FormValidatorService, 25 protected formValidatorService: FormValidatorService,
@@ -33,9 +34,9 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
33 ngOnInit () { 34 ngOnInit () {
34 this.sub = this.route.params.subscribe( 35 this.sub = this.route.params.subscribe(
35 routeParams => { 36 routeParams => {
36 const npmName = routeParams['npmName'] 37 this.npmName = routeParams['npmName']
37 38
38 this.loadPlugin(npmName) 39 this.loadPlugin(this.npmName)
39 } 40 }
40 ) 41 )
41 } 42 }
@@ -62,7 +63,11 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
62 } 63 }
63 64
64 isSettingHidden (setting: RegisterServerSettingOptions) { 65 isSettingHidden (setting: RegisterServerSettingOptions) {
65 return false 66 const script = this.pluginService.getRegisteredSettingsScript(this.npmName)
67
68 if (!script?.isSettingHidden) return false
69
70 return script.isSettingHidden({ setting, formValues: this.form.value })
66 } 71 }
67 72
68 private loadPlugin (npmName: string) { 73 private loadPlugin (npmName: string) {
@@ -74,6 +79,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
74 .subscribe( 79 .subscribe(
75 async ({ plugin, registeredSettings }) => { 80 async ({ plugin, registeredSettings }) => {
76 this.plugin = plugin 81 this.plugin = plugin
82
77 this.registeredSettings = await this.translateSettings(registeredSettings) 83 this.registeredSettings = await this.translateSettings(registeredSettings)
78 84
79 this.pluginTypeLabel = this.pluginAPIService.getPluginTypeLabel(this.plugin.type) 85 this.pluginTypeLabel = this.pluginAPIService.getPluginTypeLabel(this.plugin.type)
@@ -110,11 +116,9 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
110 } 116 }
111 117
112 private async translateSettings (settings: RegisterServerSettingOptions[]) { 118 private async translateSettings (settings: RegisterServerSettingOptions[]) {
113 const npmName = this.pluginService.nameToNpmName(this.plugin.name, this.plugin.type)
114
115 for (const setting of settings) { 119 for (const setting of settings) {
116 for (const key of [ 'label', 'html', 'descriptionHTML' ]) { 120 for (const key of [ 'label', 'html', 'descriptionHTML' ]) {
117 if (setting[key]) setting[key] = await this.pluginService.translateBy(npmName, setting[key]) 121 if (setting[key]) setting[key] = await this.pluginService.translateBy(this.npmName, setting[key])
118 } 122 }
119 123
120 if (Array.isArray(setting.options)) { 124 if (Array.isArray(setting.options)) {
@@ -123,7 +127,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
123 for (const o of setting.options) { 127 for (const o of setting.options) {
124 newOptions.push({ 128 newOptions.push({
125 value: o.value, 129 value: o.value,
126 label: await this.pluginService.translateBy(npmName, o.label) 130 label: await this.pluginService.translateBy(this.npmName, o.label)
127 }) 131 })
128 } 132 }
129 133
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index c2dcf9fef..1243bac67 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -19,6 +19,7 @@ import {
19 PluginTranslation, 19 PluginTranslation,
20 PluginType, 20 PluginType,
21 PublicServerSetting, 21 PublicServerSetting,
22 RegisterClientSettingsScript,
22 ServerConfigPlugin 23 ServerConfigPlugin
23} from '@shared/models' 24} from '@shared/models'
24import { environment } from '../../../environments/environment' 25import { environment } from '../../../environments/environment'
@@ -58,6 +59,7 @@ export class PluginService implements ClientHook {
58 private formFields: FormFields = { 59 private formFields: FormFields = {
59 video: [] 60 video: []
60 } 61 }
62 private settingsScripts: { [ npmName: string ]: RegisterClientSettingsScript } = {}
61 63
62 constructor ( 64 constructor (
63 private authService: AuthService, 65 private authService: AuthService,
@@ -200,6 +202,10 @@ export class PluginService implements ClientHook {
200 return this.formFields.video.filter(f => f.videoFormOptions.type === type) 202 return this.formFields.video.filter(f => f.videoFormOptions.type === type)
201 } 203 }
202 204
205 getRegisteredSettingsScript (npmName: string) {
206 return this.settingsScripts[npmName]
207 }
208
203 translateBy (npmName: string, toTranslate: string) { 209 translateBy (npmName: string, toTranslate: string) {
204 const helpers = this.helpers[npmName] 210 const helpers = this.helpers[npmName]
205 if (!helpers) { 211 if (!helpers) {
@@ -220,6 +226,7 @@ export class PluginService implements ClientHook {
220 return loadPlugin({ 226 return loadPlugin({
221 hooks: this.hooks, 227 hooks: this.hooks,
222 formFields: this.formFields, 228 formFields: this.formFields,
229 onSettingsScripts: options => this.settingsScripts[npmName] = options,
223 pluginInfo, 230 pluginInfo,
224 peertubeHelpersFactory: () => helpers 231 peertubeHelpersFactory: () => helpers
225 }) 232 })