From 0ea9f463a9dc642ec44af4887b97e9dd63b323ef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Apr 2021 11:18:13 +0200 Subject: Add action:admin-plugin-settings.init client hook --- .../plugin-show-installed.component.html | 2 +- .../plugin-show-installed/plugin-show-installed.component.ts | 11 ++++++++++- client/src/app/core/plugins/plugin.service.ts | 1 + shared/models/plugins/client-hook.model.ts | 4 ++++ shared/models/plugins/plugin-client-scope.type.ts | 10 +++++++++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html index ad65293d4..dbc521092 100644 --- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html +++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html @@ -6,7 +6,7 @@
-
+
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 ca9ad9922..c3d14d2b3 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 @@ -2,7 +2,7 @@ import { Subscription } from 'rxjs' import { map, switchMap } from 'rxjs/operators' import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { Notifier, PluginService } from '@app/core' +import { HooksService, Notifier, PluginService } from '@app/core' import { BuildFormArgument } from '@app/shared/form-validators' import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models' @@ -26,6 +26,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit private pluginService: PluginService, private pluginAPIService: PluginApiService, private notifier: Notifier, + private hooks: HooksService, private route: ActivatedRoute ) { super() @@ -70,6 +71,12 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit return script.isSettingHidden({ setting, formValues: this.form.value }) } + getWrapperId (setting: RegisterServerSettingOptions) { + if (!setting.name) return + + return setting.name + '-wrapper' + } + private loadPlugin (npmName: string) { this.pluginAPIService.getPlugin(npmName) .pipe(switchMap(plugin => { @@ -103,6 +110,8 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit this.buildForm(buildOptions) this.form.patchValue(settingsValues) + + setTimeout(() => this.hooks.runAction('action:admin-plugin-settings.init', 'admin-plugin', { npmName: this.npmName })) } private getSetting (name: string) { diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 1243bac67..ee80d4d39 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -34,6 +34,7 @@ export class PluginService implements ClientHook { pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject } = { common: new ReplaySubject(1), + 'admin-plugin': new ReplaySubject(1), search: new ReplaySubject(1), 'video-watch': new ReplaySubject(1), signup: new ReplaySubject(1), diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts index f8ca32771..620651051 100644 --- a/shared/models/plugins/client-hook.model.ts +++ b/shared/models/plugins/client-hook.model.ts @@ -85,6 +85,10 @@ export const clientActionHookObject = { // Fired when the registration page is being initialized 'action:signup.register.init': true, + // PeerTube >= 3.2 + // Fired when the admin plugin settings page is being initialized + 'action:admin-plugin-settings.init': true, + // Fired when the video upload page is being initalized 'action:video-upload.init': true, // Fired when the video import by URL page is being initalized diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/plugin-client-scope.type.ts index e188ce100..8cc234ff2 100644 --- a/shared/models/plugins/plugin-client-scope.type.ts +++ b/shared/models/plugins/plugin-client-scope.type.ts @@ -1 +1,9 @@ -export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup' | 'login' | 'embed' | 'video-edit' +export type PluginClientScope = + 'common' | + 'video-watch' | + 'search' | + 'signup' | + 'login' | + 'embed' | + 'video-edit' | + 'admin-plugin' -- cgit v1.2.3