From 3c47fa3bc0e3f2362bb17976057287a7e9aba46b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Apr 2021 13:50:31 +0200 Subject: Add ability to hide plugin settings --- .../plugin-show-installed.component.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'client/src/app/+admin') 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 pluginTypeLabel: string private sub: Subscription + private npmName: string constructor ( protected formValidatorService: FormValidatorService, @@ -33,9 +34,9 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit ngOnInit () { this.sub = this.route.params.subscribe( routeParams => { - const npmName = routeParams['npmName'] + this.npmName = routeParams['npmName'] - this.loadPlugin(npmName) + this.loadPlugin(this.npmName) } ) } @@ -62,7 +63,11 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit } isSettingHidden (setting: RegisterServerSettingOptions) { - return false + const script = this.pluginService.getRegisteredSettingsScript(this.npmName) + + if (!script?.isSettingHidden) return false + + return script.isSettingHidden({ setting, formValues: this.form.value }) } private loadPlugin (npmName: string) { @@ -74,6 +79,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit .subscribe( async ({ plugin, registeredSettings }) => { this.plugin = plugin + this.registeredSettings = await this.translateSettings(registeredSettings) this.pluginTypeLabel = this.pluginAPIService.getPluginTypeLabel(this.plugin.type) @@ -110,11 +116,9 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit } private async translateSettings (settings: RegisterServerSettingOptions[]) { - const npmName = this.pluginService.nameToNpmName(this.plugin.name, this.plugin.type) - for (const setting of settings) { for (const key of [ 'label', 'html', 'descriptionHTML' ]) { - if (setting[key]) setting[key] = await this.pluginService.translateBy(npmName, setting[key]) + if (setting[key]) setting[key] = await this.pluginService.translateBy(this.npmName, setting[key]) } if (Array.isArray(setting.options)) { @@ -123,7 +127,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit for (const o of setting.options) { newOptions.push({ value: o.value, - label: await this.pluginService.translateBy(npmName, o.label) + label: await this.pluginService.translateBy(this.npmName, o.label) }) } -- cgit v1.2.3