mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-20 11:48:31 -06:00
Add action:admin-plugin-settings.init client hook
This commit is contained in:
parent
302eba0d89
commit
0ea9f463a9
@ -6,7 +6,7 @@
|
|||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<form *ngIf="hasRegisteredSettings()" role="form" (ngSubmit)="formValidated()" [formGroup]="form">
|
<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>
|
<my-dynamic-form-field [hidden]="isSettingHidden(setting)" [form]="form" [setting]="setting" [formErrors]="formErrors"></my-dynamic-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { Subscription } from 'rxjs'
|
|||||||
import { map, switchMap } from 'rxjs/operators'
|
import { map, switchMap } from 'rxjs/operators'
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core'
|
import { Component, OnDestroy, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute } from '@angular/router'
|
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 { BuildFormArgument } from '@app/shared/form-validators'
|
||||||
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
||||||
import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
|
import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
|
||||||
@ -26,6 +26,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
|
|||||||
private pluginService: PluginService,
|
private pluginService: PluginService,
|
||||||
private pluginAPIService: PluginApiService,
|
private pluginAPIService: PluginApiService,
|
||||||
private notifier: Notifier,
|
private notifier: Notifier,
|
||||||
|
private hooks: HooksService,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
@ -70,6 +71,12 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
|
|||||||
return script.isSettingHidden({ setting, formValues: this.form.value })
|
return script.isSettingHidden({ setting, formValues: this.form.value })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWrapperId (setting: RegisterServerSettingOptions) {
|
||||||
|
if (!setting.name) return
|
||||||
|
|
||||||
|
return setting.name + '-wrapper'
|
||||||
|
}
|
||||||
|
|
||||||
private loadPlugin (npmName: string) {
|
private loadPlugin (npmName: string) {
|
||||||
this.pluginAPIService.getPlugin(npmName)
|
this.pluginAPIService.getPlugin(npmName)
|
||||||
.pipe(switchMap(plugin => {
|
.pipe(switchMap(plugin => {
|
||||||
@ -103,6 +110,8 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
|
|||||||
this.buildForm(buildOptions)
|
this.buildForm(buildOptions)
|
||||||
|
|
||||||
this.form.patchValue(settingsValues)
|
this.form.patchValue(settingsValues)
|
||||||
|
|
||||||
|
setTimeout(() => this.hooks.runAction('action:admin-plugin-settings.init', 'admin-plugin', { npmName: this.npmName }))
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSetting (name: string) {
|
private getSetting (name: string) {
|
||||||
|
@ -34,6 +34,7 @@ export class PluginService implements ClientHook {
|
|||||||
|
|
||||||
pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
|
pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
|
||||||
common: new ReplaySubject<boolean>(1),
|
common: new ReplaySubject<boolean>(1),
|
||||||
|
'admin-plugin': new ReplaySubject<boolean>(1),
|
||||||
search: new ReplaySubject<boolean>(1),
|
search: new ReplaySubject<boolean>(1),
|
||||||
'video-watch': new ReplaySubject<boolean>(1),
|
'video-watch': new ReplaySubject<boolean>(1),
|
||||||
signup: new ReplaySubject<boolean>(1),
|
signup: new ReplaySubject<boolean>(1),
|
||||||
|
@ -85,6 +85,10 @@ export const clientActionHookObject = {
|
|||||||
// Fired when the registration page is being initialized
|
// Fired when the registration page is being initialized
|
||||||
'action:signup.register.init': true,
|
'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
|
// Fired when the video upload page is being initalized
|
||||||
'action:video-upload.init': true,
|
'action:video-upload.init': true,
|
||||||
// Fired when the video import by URL page is being initalized
|
// Fired when the video import by URL page is being initalized
|
||||||
|
@ -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'
|
||||||
|
Loading…
Reference in New Issue
Block a user