Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add action:admin-plugin-settings.init client hook

Chocobozzz0ea9f463a9dc
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 ad65293d42..dbc5210927 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 @@
</h2>
<form *ngIf="hasRegisteredSettings()" role="form" (ngSubmit)="formValidated()" [formGroup]="form">
- <div class="form-group" *ngFor="let setting of registeredSettings">
+ <div class="form-group" *ngFor="let setting of registeredSettings" [id]="getWrapperId(setting)">
<my-dynamic-form-field [hidden]="isSettingHidden(setting)" [form]="form" [setting]="setting" [formErrors]="formErrors"></my-dynamic-form-field>
</div>
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 ca9ad9922b..c3d14d2b37 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 1243bac679..ee80d4d39b 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<boolean> } = {
common: new ReplaySubject<boolean>(1),
+ 'admin-plugin': new ReplaySubject<boolean>(1),
search: new ReplaySubject<boolean>(1),
'video-watch': new ReplaySubject<boolean>(1),
signup: new ReplaySubject<boolean>(1),
diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts
index f8ca327715..620651051f 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 e188ce1003..8cc234ff22 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'